mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Andrea Righi <arighi@nvidia.com>
Cc: David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	Christian Loehle <christian.loehle@arm.com>,
	sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH sched_ext/for-6.18] sched_ext: Acquire task reference in scx_bpf_cpu_curr()
Date: Tue, 9 Sep 2025 10:01:16 -1000	[thread overview]
Message-ID: <aMCHjFwwjqvKsZBg@slm.duckdns.org> (raw)
In-Reply-To: <20250909195709.92669-1-arighi@nvidia.com>

Hello, Andrea.

On Tue, Sep 09, 2025 at 09:57:09PM +0200, Andrea Righi wrote:
> scx_bpf_cpu_curr() has been introduced to retrieve the current task of a
> given runqueue, allowing schedulers to interact with that task.
> 
> The kfunc assumes that it is always called in an RCU context, but this
> is not always guaranteed and some BPF schedulers can trigger the
> following warning:
> 
>   WARNING: suspicious RCU usage
>   sched_ext: BPF scheduler "cosmos_1.0.2_gd0e71ca_x86_64_unknown_linux_gnu_debug" enabled
>   6.17.0-rc1 #1-NixOS Not tainted
>   -----------------------------
>   kernel/sched/ext.c:6415 suspicious rcu_dereference_check() usage!
> 
> The correct behavior is to acquire a reference to the returned task, so
> the scheduler can safely access it and then release it with
> bpf_task_release().
> 
> Update the kfunc and the corresponding compatibility helper to implement
> reference acquisition and prevent potential RCU warnings.

I think KF_RCU likely fits better for peeking kernel data structures than
having to acquire/release them. Can you post the full backtrace? Is it being
called from a sleepable bpf prog? Or is it that we just need to expand the
rcu check scope to cover regular rcu, bh and sched? And, everything aside,
if KF_RCU, should we be tripping on rcu_dereference() in the first place?

Thanks.

-- 
tejun

  reply	other threads:[~2025-09-09 20:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09 19:57 Andrea Righi
2025-09-09 20:01 ` Tejun Heo [this message]
2025-09-09 20:45   ` Andrea Righi
2025-09-18 15:48     ` Christian Loehle
2025-09-18 16:06       ` Andrea Righi
2025-09-18 16:46         ` Christian Loehle

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=aMCHjFwwjqvKsZBg@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=christian.loehle@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --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

all inboxes | Powered by JetHome®