bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>
Cc: Ihor Solodrai <ihor.solodrai@pm.me>,
	sched-ext@meta.com, kernel-team@meta.com,
	linux-kernel@vger.kernel.org, bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH sched_ext/for-6.14-fixes] sched_ext: selftests/dsp_local_on: Fix sporadic failures
Date: Sat, 25 Jan 2025 05:54:23 +0100	[thread overview]
Message-ID: <Z5Ruf3o2f4sC0J5N@gpd3> (raw)
In-Reply-To: <Z5QNhsWw0P1iPd2q@slm.duckdns.org>

On Fri, Jan 24, 2025 at 12:00:38PM -1000, Tejun Heo wrote:
> From e9fe182772dcb2630964724fd93e9c90b68ea0fd Mon Sep 17 00:00:00 2001
> From: Tejun Heo <tj@kernel.org>
> Date: Fri, 24 Jan 2025 10:48:25 -1000
> 
> dsp_local_on has several incorrect assumptions, one of which is that
> p->nr_cpus_allowed always tracks p->cpus_ptr. This is not true when a task
> is scheduled out while migration is disabled - p->cpus_ptr is temporarily
> overridden to the previous CPU while p->nr_cpus_allowed remains unchanged.
> 
> This led to sporadic test faliures when dsp_local_on_dispatch() tries to put
> a migration disabled task to a different CPU. Fix it by keeping the previous
> CPU when migration is disabled.
> 
> There are SCX schedulers that make use of p->nr_cpus_allowed. They should
> also implement explicit handling for p->migration_disabled.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Reported-by: Ihor Solodrai <ihor.solodrai@pm.me>
> Cc: Andrea Righi <arighi@nvidia.com>
> Cc: Changwoo Min <changwoo@igalia.com>
> ---
> Applying to sched_ext/for-6.14-fixes. Thanks.
> 
>  tools/testing/selftests/sched_ext/dsp_local_on.bpf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c b/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
> index fbda6bf54671..758b479bd1ee 100644
> --- a/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
> +++ b/tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
> @@ -43,7 +43,7 @@ void BPF_STRUCT_OPS(dsp_local_on_dispatch, s32 cpu, struct task_struct *prev)
>  	if (!p)
>  		return;
>  
> -	if (p->nr_cpus_allowed == nr_cpus)
> +	if (p->nr_cpus_allowed == nr_cpus && !p->migration_disabled)

This doesn't work with !CONFIG_SMP, maybe we can introduce a helper like:

static bool is_migration_disabled(const struct task_struct *p)
{
	if (bpf_core_field_exists(p->migration_disabled))
		return p->migration_disabled;
	return false;
}

>  		target = bpf_get_prandom_u32() % nr_cpus;
>  	else
>  		target = scx_bpf_task_cpu(p);
> -- 
> 2.48.1
> 

Thanks,
-Andrea

  reply	other threads:[~2025-01-25  4:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20241209152924.4508-1-void@manifault.com>
2024-12-10 20:52 ` [PATCH] scx: Fix maximal BPF selftest prog Ihor Solodrai
2024-12-11 21:01   ` [PATCH sched_ext/for-6.13-fixes] sched_ext: Fix invalid irq restore in scx_ops_bypass() Tejun Heo
2024-12-11 21:03     ` Tejun Heo
2024-12-12 18:12     ` Ihor Solodrai
2024-12-17 23:44       ` Ihor Solodrai
2024-12-18 18:34         ` Tejun Heo
2024-12-19 22:51           ` Ihor Solodrai
2024-12-20 19:26             ` Ihor Solodrai
2024-12-25  0:09             ` [PATCH sched_ext/for-6.13-fixes] sched_ext: Fix dsq_local_on selftest Tejun Heo
2024-12-25  0:10               ` Tejun Heo
2025-01-15 23:50               ` Ihor Solodrai
2025-01-22  1:40                 ` Tejun Heo
2025-01-22 19:10                   ` Ihor Solodrai
2025-01-23  9:40                     ` Andrea Righi
2025-01-23 16:57                       ` Tejun Heo
2025-01-23 18:45                         ` Andrea Righi
2025-01-23 22:26                           ` Andrea Righi
2025-01-24 22:00                             ` [PATCH sched_ext/for-6.14-fixes] sched_ext: selftests/dsp_local_on: Fix sporadic failures Tejun Heo
2025-01-25  4:54                               ` Andrea Righi [this message]
2025-01-27 18:45                                 ` Tejun Heo

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=Z5Ruf3o2f4sC0J5N@gpd3 \
    --to=arighi@nvidia.com \
    --cc=bpf@vger.kernel.org \
    --cc=ihor.solodrai@pm.me \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@meta.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).