The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: David Vernet <void@manifault.com>
To: Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH RESEND sched_ext/for-6.12] sched_ext: Don't use double locking to migrate tasks across CPUs
Date: Thu, 8 Aug 2024 13:25:59 -0500	[thread overview]
Message-ID: <20240808182559.GG6223@maniforge> (raw)
In-Reply-To: <ZrUNdy-oQFd3TgJj@slm.duckdns.org>

[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]

On Thu, Aug 08, 2024 at 08:24:55AM -1000, Tejun Heo wrote:
> Hello,
> 
> On Thu, Aug 08, 2024 at 01:19:27PM -0500, David Vernet wrote:
> ...
> > > +	deactivate_task(src_rq, p, 0);
> > > +	set_task_cpu(p, cpu_of(dst_rq));
> > > +	p->scx.sticky_cpu = cpu_of(dst_rq);
> > > +
> > > +	raw_spin_rq_unlock(src_rq);
> > > +	raw_spin_rq_lock(dst_rq);
> > >  
> > >  	/*
> > >  	 * We want to pass scx-specific enq_flags but activate_task() will
> > >  	 * truncate the upper 32 bit. As we own @rq, we can pass them through
> > >  	 * @rq->scx.extra_enq_flags instead.
> > >  	 */
> > > -	WARN_ON_ONCE(rq->scx.extra_enq_flags);
> > > -	rq->scx.extra_enq_flags = enq_flags;
> > > -	activate_task(rq, p, 0);
> > > -	rq->scx.extra_enq_flags = 0;
> > > +	WARN_ON_ONCE(!cpumask_test_cpu(cpu_of(dst_rq), p->cpus_ptr));
> > 
> > Hmmm, what's to stop someone from issuing a call to
> > set_cpus_allowed_ptr() after we drop the src_rq lock above?  Before we
> > held any relevant rq lock so everything should have been protected, but
> > I'm not following how we prevent racing with the cpus_allowed logic in
> > core.c here.
> 
> deactivate_task(src_rq, p, 0) sets p->on_rq to TASK_ON_RQ_MIGRATING and
> task_rq_lock() can't lock p until it's cleared, so set_cpus_allowed_ptr()
> is blocked till the migration is complete.

Ahh I see, thanks. This LGTM then.

Acked-by: David Vernet <void@manifault.com>

> 
> Thanks.
> 
> -- 
> tejun

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2024-08-08 18:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07 23:14 [sched_ext/for-6.12] sched_ext: Don't use double locking to migrate tasks across CPUs Tejun Heo
2024-08-07 23:15 ` [PATCH RESEND sched_ext/for-6.12] " Tejun Heo
2024-08-08 18:19   ` David Vernet
2024-08-08 18:24     ` Tejun Heo
2024-08-08 18:25       ` David Vernet [this message]
2024-08-13 19:09   ` 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=20240808182559.GG6223@maniforge \
    --to=void@manifault.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --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