From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BA34C4167B for ; Fri, 8 Dec 2023 03:47:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573078AbjLHDrD (ORCPT ); Thu, 7 Dec 2023 22:47:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbjLHDrB (ORCPT ); Thu, 7 Dec 2023 22:47:01 -0500 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [IPv6:2001:41d0:203:375::ad]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C4810F9 for ; Thu, 7 Dec 2023 19:47:06 -0800 (PST) Message-ID: <620df220-4b82-4102-ba56-1ed348c2f8cb@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702007224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LRG1tZ4BUZmjduFYGxdtrgVWOq3VdOKTbXXj+ZyvQXQ=; b=Y8auVz02tjoEIUc5pIn0TwqMEITXkgCR9ncdXJWR54TcaBEplXik5NNufV91wm50W4GLzw 7VVbQZlJ09/QB7mFD9brVfMbAbi69T7TzFW+6IeSyhOq0FQYFgWkUJTQx0mrIQiA2K16J1 6fAg53MbC+XKopi+b74uquU794C1NYc= Date: Thu, 7 Dec 2023 19:46:56 -0800 MIME-Version: 1.0 Subject: Re: [PATCH v2 3/3] selftest/bpf: Test a perf bpf program that suppresses side effects. Content-Language: en-GB To: Kyle Huey , Marco Elver Cc: Andrii Nakryiko , Kyle Huey , linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim , Robert O'Callahan , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Mykola Lysenko , Shuah Khan , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org References: <20231207163458.5554-1-khuey@kylehuey.com> <20231207163458.5554-4-khuey@kylehuey.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/7/23 5:08 PM, Kyle Huey wrote: > On Thu, Dec 7, 2023 at 2:56 PM Kyle Huey wrote: >> On Thu, Dec 7, 2023 at 11:20 AM Marco Elver wrote: >>> On Thu, 7 Dec 2023 at 20:12, Andrii Nakryiko wrote: >>>> On Thu, Dec 7, 2023 at 8:35 AM Kyle Huey wrote: >>>>> The test sets a hardware breakpoint and uses a bpf program to suppress the >>>>> side effects of a perf event sample, including I/O availability signals, >>>>> SIGTRAPs, and decrementing the event counter limit, if the ip matches the >>>>> expected value. Then the function with the breakpoint is executed multiple >>>>> times to test that all effects behave as expected. >>>>> >>>>> Signed-off-by: Kyle Huey >>>>> --- >>>>> .../selftests/bpf/prog_tests/perf_skip.c | 145 ++++++++++++++++++ >>>>> .../selftests/bpf/progs/test_perf_skip.c | 15 ++ >>>>> 2 files changed, 160 insertions(+) >>>>> create mode 100644 tools/testing/selftests/bpf/prog_tests/perf_skip.c >>>>> create mode 100644 tools/testing/selftests/bpf/progs/test_perf_skip.c >>>>> >>>>> diff --git a/tools/testing/selftests/bpf/prog_tests/perf_skip.c b/tools/testing/selftests/bpf/prog_tests/perf_skip.c >>>>> new file mode 100644 >>>>> index 000000000000..f6fa9bfd9efa >>>>> --- /dev/null >>>>> +++ b/tools/testing/selftests/bpf/prog_tests/perf_skip.c >>>>> @@ -0,0 +1,145 @@ >>>>> +// SPDX-License-Identifier: GPL-2.0 >>>>> +#define _GNU_SOURCE >>>>> + >>>>> +/* We need the latest siginfo from the kernel repo. */ >>>>> +#include >>>> selftests are built with UAPI headers' copies under tools/include, so >>>> CI did catch a real issue, I think. Try copying >>>> include/uapi/asm-generic/siginfo.h into >>>> tools/include/uapi/asm-generic/siginfo.h ? >>> I believe parts of this were inspired by >>> tools/testing/selftests/perf_events/sigtrap_threads.c - getting the >>> kernel headers is allowed, as long as $(KHDR_INCLUDES) is added to >>> CFLAGS. See tools/testing/selftests/perf_events/Makefile. Not sure >>> it's appropriate for this test though, if you don't want to add >>> KHDR_INCLUDES for everything. >> Yes, that's right. Namhyung's commit message for 91c97b36bd69 leads me >> to believe that I should copy siginfo.h over into tools/include and >> fix the perf_events self tests too. >> >> - Kyle > That doesn't really help (though perhaps it should be done anyway so > the selftests aren't reaching into include/) because the glibc headers > still redefine a ton of stuff in asm-generic/siginfo.h. Just for testing purpose, I think you can avoid includeasm/siginfo.h and directly define necessary structures in the C file directly, right? > > - Kyle