From nobody Wed Nov 27 10:40:41 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 543181D31B2; Thu, 10 Oct 2024 20:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728591170; cv=none; b=V+SQKTT0efWPnWySyLZLl0+gPspzLkuPVSgv6dJvI0nG8XSICcGDpwsi5tsvt9k4Q7OQpZWlUZ6pRHJnzl7Dw5lTS+Ij4X5FySD/hydaLoqKixb1ON784m+428elGDENqqfqL0pYVVEW47C2kw+SAKdKKHFRmFkcW57J5KZ/sl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728591170; c=relaxed/simple; bh=U/bLZDppAfaNNv5D7VdyCPV08xWP80i4ouw+8O8MYJ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IVe1D6jNmFiGO479sFwelHqTHB8XiV4DKrdzXrDbDdHjV5LGCs0E9LIS6JZ4hlOO+ocXCH5VFuZ+ENxl2PtmISz5XunEelCkN35qcNZ2thS7+Lxe+zruJ4eT9B/w1XoSbnkMtMQTSkapv66T9KF2OtD139kMVmSzejmAZ7INm/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p0pScCIF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p0pScCIF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95AEDC4CEC5; Thu, 10 Oct 2024 20:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728591170; bh=U/bLZDppAfaNNv5D7VdyCPV08xWP80i4ouw+8O8MYJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0pScCIF7wGzfula9l/0/yy2HGyyFOYxiqajdAgEiejc4GGt2SYTp+XnvY8UxN315 yyz8pinFn7s/gMdF9xeSS2iqhezKPlSq7ozkDYC9Y9UYAGU9VUQKkKJ8gNGCUmDrOB F+k/FVManD61OVleXofiHlCfg+suYOrVsQGXxF20IQgjzZsddDVycFMCRdQsm+hWE2 8tTePKv8y/KcA3wRURwhS4w8jpotfFukqhEtfSjYUCDtwMYptE9PAam6TPkdcsia4o ofgC5uNz4o2JCB1HZDGSo4KjtMUmBPIg43IOBnmcr1WpBloSk/5GrRop2zpEELgFHz WWrc25ke247+A== From: Jiri Olsa To: Oleg Nesterov , Peter Zijlstra , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Steven Rostedt , Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCHv6 bpf-next 14/16] selftests/bpf: Scale down uprobe multi consumer test Date: Thu, 10 Oct 2024 22:09:55 +0200 Message-ID: <20241010200957.2750179-15-jolsa@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241010200957.2750179-1-jolsa@kernel.org> References: <20241010200957.2750179-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We have currently 2 uprobes and 2 uretprobes and we are about to add sessions uprobes in following change, which makes the test time unsuitable for CI even with threads. It's enough for the test to have just 1 uprobe and 1 uretprobe. Signed-off-by: Jiri Olsa --- .../bpf/prog_tests/uprobe_multi_test.c | 57 ++++++++----------- .../bpf/progs/uprobe_multi_consumers.c | 16 +----- 2 files changed, 25 insertions(+), 48 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c b/t= ools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c index 7e0228f8fcfc..2effe4d693b4 100644 --- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c @@ -761,10 +761,6 @@ get_program(struct uprobe_multi_consumers *skel, int p= rog) return skel->progs.uprobe_0; case 1: return skel->progs.uprobe_1; - case 2: - return skel->progs.uprobe_2; - case 3: - return skel->progs.uprobe_3; default: ASSERT_FAIL("get_program"); return NULL; @@ -779,10 +775,6 @@ get_link(struct uprobe_multi_consumers *skel, int link) return &skel->links.uprobe_0; case 1: return &skel->links.uprobe_1; - case 2: - return &skel->links.uprobe_2; - case 3: - return &skel->links.uprobe_3; default: ASSERT_FAIL("get_link"); return NULL; @@ -799,10 +791,10 @@ static int uprobe_attach(struct uprobe_multi_consumer= s *skel, int idx) return -1; =20 /* - * bit/prog: 0,1 uprobe entry - * bit/prog: 2,3 uprobe return + * bit/prog: 0 uprobe entry + * bit/prog: 1 uprobe return */ - opts.retprobe =3D idx =3D=3D 2 || idx =3D=3D 3; + opts.retprobe =3D idx =3D=3D 1; =20 *link =3D bpf_program__attach_uprobe_multi(prog, 0, "/proc/self/exe", "uprobe_consumer_test", @@ -832,7 +824,7 @@ uprobe_consumer_test(struct uprobe_multi_consumers *ske= l, int idx; =20 /* detach uprobe for each unset programs in 'before' state ... */ - for (idx =3D 0; idx < 4; idx++) { + for (idx =3D 0; idx < 1; idx++) { if (test_bit(idx, before) && !test_bit(idx, after)) uprobe_detach(skel, idx); } @@ -855,7 +847,7 @@ static int consumer_test(struct uprobe_multi_consumers = *skel, printf("consumer_test before %lu after %lu\n", before, after); =20 /* 'before' is each, we attach uprobe for every set idx */ - for (idx =3D 0; idx < 4; idx++) { + for (idx =3D 0; idx < 1; idx++) { if (test_bit(idx, before)) { if (!ASSERT_OK(uprobe_attach(skel, idx), "uprobe_attach_before")) goto cleanup; @@ -866,18 +858,18 @@ static int consumer_test(struct uprobe_multi_consumer= s *skel, if (!ASSERT_EQ(err, 0, "uprobe_consumer_test")) goto cleanup; =20 - for (idx =3D 0; idx < 4; idx++) { + for (idx =3D 0; idx < 1; idx++) { const char *fmt =3D "BUG"; __u64 val =3D 0; =20 - if (idx < 2) { + if (idx =3D=3D 0) { /* * uprobe entry * +1 if define in 'before' */ if (test_bit(idx, before)) val++; - fmt =3D "prog 0/1: uprobe"; + fmt =3D "prog 0: uprobe"; } else { /* * to trigger uretprobe consumer, the uretprobe needs to be installed, @@ -885,11 +877,11 @@ static int consumer_test(struct uprobe_multi_consumer= s *skel, * * idxs: 2/3 uprobe return in 'installed' mask */ - unsigned long had_uretprobes =3D before & 0b1100; /* is uretprobe inst= alled */ + unsigned long had_uretprobes =3D before & 0b10; /* is uretprobe install= ed */ =20 if (had_uretprobes && test_bit(idx, after)) val++; - fmt =3D "idx 2/3: uretprobe"; + fmt =3D "prog 1: uretprobe"; } =20 if (!ASSERT_EQ(skel->bss->uprobe_result[idx], val, fmt)) @@ -900,7 +892,7 @@ static int consumer_test(struct uprobe_multi_consumers = *skel, ret =3D 0; =20 cleanup: - for (idx =3D 0; idx < 4; idx++) + for (idx =3D 0; idx < 1; idx++) uprobe_detach(skel, idx); return ret; } @@ -918,42 +910,41 @@ static void test_consumers(void) * The idea of this test is to try all possible combinations of * uprobes consumers attached on single function. * - * - 2 uprobe entry consumer - * - 2 uprobe exit consumers + * - 1 uprobe entry consumer + * - 1 uprobe exit consumer * - * The test uses 4 uprobes attached on single function, but that - * translates into single uprobe with 4 consumers in kernel. + * The test uses 2 uprobes attached on single function, but that + * translates into single uprobe with 2 consumers in kernel. * * The before/after values present the state of attached consumers * before and after the probed function: * - * bit/prog 0,1 : uprobe entry - * bit/prog 2,3 : uprobe return + * bit/prog 0 : uprobe entry + * bit/prog 1 : uprobe return * * For example for: * - * before =3D 0b0101 - * after =3D 0b0110 + * before =3D 0b01 + * after =3D 0b10 * * it means that before we call 'uprobe_consumer_test' we attach * uprobes defined in 'before' value: * - * - bit/prog 0: uprobe entry - * - bit/prog 2: uprobe return + * - bit/prog 1: uprobe entry * * uprobe_consumer_test is called and inside it we attach and detach * uprobes based on 'after' value: * - * - bit/prog 0: stays untouched - * - bit/prog 2: uprobe return is detached + * - bit/prog 0: is detached + * - bit/prog 1: is attached * * uprobe_consumer_test returns and we check counters values increased * by bpf programs on each uprobe to match the expected count based on * before/after bits. */ =20 - for (before =3D 0; before < 16; before++) { - for (after =3D 0; after < 16; after++) + for (before =3D 0; before < 4; before++) { + for (after =3D 0; after < 4; after++) if (consumer_test(skel, before, after)) goto out; } diff --git a/tools/testing/selftests/bpf/progs/uprobe_multi_consumers.c b/t= ools/testing/selftests/bpf/progs/uprobe_multi_consumers.c index 7e0fdcbbd242..1c64d7263911 100644 --- a/tools/testing/selftests/bpf/progs/uprobe_multi_consumers.c +++ b/tools/testing/selftests/bpf/progs/uprobe_multi_consumers.c @@ -8,7 +8,7 @@ =20 char _license[] SEC("license") =3D "GPL"; =20 -__u64 uprobe_result[4]; +__u64 uprobe_result[2]; =20 SEC("uprobe.multi") int uprobe_0(struct pt_regs *ctx) @@ -23,17 +23,3 @@ int uprobe_1(struct pt_regs *ctx) uprobe_result[1]++; return 0; } - -SEC("uprobe.multi") -int uprobe_2(struct pt_regs *ctx) -{ - uprobe_result[2]++; - return 0; -} - -SEC("uprobe.multi") -int uprobe_3(struct pt_regs *ctx) -{ - uprobe_result[3]++; - return 0; -} --=20 2.46.2