From: Andrea Righi <arighi@nvidia.com>
To: Kuba Piecuch <jpiecuch@google.com>
Cc: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>, Ryan Newton <newton@meta.com>,
sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] sched_ext: Take rcu_read_lock() explicitly in sub-cap kfuncs
Date: Tue, 24 Nov 2026 09:02:48 +0100 [thread overview]
Message-ID: <awVEqEZdHReap399@gpd4> (raw)
In-Reply-To: <20261123145927.577162-3-jpiecuch@google.com>
Hi Kuba,
On Mon, Nov 23, 2026 at 03:00:38PM +0000, Kuba Piecuch wrote:
> scx_bpf_sub_grant(), scx_bpf_sub_revoke() and scx_bpf_sub_caps() look up
> scheds via scx_prog_sched() and scx_find_sub_sched(), read the cid
> tables and, in revoke, walk ->children while holding only
> guard(irqsave)(). They can be called without rcu_read_lock(), e.g. from
> sleepable ops or bpf_timer callbacks.
>
> This works only because IRQs are disabled and none of the RCU checks on
> these paths require rcu_read_lock_held(). A plain rcu_dereference()
> added to these paths would trigger a lockdep splat when called without
> rcu_read_lock().
>
> Take guard(rcu)() as scx_bpf_sub_dispatch() and scx_bpf_sub_kill_bstr()
> already do. No functional change.
I'd drop this patch. The IRQ-disabled region already provides the
required lifetime protection and the existing checks recognize it.
If a future change introduces another dereference here, it should use
the check appropriate to that protection, such as rcu_dereference_all().
I think we don't want to introduce additional RCU read-side bookkeeping
on every call to accommodate that possibility.
Thanks,
-Andrea
>
> Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
> ---
> kernel/sched/ext/sub.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
> index d2a20114eaa2..45aaa333f9c2 100644
> --- a/kernel/sched/ext/sub.c
> +++ b/kernel/sched/ext/sub.c
> @@ -2870,6 +2870,7 @@ __bpf_kfunc s32 scx_bpf_sub_grant(u64 cgroup_id, u64 caps,
> LIST_HEAD(to_deliver);
> s32 si, ret;
>
> + guard(rcu)();
> guard(irqsave)();
>
> ret = sub_cap_preamble(cgroup_id, caps, aux, &parent, &child);
> @@ -2999,6 +3000,7 @@ __bpf_kfunc void scx_bpf_sub_revoke(u64 cgroup_id, u64 caps,
> LIST_HEAD(to_deliver);
> s32 si, ret;
>
> + guard(rcu)();
> guard(irqsave)();
>
> if (sub_cap_preamble(cgroup_id, caps, aux, &parent, &child))
> @@ -3092,6 +3094,7 @@ __bpf_kfunc s32 scx_bpf_sub_caps(u64 cgroup_id, u64 caps, struct scx_cmask *out_
> struct scx_pshard **pshard;
> s32 si, ret;
>
> + guard(rcu)();
> guard(irqsave)();
>
> sch = scx_prog_sched(aux);
> --
> 2.56.1.750.gf70dc682cf-goog
>
>
prev parent reply other threads:[~2026-11-24 8:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:00 [PATCHSET sched_ext/for-7.4-fixes] sched_ext: Fix and tighten RCU usage in kfuncs Kuba Piecuch
2026-11-23 15:00 ` [PATCH 1/2] sched_ext: Fix suspicious RCU usage in KF_RCU_PROTECTED kfuncs Kuba Piecuch
2026-11-24 8:00 ` Andrea Righi
2026-11-23 15:00 ` [PATCH 2/2] sched_ext: Take rcu_read_lock() explicitly in sub-cap kfuncs Kuba Piecuch
2026-11-24 8:02 ` Andrea Righi [this message]
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=awVEqEZdHReap399@gpd4 \
--to=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=jpiecuch@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=newton@meta.com \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--cc=void@manifault.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox