From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Mike Bazov" <mikeba@sentinelone.com>
Cc: "JP Kobryn" <jp.kobryn@linux.dev>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
"Shuah Khan" <shuah@kernel.org>, <bpf@vger.kernel.org>,
<linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [EXT.MSG] Re: [PATCH RFC bpf-next 0/2] bpf: Do not let preemption cause false recursion drops in trampoline progs
Date: Thu, 05 Nov 2026 05:14:16 +0000 [thread overview]
Message-ID: <DMN0RC27TJRM.3KUSPS9QTBV4G@gmail.com> (raw)
In-Reply-To: <CAPnbwjpQBR-KHwOMG2bo1uhdp22ZW_O5sUj3=vjazVu=Rdnb7A@mail.gmail.com>
On Thu Nov 5, 2026 at 12:12 AM UTC, Mike Bazov wrote:
> On Wed, Nov 04, 2026 at 02:20 AM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> > Add bpf_preempt_disable().
> > Your test forces the preemption in the middle of the prog.
> > Explicit bpf_preempt_disable() will fix it.
>
> I tried it, and with the whole prog body wrapped in bpf_preempt_disable() /
> bpf_preempt_enable(), Task B is still skipped in every round (on a 7.0
> kernel, 20 rounds, fentry and fexit: runs_b=0, recursion_misses=20).
>
> perf record -e sched:sched_switch -g shows where Task A is switched out
> now, 20 of 20 (Task A, SCHED_OTHER, preempted by Task B, SCHED_FIFO):
>
> __schedule+0x48f
> preempt_schedule+0x59
> preempt_schedule_thunk+0x16
> bpf_preempt_enable+0x1c
> bpf_trampoline_6442539626+0x105
> bpf_prog_7dd04eadc26e277d_on_fentry+0x11
> bpf_trampoline_6442539626+0x192
> __set_task_comm+0x5
>
> That is still inside the prog, while prog->active is held.
Right. Pls hack bpf_preempt_enable() to use preempt_enable_no_resched().
I think recursion misses may disappear or become single digit.
If it's good enough we can quickly add bpf_preempt_enable_no_resched() kfunc.
Also try NO_HRTICK in /sys/kernel/debug/sched/features.
That may be decent workaround for now.
> > What are run_cnt and recursion_misses of your progs on inet_sendmsg()
> > and inet_recvmsg() in production?
>
> We hit this while testing new distros with 7.0 kernels, so we don't
> have fleet numbers for these counters yet. For our inet_sendmsg/recvmsg
> progs, in testing: fentry/fexit on inet[6]_{send,recv}msg, Ubuntu 24.04
> with its stock 7.0 HWE kernel (7.0.0-38-generic, default lazy
> preemption, 4 vCPUs), behind nginx -> gunicorn -> redis, with wrk from
> another machine (128 keep-alive connections, ~1.07M requests over 10
> minutes, ~62% CPU):
>
> run_cnt 38040015, recursion_misses 4063
hmm. you really cannot tolerate that small drop? it's tracing at the end.
It would be a different story if such drops were on lsm hook.
let's try to think how per-task counter would work.
I'm guessing 128 connections is 128 threads servicing them,
so 200 cpus will be hammering the same per-task counter which will
cause real perf loss.
Gotta do better than per-task.
Also it needs to be per-task + per-prog. How will it look like?
next prev parent reply other threads:[~2026-11-05 5:14 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 11:02 [PATCH RFC bpf-next 0/2] bpf: Do not let preemption cause false recursion drops in trampoline progs Mike Bazov via B4 Relay
2026-10-25 11:02 ` Mike Bazov
2026-10-25 11:02 ` [PATCH RFC bpf-next 1/2] bpf: Keep recursion-checked trampoline programs non-preemptible on !PREEMPT_RT Mike Bazov via B4 Relay
2026-10-25 11:02 ` Mike Bazov
2026-10-25 11:38 ` sashiko-bot
2026-10-25 11:02 ` [PATCH RFC bpf-next 2/2] selftests/bpf: Add trampoline preemption false-recursion test Mike Bazov via B4 Relay
2026-10-25 11:02 ` Mike Bazov
2026-10-30 22:22 ` [PATCH RFC bpf-next 0/2] bpf: Do not let preemption cause false recursion drops in trampoline progs Alexei Starovoitov
2026-11-02 23:24 ` [EXT.MSG] " Mike Bazov
2026-11-03 1:49 ` Alexei Starovoitov
2026-11-03 21:28 ` Mike Bazov
2026-11-04 2:20 ` Alexei Starovoitov
2026-11-05 1:12 ` Martin Kelly
2026-11-05 5:18 ` Alexei Starovoitov
2026-11-05 8:53 ` Peter Zijlstra
2026-11-05 20:16 ` Martin Kelly
2026-11-05 12:26 ` Peter Zijlstra
2026-11-05 20:44 ` Martin Kelly
2026-11-03 23:46 ` JP Kobryn
2026-11-04 2:21 ` Alexei Starovoitov
2026-11-05 0:12 ` [EXT.MSG] " Mike Bazov
2026-11-05 5:14 ` Alexei Starovoitov [this message]
2026-11-05 21:10 ` Martin Kelly
2026-11-05 23:35 ` Mike Bazov
2026-11-06 22:08 ` Andrii Nakryiko
2026-11-07 21:32 ` Mike Bazov
2026-11-10 0:12 ` JP Kobryn (CrowdStrike)
2026-11-10 20:43 ` Mike Bazov
2026-11-11 2:58 ` JP Kobryn (CrowdStrike)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DMN0RC27TJRM.3KUSPS9QTBV4G@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jp.kobryn@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mikeba@sentinelone.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.