From patchwork Tue Sep 24 11:07:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13810787 X-Patchwork-Delegate: bpf@iogearbox.net 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 110071F5FF for ; Tue, 24 Sep 2024 11:07:38 +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=1727176059; cv=none; b=eVKG5/nC17kRXAUo6um/xjqxNqY9DNczBb72zkianTgqvx4oashMOGK5n4BJYGTm4AdCK23IWPdOnBnOCRumnH9jz7+peT8P7J4qb/9Hxrw/VFuskj71lD/xNPAFrDdBkAyqxskv0JsD9SxDNkQpo/ujQrDHmakgXwPW12q1otY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727176059; c=relaxed/simple; bh=9X7JIYFJyll421XZX259Qd6ks2dRNi4SBc6zWIWW5Xs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rmrhBzuzlB33x5av5BMXIXvSrfnCwK0IqiLaoStt4SXhRmtQxMM/4QcIKB6g3jrRpiBxdOSRcNihLy/dExCcii28vv83nNHnrbAaurdbENl0ts566PYZ76Xs+el9jNukovaDRbMSZtx82zmW4inViFVwRxqbLSUFUNS3ColxCjQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PIXNM2k3; 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="PIXNM2k3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57943C4CEC5; Tue, 24 Sep 2024 11:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727176058; bh=9X7JIYFJyll421XZX259Qd6ks2dRNi4SBc6zWIWW5Xs=; h=From:To:Cc:Subject:Date:From; b=PIXNM2k3eINB1XomYJ2y3gSbnK+EtNZDp4pk+0hAtk8m+MEORbOZH+Og6X6LBoabI y2OtNqQPFJiOMvI7mb+ATOsuZrFGzyChgDdsYeAfCO/xUOlpvIKHb3BONGgCMPpmIj 4hBKPb/WAAnQERW0vhwpviJRzyORyabWx/hQ/lv+KfMSoou4iZuabNqe/e+6VOZIG8 mhgldCf0vmVjxUqVUQh7DGKsf+IhKjErnXCK6K3DsDtHiUQDJfoQ0QAKej8KcPvSZD jxfd/1vd6V0MAqQl600WnBD8o/fp0RyfW0633HmykgwNOwxfXgsGyc9iX1pDwYwMHD Iyyk9Ef7WfB4g== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Ihor Solodrai , bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo Subject: [PATCH bpf-next 1/2] selftests/bpf: Fix uprobe consumer test Date: Tue, 24 Sep 2024 13:07:30 +0200 Message-ID: <20240924110731.2644249-1-jolsa@kernel.org> X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net With newly merged code the uprobe behaviour is slightly different and affects uprobe consumer test. We no longer need to check if the uprobe object is still preserved after removing last uretprobe, because it stays as long as there's pending/installed uretprobe instance. This allows to run uretprobe consumers registered 'after' uprobe was hit even if previous uretprobe got unregistered before being hit. The uprobe object will be now removed after the last uprobe ref is released and in such case it's held by ri->uprobe (return instance) which is released after the uretprobe is hit. Reported-by: Ihor Solodrai Closes: https://lore.kernel.org/bpf/w6U8Z9fdhjnkSp2UaFaV1fGqJXvfLEtDKEUyGDkwmoruDJ_AgF_c0FFhrkeKW18OqiP-05s9yDKiT6X-Ns-avN_ABf0dcUkXqbSJN1TQSXo=@pm.me/ Signed-off-by: Jiri Olsa Tested-by: Ihor Solodrai --- .../testing/selftests/bpf/prog_tests/uprobe_multi_test.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c index 844f6fc8487b..c1ac813ff9ba 100644 --- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c @@ -869,21 +869,14 @@ static void consumer_test(struct uprobe_multi_consumers *skel, fmt = "prog 0/1: uprobe"; } else { /* - * uprobe return is tricky ;-) - * * to trigger uretprobe consumer, the uretprobe needs to be installed, * which means one of the 'return' uprobes was alive when probe was hit: * * idxs: 2/3 uprobe return in 'installed' mask - * - * in addition if 'after' state removes everything that was installed in - * 'before' state, then uprobe kernel object goes away and return uprobe - * is not installed and we won't hit it even if it's in 'after' state. */ unsigned long had_uretprobes = before & 0b1100; /* is uretprobe installed */ - unsigned long probe_preserved = before & after; /* did uprobe go away */ - if (had_uretprobes && probe_preserved && test_bit(idx, after)) + if (had_uretprobes && test_bit(idx, after)) val++; fmt = "idx 2/3: uretprobe"; } From patchwork Tue Sep 24 11:07:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13810788 X-Patchwork-Delegate: bpf@iogearbox.net 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 A1C2C1A4E98 for ; Tue, 24 Sep 2024 11:07: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=1727176070; cv=none; b=k4NpF4xzgrx3l12QT5/Z0XU9hdR2wNQUJw3CZeOHQLgSOd36/ytSNen3sl6xM0Ygwe+9K89JQVEOnUJR25CPx3HgK7XnYqDuSjyAxyRK+kk+CZzhVNwSIJkly62dwYsC1uYYoM6ZXHuM7FaYdWOVT77yozYb7hl+1gv7LBOp+5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727176070; c=relaxed/simple; bh=8G37jGGd8Ye5q1WU19cVMSSjIr5L8SNGnVOyyv3/R/Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q0rAnJ0+MULzmcgo7EoIiaaROsX9IhdIj8xpOH/iTFVWnYF8S2MGOk2VN+bLSTJxPlmSobIeyBJ/IVmk/rzeisIeSSpntyGW5CVw3B2ZLviOXI2h6yTRRQQ3TM97Pwfwn3W0n5OVXzEwndSntyRqfhWIO8lw3uo0M0hVJWnAVwA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ai/VPV1F; 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="ai/VPV1F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99516C4CEC4; Tue, 24 Sep 2024 11:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727176070; bh=8G37jGGd8Ye5q1WU19cVMSSjIr5L8SNGnVOyyv3/R/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ai/VPV1FV4GsnErA50+ujCLvLxu7HoCY5+AqH0WB8HuOLaqLjWfOYeDCWGlcUyZGu n19FbAnqbksPIDp5QDB5UGet0rX9OcbR/x89pLF0F74A6rYHDGHUjPQsX9DbOBJwrF 7ySR7kH/V2CBBcWOSJyilvQaM6Wd2tUzI56lxdHqT9t2IA8Ti0XzbNGHLvcpb+p9RM fnhn7vK/hhEEQnSU7kn8kifQGjWjkfm6Z5osZdyb+CLt4ucvFXct/5KJIh57MTJykW Ny+bBzczqqh9/fL6OBnAv14WnFRdUCvgsh0WdODJRG+VnezlhSUsWc/t5NBrIowQcP 7ht5kw5jrpRTA== From: Jiri Olsa To: 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 , Ihor Solodrai Subject: [PATCH bpf-next 2/2] selftests/bpf: Bail out quickly from failing consumer test Date: Tue, 24 Sep 2024 13:07:31 +0200 Message-ID: <20240924110731.2644249-2-jolsa@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240924110731.2644249-1-jolsa@kernel.org> References: <20240924110731.2644249-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Let's bail out from consumer test after we hit first fail, so we don't pollute the log with many instances with possibly the same error. Signed-off-by: Jiri Olsa --- .../selftests/bpf/prog_tests/uprobe_multi_test.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c index c1ac813ff9ba..2c39902b8a09 100644 --- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c @@ -836,10 +836,10 @@ uprobe_consumer_test(struct uprobe_multi_consumers *skel, return 0; } -static void consumer_test(struct uprobe_multi_consumers *skel, - unsigned long before, unsigned long after) +static int consumer_test(struct uprobe_multi_consumers *skel, + unsigned long before, unsigned long after) { - int err, idx; + int err, idx, ret = -1; printf("consumer_test before %lu after %lu\n", before, after); @@ -881,13 +881,17 @@ static void consumer_test(struct uprobe_multi_consumers *skel, fmt = "idx 2/3: uretprobe"; } - ASSERT_EQ(skel->bss->uprobe_result[idx], val, fmt); + if (!ASSERT_EQ(skel->bss->uprobe_result[idx], val, fmt)) + goto cleanup; skel->bss->uprobe_result[idx] = 0; } + ret = 0; + cleanup: for (idx = 0; idx < 4; idx++) uprobe_detach(skel, idx); + return ret; } static void test_consumers(void) @@ -939,9 +943,11 @@ static void test_consumers(void) for (before = 0; before < 16; before++) { for (after = 0; after < 16; after++) - consumer_test(skel, before, after); + if (consumer_test(skel, before, after)) + goto out; } +out: uprobe_multi_consumers__destroy(skel); }