The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Waiman Long <longman@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Valentin Schneider <vschneid@redhat.com>,
	Will Deacon <will@kernel.org>, Phil Auld <pauld@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/core: Fix a missed update of user_cpus_ptr
Date: Fri, 3 Feb 2023 11:04:50 -1000	[thread overview]
Message-ID: <Y9128uN5X8L3VTG3@slm.duckdns.org> (raw)
In-Reply-To: <20230203181849.221943-1-longman@redhat.com>

On Fri, Feb 03, 2023 at 01:18:49PM -0500, Waiman Long wrote:
> Since commit 8f9ea86fdf99 ("sched: Always preserve the user requested
> cpumask"), a successful call to sched_setaffinity() should always save
> the user requested cpu affinity mask in a task's user_cpus_ptr. However,
> when the given cpu mask is the same as the current one, user_cpus_ptr
> is not updated. Fix this by saving the user mask in this case too.
> 
> Fixes: 8f9ea86fdf99 ("sched: Always preserve the user requested cpumask")
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
>  kernel/sched/core.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 30d9752e2ca5..91255f791df3 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2951,8 +2951,11 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
>  	}
>  
>  	if (!(ctx->flags & SCA_MIGRATE_ENABLE)) {
> -		if (cpumask_equal(&p->cpus_mask, ctx->new_mask))
> +		if (cpumask_equal(&p->cpus_mask, ctx->new_mask)) {
> +			if (ctx->flags & SCA_USER)
> +				swap(p->user_cpus_ptr, ctx->user_mask);
>  			goto out;
> +		}
>  
>  		if (WARN_ON_ONCE(p == current &&
>  				 is_migration_disabled(p) &&

and this is for a separate bug and should go through the scheduler tree.

Thanks.

-- 
tejun

  reply	other threads:[~2023-02-03 21:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 18:18 [PATCH] sched/core: Fix a missed update of user_cpus_ptr Waiman Long
2023-02-03 21:04 ` Tejun Heo [this message]
2023-02-03 22:13   ` Waiman Long
2023-02-13 14:56 ` Peter Zijlstra
2023-02-15 10:33 ` [tip: sched/urgent] " tip-bot2 for Waiman Long

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=Y9128uN5X8L3VTG3@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=pauld@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=will@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