All of lore.kernel.org
 help / color / mirror / Atom feed
From: fushuai.wang@linux.dev
To: "Peter Zijlstra" <peterz@infradead.org>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	vschneid@redhat.com, kprateek.nayak@amd.com,
	sshegde@linux.ibm.com, linux-kernel@vger.kernel.org,
	wangfushuai@baidu.com
Subject: Re: [PATCH v2] sched/core: Fix a TOCTOU bug in sched_non_preferred_cpu_push_stop()
Date: Fri, 20 Nov 2026 03:18:45 +0000	[thread overview]
Message-ID: <9ccffcd29373dd9ab6b598ebe07eebbced04c156@linux.dev> (raw)
In-Reply-To: <20261119090728.GN2668804@noisy.programming.kicks-ass.net>

2026年11月19日 17:07, "Peter Zijlstra" <peterz@infradead.org mailto:peterz@infradead.org?to=%22Peter%20Zijlstra%22%20%3Cpeterz%40infradead.org%3E > 写到:

> >  
> >  kernel/sched/core.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >  
> >  diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> >  index 5ed660f099a5..6f9374aa3f19 100644
> >  --- a/kernel/sched/core.c
> >  +++ b/kernel/sched/core.c
> >  @@ -11314,7 +11314,8 @@ static int sched_non_preferred_cpu_push_stop(void *arg)
> >  rq->npc_push_work_pending = false;
> >  update_rq_clock(rq);
> >  
> >  - if (task_rq(p) == rq && task_on_rq_queued(p)) {
> >  + if (task_rq(p) == rq && task_on_rq_queued(p) &&
> >  + !is_migration_disabled(p)) {
> >  struct rq *dest_rq = __migrate_task(rq, &rf, p, cpu);
> >  
> >  if (rq != dest_rq)
> > 
> I think I like a comment with this. Perhaps add something like:
> 
>  /*
>  * Racy: is_migration_disabled(current) isn't stable.
>  */
>  if (is_migration_disabled(push_task))
>  return;
> 
> in sched_push_current_non_preferred_cpu().

Hi, Peter

Will add it in v3.

> 
> Also, I wonder if you'd find more of this if you stick something like:
> 
>  lockdep_assert(!task_on_cpu(p) || in_task());
> 
> inside is_migration_disabled().
>

I'll add it and run more tests.

Regards,
Fushuai.

      reply	other threads:[~2026-11-20  3:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  6:59 [PATCH v2] sched/core: Fix a TOCTOU bug in sched_non_preferred_cpu_push_stop() Fushuai Wang
2026-11-18  9:06 ` Shrikanth Hegde
2026-11-19  9:07 ` Peter Zijlstra
2026-11-20  3:18   ` fushuai.wang [this message]

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=9ccffcd29373dd9ab6b598ebe07eebbced04c156@linux.dev \
    --to=fushuai.wang@linux.dev \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sshegde@linux.ibm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=wangfushuai@baidu.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 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.