[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4ca5cd70904d47bea0df93f7c0979c66@AcuMS.aculab.com>
Date: Tue, 12 Apr 2022 08:39:28 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Qais Yousef' <qais.yousef@....com>
CC: Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
"mingo@...hat.com" <mingo@...hat.com>,
"peterz@...radead.org" <peterz@...radead.org>,
"juri.lelli@...hat.com" <juri.lelli@...hat.com>,
"rostedt@...dmis.org" <rostedt@...dmis.org>,
"bsegall@...gle.com" <bsegall@...gle.com>,
"mgorman@...e.de" <mgorman@...e.de>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"parth@...ux.ibm.com" <parth@...ux.ibm.com>,
"chris.hyser@...cle.com" <chris.hyser@...cle.com>,
"pkondeti@...eaurora.org" <pkondeti@...eaurora.org>,
"Valentin.Schneider@....com" <Valentin.Schneider@....com>,
"patrick.bellasi@...bug.net" <patrick.bellasi@...bug.net>,
"pjt@...gle.com" <pjt@...gle.com>, "pavel@....cz" <pavel@....cz>,
"tj@...nel.org" <tj@...nel.org>,
"qperret@...gle.com" <qperret@...gle.com>,
"tim.c.chen@...ux.intel.com" <tim.c.chen@...ux.intel.com>,
Wei Wang <wvw@...gle.com>
Subject: RE: Scheduling tasks on idle cpu
From: Qais Yousef
> Sent: 12 April 2022 00:35
>
> On 04/11/22 08:26, David Laight wrote:
> > From: Qais Yousef
> > > Sent: 09 April 2022 18:09
> > ...
> > > RT scheduler will push/pull tasks to ensure the task will get to run ASAP if
> > > there's another cpu at lower priority is available
> >
> > Does that actually happen?
>
> For RT tasks, yes. They should get distributed.
Ok, that is something slightly different from what I'm seeing.
> > I've seen the following:
> > 34533 [017]: sys_futex(uaddr: 1049104, op: 85, val: 1, utime: 1, uaddr2: 1049100, val3: 4000001)
> > 34533 [017]: sched_migrate_task: pid=34512 prio=120 orig_cpu=14 dest_cpu=17
> > 34533 [017]: sched_wakeup: pid=34512 prio=120 success=1 target_cpu=017
>
> prio=120 is a CFS task, no?
CFS = 'normal time-slice processes ? Then yes.
> > and pid 34512 doesn't get scheduled until pid 34533 finally sleeps.
> > This is in spite of there being 5 idle cpu.
> > cpu 14 is busy running a RT thread, but migrating to cpu 17 seems wrong.
> >
> > This is on a RHEL7 kernel, I've not replicated it on anything recent.
> > But I've very much like a RT thread to be able to schedule a non-RT
> > thread to run on an idle cpu.
>
> Oh, you want CFS to avoid CPUs that are running RT tasks.
>
> We had a proposal in the past, but it wasn't good enough
>
> https://lore.kernel.org/lkml/1567048502-6064-1-git-send-email-jing-ting.wu@mediatek.com/
That seems to be something different.
Related to something else I've seen where a RT process is scheduled
on its old cpu (to get the hot cache) but the process running on
that cpu is looping in kernel - so the RT process doesn't start.
I've avoided most of the pain that caused by not using a single
cv_broadcast() to wake up the 34 RT threads (in this config).
(Each kernel thread seemed to wake up the next one, so the
delays were cumulative.)
Instead there is a separate cv for each RT thread.
I actually want the 'herd of wildebeest' :-)
> The approach in that patch modified RT to avoid CFS actually.
Yes I want the CFS scheduler to pick an idle cpu in preference
to an active RT one.
> Can you verify whether the RT task woke up after task 34512 was migrated to CPU
> 17? Looking at the definition of available_idle_cpu() we should have avoided
> that CPU if the RT task was already running. Both waking up at the same time
> would explain what you see. Otherwise I'm not sure why it picked CPU 17.
All 35 RT tasks are running when the request to schedule task 34512 is made.
(They wake every 10ms to process UDP/RTP audio packets.)
The RT task on cpu 17 carried on running until it ran out of work (after about 1ms).
Task 34512 then ran on cpu 17.
In this case task 34512 actually finished quite quickly.
(It is creating and binding more UDP sockets.)
But it looks like if it were still running on the next 10ms 'tick'
it would be pre-empted by the RT task and be idle.
Not ideal when I'm trying to schedule a background activity.
I don't think the load-balancer will ever pick it up.
All the process scheduling is happening far too fast.
What I think might be happening is that the futex() code is requesting
the woken up thread run on the current cpu.
This can be advantageous in some circumstances - usually if you
know the current thread is about to sleep.
(I remember another scheduler doing that, but I can't remember why!
The only sequence I can think of is a shell doing fork+exec+wait.)
But it seems like a bad idea when a RT thread is waking a CFS one.
(Or any case where the one being woken is lower priority.)
I might have to run the 'background tasks' at low RT priority
just to get them scheduled on idle cpu.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists