public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Changwoo Min <changwoo@igalia.com>
Cc: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] sched_ext: idle: Introduce scx_bpf_select_cpu_pref()
Date: Fri, 7 Mar 2025 07:35:22 +0100	[thread overview]
Message-ID: <Z8qTqgrMmFeAD4yJ@gpd3> (raw)
In-Reply-To: <e3d578fe-5be5-4db7-8621-798468faee03@igalia.com>

Hi Changwoo,

On Fri, Mar 07, 2025 at 12:15:04PM +0900, Changwoo Min wrote:
...
> > +__bpf_kfunc s32 scx_bpf_select_cpu_pref(struct task_struct *p,
> > +					const struct cpumask *preferred_cpus,
> > +					s32 prev_cpu, u64 wake_flags, u64 flags)
> > +{
> > +#ifdef CONFIG_SMP
> > +	struct cpumask *preferred = NULL;
> > +	bool is_idle = false;
> > +#endif
> > +
> > +	if (!ops_cpu_valid(prev_cpu, NULL))
> > +		return -EINVAL;
> > +
> > +	if (!check_builtin_idle_enabled())
> > +		return -EBUSY;
> > +
> > +	if (!scx_kf_allowed(SCX_KF_SELECT_CPU))
> > +		return -EPERM;
> > +
> > +#ifdef CONFIG_SMP
> > +	preempt_disable();
> > +
> > +	/*
> > +	 * As an optimization, do not update the local idle mask when
> > +	 * p->cpus_ptr is passed directly in @preferred_cpus.
> > +	 */
> > +	if (preferred_cpus != p->cpus_ptr) {
> > +		preferred = this_cpu_cpumask_var_ptr(local_idle_cpumask);
> > +		if (!cpumask_and(preferred, p->cpus_ptr, preferred_cpus))
> > +			preferred = NULL;
> 
> I think it would be better to move cpumask_and() inside
> scx_select_cpu_dfl() because scx_select_cpu_dfl() assumes that
> anyway. That will make the code easier to read and avoid
> potential mistakes when extending scx_select_cpu_dfl() in the
> future.

I agree, will do this in the next version.

Thanks!
-Andrea

  reply	other threads:[~2025-03-07  6:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06 18:18 [PATCHSET sched_ext/for-6.15] sched_ext: Enhance built-in idle selection with preferred CPUs Andrea Righi
2025-03-06 18:18 ` [PATCH 1/4] sched_ext: idle: Honor idle flags in the built-in idle selection policy Andrea Righi
2025-03-06 18:18 ` [PATCH 2/4] sched_ext: idle: Introduce the concept of preferred CPUs Andrea Righi
2025-03-06 18:18 ` [PATCH 3/4] sched_ext: idle: Introduce scx_bpf_select_cpu_pref() Andrea Righi
2025-03-07  3:15   ` Changwoo Min
2025-03-07  6:35     ` Andrea Righi [this message]
2025-03-06 18:18 ` [PATCH 4/4] selftests/sched_ext: Add test for scx_bpf_select_cpu_pref() Andrea Righi
2025-03-06 18:34 ` [PATCHSET sched_ext/for-6.15] sched_ext: Enhance built-in idle selection with preferred CPUs Tejun Heo
2025-03-06 18:54   ` Andrea Righi
2025-03-06 18:58     ` Tejun Heo
2025-03-06 19:02       ` Andrea Righi
2025-03-07  3:14 ` Changwoo Min

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=Z8qTqgrMmFeAD4yJ@gpd3 \
    --to=arighi@nvidia.com \
    --cc=bpf@vger.kernel.org \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --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