All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Christian Loehle <christian.loehle@arm.com>
Cc: Ryan Newton <rrnewton@gmail.com>,
	linux-kernel@vger.kernel.org, sched-ext@lists.linux.dev,
	tj@kernel.org, newton@meta.com
Subject: Re: [PATCH v4 1/2] sched_ext: Add lockless peek operation for DSQs
Date: Wed, 15 Oct 2025 18:02:31 +0200	[thread overview]
Message-ID: <aO_Fl0Zpeh9pvMFB@gpd4> (raw)
In-Reply-To: <a469d0fb-62f2-4286-901f-b7a634d3e0c4@arm.com>

On Wed, Oct 15, 2025 at 10:46:52AM +0100, Christian Loehle wrote:
> On 10/15/25 02:57, Ryan Newton wrote:
...
> > --- a/tools/sched_ext/include/scx/compat.bpf.h
> > +++ b/tools/sched_ext/include/scx/compat.bpf.h
> > @@ -26,6 +26,24 @@ int bpf_cpumask_populate(struct cpumask *dst, void *src, size_t src__sz) __ksym
> >  	(bpf_ksym_exists(bpf_cpumask_populate) ?			\
> >  	 (bpf_cpumask_populate(cpumask, src, size__sz)) : -EOPNOTSUPP)
> >  
> > +/*
> > + * v6.19: Introduce lockless peek API for user DSQs.
> > + *
> > + * Preserve the following macro until v6.21.
> > + */
> > +static inline struct task_struct *__COMPAT_scx_bpf_dsq_peek(u64 dsq_id)
> > +{
> > +	struct task_struct *p = NULL;
> > +	struct bpf_iter_scx_dsq it;
> > +
> > +	if (bpf_ksym_exists(scx_bpf_dsq_peek))
> > +		return scx_bpf_dsq_peek(dsq_id);
> > +	if (!bpf_iter_scx_dsq_new(&it, dsq_id, 0))
> > +		p = bpf_iter_scx_dsq_next(&it);
> > +	bpf_iter_scx_dsq_destroy(&it);
> > +	return p;
> > +}
> > +
> I think there's an argument to be made for this to just return NULL on
> !bpf_ksym_exists(scx_bpf_dsq_peek), the caller needs to handle that anyway
> and at least it's guaranteed to be lockfree then?
> I don't have a strong leaning either way, probably is fine if documented.

If we return NULL, the caller cannot tell whether the DSQ is empty or the
kfunc is missing. Honestly, I don't think being lockless is a strict
requirement from a scheduler's perspective, but if there's a case where it
matters, we can add a separate helper, i.e., scx_bpf_dsq_peek_nolock(),
that explicitly returns NULL when scx_bpf_dsq_peek() is unavailable.

Thanks,
-Andrea

  parent reply	other threads:[~2025-10-15 16:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15  1:57 [PATCH v4 0/2] sched_ext: lockless peek operation for DSQs Ryan Newton
2025-10-15  1:57 ` [PATCH v4 1/2] sched_ext: Add " Ryan Newton
2025-10-15  9:46   ` Christian Loehle
2025-10-15 14:05     ` Ryan Newton
2025-10-15 16:02     ` Andrea Righi [this message]
2025-10-15  1:57 ` [PATCH v4 2/2] sched_ext: Add a selftest for scx_bpf_dsq_peek Ryan Newton
2025-10-15  9:41   ` 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=aO_Fl0Zpeh9pvMFB@gpd4 \
    --to=arighi@nvidia.com \
    --cc=christian.loehle@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=newton@meta.com \
    --cc=rrnewton@gmail.com \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    /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.