[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YB10S/qnerZkH9eb@google.com>
Date: Fri, 5 Feb 2021 11:37:31 -0500
From: Joel Fernandes <joel@...lfernandes.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Nishanth Aravamudan <naravamudan@...italocean.com>,
Julien Desfossez <jdesfossez@...italocean.com>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Vineeth Pillai <viremana@...ux.microsoft.com>,
Aaron Lu <aaron.lwe@...il.com>,
Aubrey Li <aubrey.intel@...il.com>, tglx@...utronix.de,
linux-kernel@...r.kernel.org, mingo@...nel.org,
torvalds@...ux-foundation.org, fweisbec@...il.com,
keescook@...omium.org, kerrnel@...gle.com,
Phil Auld <pauld@...hat.com>,
Valentin Schneider <valentin.schneider@....com>,
Mel Gorman <mgorman@...hsingularity.net>,
Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>,
Paolo Bonzini <pbonzini@...hat.com>, vineeth@...byteword.org,
Chen Yu <yu.c.chen@...el.com>,
Christian Brauner <christian.brauner@...ntu.com>,
Agata Gruza <agata.gruza@...el.com>,
Antonio Gomez Iglesias <antonio.gomez.iglesias@...el.com>,
graf@...zon.com, konrad.wilk@...cle.com, dfaggioli@...e.com,
pjt@...gle.com, rostedt@...dmis.org, derkling@...gle.com,
benbjiang@...cent.com,
Alexandre Chartre <alexandre.chartre@...cle.com>,
James.Bottomley@...senpartnership.com, OWeisse@...ch.edu,
Dhaval Giani <dhaval.giani@...cle.com>,
Junaid Shahid <junaids@...gle.com>, jsbarnes@...gle.com,
chris.hyser@...cle.com, Ben Segall <bsegall@...gle.com>,
Josh Don <joshdon@...gle.com>, Hao Luo <haoluo@...gle.com>,
Tom Lendacky <thomas.lendacky@....com>
Subject: Re: [PATCH v10 2/5] sched: CGroup tagging interface for core
scheduling
On Thu, Feb 04, 2021 at 03:52:53PM +0100, Peter Zijlstra wrote:
> On Fri, Jan 22, 2021 at 08:17:01PM -0500, Joel Fernandes (Google) wrote:
> > +static void sched_core_update_cookie(struct task_struct *p, unsigned long cookie,
> > + enum sched_core_cookie_type cookie_type)
> > +{
> > + struct rq_flags rf;
> > + struct rq *rq;
> > +
> > + if (!p)
> > + return;
> > +
> > + rq = task_rq_lock(p, &rf);
> > +
> > + switch (cookie_type) {
> > + case sched_core_task_cookie_type:
> > + p->core_task_cookie = cookie;
> > + break;
> > + case sched_core_group_cookie_type:
> > + p->core_group_cookie = cookie;
> > + break;
> > + default:
> > + WARN_ON_ONCE(1);
> > + }
> > +
> > + /* Set p->core_cookie, which is the overall cookie */
> > + __sched_core_update_cookie(p);
> > +
> > + if (sched_core_enqueued(p)) {
> > + sched_core_dequeue(rq, p);
> > + if (!p->core_cookie) {
> > + task_rq_unlock(rq, p, &rf);
> > + return;
> > + }
> > + }
> > +
> > + if (sched_core_enabled(rq) &&
> > + p->core_cookie && task_on_rq_queued(p))
> > + sched_core_enqueue(task_rq(p), p);
> > +
> > + /*
> > + * If task is currently running or waking, it may not be compatible
> > + * anymore after the cookie change, so enter the scheduler on its CPU
> > + * to schedule it away.
> > + */
> > + if (task_running(rq, p) || p->state == TASK_WAKING)
> > + resched_curr(rq);
>
> I'm not immediately seeing the need for that WAKING test. Since we're
> holding it's rq->lock, the only place that task can be WAKING is on the
> wake_list. And if it's there, it needs to acquire rq->lock to get
> enqueued, and rq->lock again to get scheduled.
>
> What am I missing?
Hi Peter,
I did this way following a similar pattern in affine_move_task(). However, I
think you are right. Unlike in the case affine_move_task(), we have
schedule() to do the right thing for us in case of any races with wakeup. So
the TASK_WAKING test is indeed not needed and we can drop tha test. Apologies
for adding the extra test out of paranoia.
thanks,
- Joel
Powered by blists - more mailing lists