Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2100698rdb; Thu, 7 Dec 2023 19:48:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCgbzTZkCw+eWsMPBxZO+2uTwugVmA4+rDYfhxslEuLF3tPlKjttwkxBmWWiHKylG/9Adu X-Received: by 2002:a05:6830:388e:b0:6d9:ee23:8cc9 with SMTP id bq14-20020a056830388e00b006d9ee238cc9mr135004otb.72.1702007282107; Thu, 07 Dec 2023 19:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702007282; cv=none; d=google.com; s=arc-20160816; b=xDhriFNg9uIuojIJ/2DPC8Sz6b7RodQt51oA0oKCf16JCLrSBPqYmEVMcaMca1I3+5 evI31L2vSj1f27jLFJczyegOCYNHxLZqzOHAyz7tGvFFw2TkxwGgg4+kHI0PhzPsQCe/ QWQOCkPezfzuuVhv+SFjVRnn4wVYn9Y4PEKjvbPWsQ1jzT4uz7eXEU/DaiJJq9nipu5J jec9J85UjdCpKd9m/nv9olMqnaTTtyFAh+xOir1h8AqzRVDn/ErQcrHEtUdGLsBp2Vzt ZSLRO/a9pfWKtLRCQDOgHdykAhTmeNlEGHy4Wk0HVcluyFkJzh2bE+GQJHVGxN+I8sT8 bZuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=LRG1tZ4BUZmjduFYGxdtrgVWOq3VdOKTbXXj+ZyvQXQ=; fh=3iH2GxgcdimmRvE5W/njU1LIdTM6mcokrNGcjXrnDPY=; b=IBdAi27Krws2jHYBrCq6ec71yRI1G9AfrwR+4GnQbHp1MAUqFBg9lSYd+Il8JjbapQ f0uqbw74SPQGNISennXj3DSd8kDej0wFsTnQYiUUlYiGUo6jQrcb8N1RRX4TtAlYbWrR UynnxhM9HbkC0OE6AT3Ag0JRn95ckNZ2+ux+5Y5jG/YggqCRDz1oeQY5lj94tIsILwxn fSeaH73hfQbwqPL+fjWEkg/RzR+0Rf5URm+ceFwiYjdQNgxRI0gtDiba+UmTLIaq5NAn 3N9Qlto2ts5pTnZgJsxUjDoloZohtV9TzkulmzwL4ocAsd15FrvWJadyx5zMUih1Z6LI JTqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Y8auVz02; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id k129-20020a632487000000b005c627018c32si773376pgk.431.2023.12.07.19.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 19:48:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Y8auVz02; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5316480E73F9; Thu, 7 Dec 2023 19:47:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231892AbjLHDrC (ORCPT + 99 others); Thu, 7 Dec 2023 22:47:02 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 19:47:40 -0800 (PST) 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