[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <878qurhlmu.ffs@tglx>
Date: Sun, 13 Oct 2024 21:02:17 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: David Laight <David.Laight@...LAB.COM>, Steven Rostedt
<rostedt@...dmis.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Sebastian Andrzej Siewior
<bigeasy@...utronix.de>, Ankur Arora <ankur.a.arora@...cle.com>,
"mingo@...nel.org" <mingo@...nel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "juri.lelli@...hat.com"
<juri.lelli@...hat.com>, "vincent.guittot@...aro.org"
<vincent.guittot@...aro.org>, "dietmar.eggemann@....com"
<dietmar.eggemann@....com>, "bsegall@...gle.com" <bsegall@...gle.com>,
"mgorman@...e.de" <mgorman@...e.de>, "vschneid@...hat.com"
<vschneid@...hat.com>, "efault@....de" <efault@....de>
Subject: RE: [PATCH 0/5] sched: Lazy preemption muck
On Thu, Oct 10 2024 at 10:23, David Laight wrote:
> ...
>> And once all the problems with LAZY are sorted then this cond_resched()
>> line just goes away and the loop looks like this:
>>
>> while ($cond) {
>> spin_lock(L);
>> do_stuff();
>> spin_unlock(L);
>> }
>
> The problem with that pattern is the cost of the atomics.
> Thay can easily be significant especially if there are
> a lot of iterations and do_stuff() is cheap;
>
> If $cond needs the lock, the code is really:
> spin_lock(L);
> while ($cond) {
> do_stuff();
> spin_unlock(L);
> spin_lock(L);
> }
> spin_unlock(L);
>
> which make it even more obvious that you need a cheap
> test to optimise away the unlock/lock pair.
You cannot optimize the unlock/lock pair away for a large number of
iterations because then you bring back the problem of extended
latencies.
It does not matter whether $cond is cheap and do_stuff() is cheap. If
you have enough iterations then even a cheap do_stuff() causes massive
latencies, unless you keep the horrible cond_resched() mess, which we
are trying to remove.
What you are proposing is a programming antipattern and the lock/unlock
around do_stuff() in the clean loop I outlined is mostly free when there
is no contention, unless you use a pointless micro benchmark which has
an empty (or almost empty) do_stuff() implementation. We are not
optimizing for completely irrelevant theoretical nonsense.
Thanks,
tglx
Powered by blists - more mailing lists