* [PATCH bpf-next] selftests/bpf: Fix htab_update/reenter_update selftest failure
@ 2025-11-06 5:26 Saket Kumar Bhaskar
2025-11-06 17:15 ` Alexei Starovoitov
0 siblings, 1 reply; 6+ messages in thread
From: Saket Kumar Bhaskar @ 2025-11-06 5:26 UTC (permalink / raw)
To: bpf, linux-kselftest, linux-kernel
Cc: hbathini, sachinpb, venkat88, andrii, eddyz87, ast, daniel,
martin.lau, song, yonghong.song, john.fastabend, kpsingh, sdf,
haoluo, jolsa, shuah
Since commit 31158ad02ddb ("rqspinlock: Add deadlock detection and recovery")
the updated path on re-entrancy now reports deadlock via
-EDEADLK instead of the previous -EBUSY.
The selftest is updated to align with expected errno
with the kernel’s current behavior.
Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
---
tools/testing/selftests/bpf/prog_tests/htab_update.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/htab_update.c b/tools/testing/selftests/bpf/prog_tests/htab_update.c
index 2bc85f4814f4..98d52bb1446f 100644
--- a/tools/testing/selftests/bpf/prog_tests/htab_update.c
+++ b/tools/testing/selftests/bpf/prog_tests/htab_update.c
@@ -40,7 +40,7 @@ static void test_reenter_update(void)
if (!ASSERT_OK(err, "add element"))
goto out;
- ASSERT_EQ(skel->bss->update_err, -EBUSY, "no reentrancy");
+ ASSERT_EQ(skel->bss->update_err, -EDEADLK, "no reentrancy");
out:
htab_update__destroy(skel);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix htab_update/reenter_update selftest failure
2025-11-06 5:26 [PATCH bpf-next] selftests/bpf: Fix htab_update/reenter_update selftest failure Saket Kumar Bhaskar
@ 2025-11-06 17:15 ` Alexei Starovoitov
2025-11-11 14:32 ` Saket Kumar Bhaskar
0 siblings, 1 reply; 6+ messages in thread
From: Alexei Starovoitov @ 2025-11-06 17:15 UTC (permalink / raw)
To: Saket Kumar Bhaskar
Cc: bpf, open list:KERNEL SELFTEST FRAMEWORK, LKML, Hari Bathini,
sachinpb, Venkat Rao Bagalkote, Andrii Nakryiko, Eduard,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, Shuah Khan
On Wed, Nov 5, 2025 at 9:26 PM Saket Kumar Bhaskar <skb99@linux.ibm.com> wrote:
>
> Since commit 31158ad02ddb ("rqspinlock: Add deadlock detection and recovery")
> the updated path on re-entrancy now reports deadlock via
> -EDEADLK instead of the previous -EBUSY.
>
> The selftest is updated to align with expected errno
> with the kernel’s current behavior.
>
> Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
> ---
> tools/testing/selftests/bpf/prog_tests/htab_update.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/htab_update.c b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> index 2bc85f4814f4..98d52bb1446f 100644
> --- a/tools/testing/selftests/bpf/prog_tests/htab_update.c
> +++ b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> @@ -40,7 +40,7 @@ static void test_reenter_update(void)
> if (!ASSERT_OK(err, "add element"))
> goto out;
>
> - ASSERT_EQ(skel->bss->update_err, -EBUSY, "no reentrancy");
> + ASSERT_EQ(skel->bss->update_err, -EDEADLK, "no reentrancy");
Makes sense, but looks like the test was broken for quite some time.
It fails with
/* lookup_elem_raw() may be inlined and find_kernel_btf_id()
will return -ESRCH */
bpf_program__set_autoload(skel->progs.lookup_elem_raw, true);
err = htab_update__load(skel);
if (!ASSERT_TRUE(!err || err == -ESRCH, "htab_update__load") || err)
before reaching deadlk check.
Pls make it more robust.
__pcpu_freelist_pop() might be better alternative then lookup_elem_raw().
pw-bot: cr
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix htab_update/reenter_update selftest failure
2025-11-06 17:15 ` Alexei Starovoitov
@ 2025-11-11 14:32 ` Saket Kumar Bhaskar
2025-11-11 18:35 ` Alexei Starovoitov
0 siblings, 1 reply; 6+ messages in thread
From: Saket Kumar Bhaskar @ 2025-11-11 14:32 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: bpf, open list:KERNEL SELFTEST FRAMEWORK, LKML, Hari Bathini,
sachinpb, Venkat Rao Bagalkote, Andrii Nakryiko, Eduard,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, Shuah Khan
On Thu, Nov 06, 2025 at 09:15:39AM -0800, Alexei Starovoitov wrote:
> On Wed, Nov 5, 2025 at 9:26 PM Saket Kumar Bhaskar <skb99@linux.ibm.com> wrote:
> >
> > Since commit 31158ad02ddb ("rqspinlock: Add deadlock detection and recovery")
> > the updated path on re-entrancy now reports deadlock via
> > -EDEADLK instead of the previous -EBUSY.
> >
> > The selftest is updated to align with expected errno
> > with the kernel’s current behavior.
> >
> > Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
> > ---
> > tools/testing/selftests/bpf/prog_tests/htab_update.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/htab_update.c b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > index 2bc85f4814f4..98d52bb1446f 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > @@ -40,7 +40,7 @@ static void test_reenter_update(void)
> > if (!ASSERT_OK(err, "add element"))
> > goto out;
> >
> > - ASSERT_EQ(skel->bss->update_err, -EBUSY, "no reentrancy");
> > + ASSERT_EQ(skel->bss->update_err, -EDEADLK, "no reentrancy");
>
> Makes sense, but looks like the test was broken for quite some time.
> It fails with
> /* lookup_elem_raw() may be inlined and find_kernel_btf_id()
> will return -ESRCH */
> bpf_program__set_autoload(skel->progs.lookup_elem_raw, true);
> err = htab_update__load(skel);
> if (!ASSERT_TRUE(!err || err == -ESRCH, "htab_update__load") || err)
>
> before reaching deadlk check.
> Pls make it more robust.
> __pcpu_freelist_pop() might be better alternative then lookup_elem_raw().
>
> pw-bot: cr
Hi Alexei,
I tried for __pcpu_freelist_pop, looks like it is not good candidate to
attach fentry for, as it is non traceable:
trace_kprobe: Could not probe notrace function __pcpu_freelist_pop
I wasn't able to find any other function for this.
Thanks
Saket
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix htab_update/reenter_update selftest failure
2025-11-11 14:32 ` Saket Kumar Bhaskar
@ 2025-11-11 18:35 ` Alexei Starovoitov
2025-11-12 15:08 ` Saket Kumar Bhaskar
0 siblings, 1 reply; 6+ messages in thread
From: Alexei Starovoitov @ 2025-11-11 18:35 UTC (permalink / raw)
To: Saket Kumar Bhaskar
Cc: bpf, open list:KERNEL SELFTEST FRAMEWORK, LKML, Hari Bathini,
sachinpb, Venkat Rao Bagalkote, Andrii Nakryiko, Eduard,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, Shuah Khan
On Tue, Nov 11, 2025 at 6:33 AM Saket Kumar Bhaskar <skb99@linux.ibm.com> wrote:
>
> On Thu, Nov 06, 2025 at 09:15:39AM -0800, Alexei Starovoitov wrote:
> > On Wed, Nov 5, 2025 at 9:26 PM Saket Kumar Bhaskar <skb99@linux.ibm.com> wrote:
> > >
> > > Since commit 31158ad02ddb ("rqspinlock: Add deadlock detection and recovery")
> > > the updated path on re-entrancy now reports deadlock via
> > > -EDEADLK instead of the previous -EBUSY.
> > >
> > > The selftest is updated to align with expected errno
> > > with the kernel’s current behavior.
> > >
> > > Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
> > > ---
> > > tools/testing/selftests/bpf/prog_tests/htab_update.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/htab_update.c b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > > index 2bc85f4814f4..98d52bb1446f 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > > @@ -40,7 +40,7 @@ static void test_reenter_update(void)
> > > if (!ASSERT_OK(err, "add element"))
> > > goto out;
> > >
> > > - ASSERT_EQ(skel->bss->update_err, -EBUSY, "no reentrancy");
> > > + ASSERT_EQ(skel->bss->update_err, -EDEADLK, "no reentrancy");
> >
> > Makes sense, but looks like the test was broken for quite some time.
> > It fails with
> > /* lookup_elem_raw() may be inlined and find_kernel_btf_id()
> > will return -ESRCH */
> > bpf_program__set_autoload(skel->progs.lookup_elem_raw, true);
> > err = htab_update__load(skel);
> > if (!ASSERT_TRUE(!err || err == -ESRCH, "htab_update__load") || err)
> >
> > before reaching deadlk check.
> > Pls make it more robust.
> > __pcpu_freelist_pop() might be better alternative then lookup_elem_raw().
> >
> > pw-bot: cr
>
> Hi Alexei,
>
> I tried for __pcpu_freelist_pop, looks like it is not good candidate to
> attach fentry for, as it is non traceable:
>
> trace_kprobe: Could not probe notrace function __pcpu_freelist_pop
>
> I wasn't able to find any other function for this.
alloc_htab_elem() is not inlined for me.
bpf_obj_free_fields() would be another option.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix htab_update/reenter_update selftest failure
2025-11-11 18:35 ` Alexei Starovoitov
@ 2025-11-12 15:08 ` Saket Kumar Bhaskar
2025-11-12 15:40 ` Alexei Starovoitov
0 siblings, 1 reply; 6+ messages in thread
From: Saket Kumar Bhaskar @ 2025-11-12 15:08 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: bpf, open list:KERNEL SELFTEST FRAMEWORK, LKML, Hari Bathini,
sachinpb, Venkat Rao Bagalkote, Andrii Nakryiko, Eduard,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, Shuah Khan
On Tue, Nov 11, 2025 at 10:35:39AM -0800, Alexei Starovoitov wrote:
> On Tue, Nov 11, 2025 at 6:33 AM Saket Kumar Bhaskar <skb99@linux.ibm.com> wrote:
> >
> > On Thu, Nov 06, 2025 at 09:15:39AM -0800, Alexei Starovoitov wrote:
> > > On Wed, Nov 5, 2025 at 9:26 PM Saket Kumar Bhaskar <skb99@linux.ibm.com> wrote:
> > > >
> > > > Since commit 31158ad02ddb ("rqspinlock: Add deadlock detection and recovery")
> > > > the updated path on re-entrancy now reports deadlock via
> > > > -EDEADLK instead of the previous -EBUSY.
> > > >
> > > > The selftest is updated to align with expected errno
> > > > with the kernel’s current behavior.
> > > >
> > > > Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
> > > > ---
> > > > tools/testing/selftests/bpf/prog_tests/htab_update.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/tools/testing/selftests/bpf/prog_tests/htab_update.c b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > > > index 2bc85f4814f4..98d52bb1446f 100644
> > > > --- a/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > > > +++ b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > > > @@ -40,7 +40,7 @@ static void test_reenter_update(void)
> > > > if (!ASSERT_OK(err, "add element"))
> > > > goto out;
> > > >
> > > > - ASSERT_EQ(skel->bss->update_err, -EBUSY, "no reentrancy");
> > > > + ASSERT_EQ(skel->bss->update_err, -EDEADLK, "no reentrancy");
> > >
> > > Makes sense, but looks like the test was broken for quite some time.
> > > It fails with
> > > /* lookup_elem_raw() may be inlined and find_kernel_btf_id()
> > > will return -ESRCH */
> > > bpf_program__set_autoload(skel->progs.lookup_elem_raw, true);
> > > err = htab_update__load(skel);
> > > if (!ASSERT_TRUE(!err || err == -ESRCH, "htab_update__load") || err)
> > >
> > > before reaching deadlk check.
> > > Pls make it more robust.
> > > __pcpu_freelist_pop() might be better alternative then lookup_elem_raw().
> > >
> > > pw-bot: cr
> >
> > Hi Alexei,
> >
> > I tried for __pcpu_freelist_pop, looks like it is not good candidate to
> > attach fentry for, as it is non traceable:
> >
> > trace_kprobe: Could not probe notrace function __pcpu_freelist_pop
> >
> > I wasn't able to find any other function for this.
>
> alloc_htab_elem() is not inlined for me.
> bpf_obj_free_fields() would be another option.
Since alloc_htab_elem() is a static function, wouldn’t its
inlining behavior be compiler-dependent?
static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
void *value, u32 key_size, u32 hash,
bool percpu, bool onallcpus,
struct htab_elem *old_elem)
When the fentry program is instead attached to bpf_obj_free_fields(),
the bpf_map_update_elem() call returns 0 rather than -EDEADLK,
because bpf_obj_free_fields() is not invoked in the bpf_map_update_elem()
re-entrancy path:
./test_progs -t htab_update/reenter_update -v
bpf_testmod.ko is already unloaded.
Loading bpf_testmod.ko...
Successfully loaded bpf_testmod.ko.
test_reenter_update:PASS:htab_update__open 0 nsec
test_reenter_update:PASS:htab_update__load 0 nsec
test_reenter_update:PASS:htab_update__attach 0 nsec
test_reenter_update:PASS:add element 0 nsec
test_reenter_update:FAIL:no reentrancy unexpected no reentrancy: actual 0 != expected -35
#143/1 htab_update/reenter_update:FAIL
#143 htab_update:FAIL
Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
Successfully unloaded bpf_testmod.ko.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix htab_update/reenter_update selftest failure
2025-11-12 15:08 ` Saket Kumar Bhaskar
@ 2025-11-12 15:40 ` Alexei Starovoitov
0 siblings, 0 replies; 6+ messages in thread
From: Alexei Starovoitov @ 2025-11-12 15:40 UTC (permalink / raw)
To: Saket Kumar Bhaskar
Cc: bpf, open list:KERNEL SELFTEST FRAMEWORK, LKML, Hari Bathini,
sachinpb, Venkat Rao Bagalkote, Andrii Nakryiko, Eduard,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, Shuah Khan
On Wed, Nov 12, 2025 at 7:08 AM Saket Kumar Bhaskar <skb99@linux.ibm.com> wrote:
>
> On Tue, Nov 11, 2025 at 10:35:39AM -0800, Alexei Starovoitov wrote:
> > On Tue, Nov 11, 2025 at 6:33 AM Saket Kumar Bhaskar <skb99@linux.ibm.com> wrote:
> > >
> > > On Thu, Nov 06, 2025 at 09:15:39AM -0800, Alexei Starovoitov wrote:
> > > > On Wed, Nov 5, 2025 at 9:26 PM Saket Kumar Bhaskar <skb99@linux.ibm.com> wrote:
> > > > >
> > > > > Since commit 31158ad02ddb ("rqspinlock: Add deadlock detection and recovery")
> > > > > the updated path on re-entrancy now reports deadlock via
> > > > > -EDEADLK instead of the previous -EBUSY.
> > > > >
> > > > > The selftest is updated to align with expected errno
> > > > > with the kernel’s current behavior.
> > > > >
> > > > > Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
> > > > > ---
> > > > > tools/testing/selftests/bpf/prog_tests/htab_update.c | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/tools/testing/selftests/bpf/prog_tests/htab_update.c b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > > > > index 2bc85f4814f4..98d52bb1446f 100644
> > > > > --- a/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > > > > +++ b/tools/testing/selftests/bpf/prog_tests/htab_update.c
> > > > > @@ -40,7 +40,7 @@ static void test_reenter_update(void)
> > > > > if (!ASSERT_OK(err, "add element"))
> > > > > goto out;
> > > > >
> > > > > - ASSERT_EQ(skel->bss->update_err, -EBUSY, "no reentrancy");
> > > > > + ASSERT_EQ(skel->bss->update_err, -EDEADLK, "no reentrancy");
> > > >
> > > > Makes sense, but looks like the test was broken for quite some time.
> > > > It fails with
> > > > /* lookup_elem_raw() may be inlined and find_kernel_btf_id()
> > > > will return -ESRCH */
> > > > bpf_program__set_autoload(skel->progs.lookup_elem_raw, true);
> > > > err = htab_update__load(skel);
> > > > if (!ASSERT_TRUE(!err || err == -ESRCH, "htab_update__load") || err)
> > > >
> > > > before reaching deadlk check.
> > > > Pls make it more robust.
> > > > __pcpu_freelist_pop() might be better alternative then lookup_elem_raw().
> > > >
> > > > pw-bot: cr
> > >
> > > Hi Alexei,
> > >
> > > I tried for __pcpu_freelist_pop, looks like it is not good candidate to
> > > attach fentry for, as it is non traceable:
> > >
> > > trace_kprobe: Could not probe notrace function __pcpu_freelist_pop
> > >
> > > I wasn't able to find any other function for this.
> >
> > alloc_htab_elem() is not inlined for me.
> > bpf_obj_free_fields() would be another option.
> Since alloc_htab_elem() is a static function, wouldn’t its
> inlining behavior be compiler-dependent?
of course. Just like lookup_elem_raw(), but alloc is much bigger
and less likely to be inlined.
> static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
> void *value, u32 key_size, u32 hash,
> bool percpu, bool onallcpus,
> struct htab_elem *old_elem)
>
> When the fentry program is instead attached to bpf_obj_free_fields(),
> the bpf_map_update_elem() call returns 0 rather than -EDEADLK,
> because bpf_obj_free_fields() is not invoked in the bpf_map_update_elem()
> re-entrancy path:
Then make it so. Think what you need to do to make
check_and_free_fields() call it.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-11-12 15:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-06 5:26 [PATCH bpf-next] selftests/bpf: Fix htab_update/reenter_update selftest failure Saket Kumar Bhaskar
2025-11-06 17:15 ` Alexei Starovoitov
2025-11-11 14:32 ` Saket Kumar Bhaskar
2025-11-11 18:35 ` Alexei Starovoitov
2025-11-12 15:08 ` Saket Kumar Bhaskar
2025-11-12 15:40 ` Alexei Starovoitov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox