From: Ingo Molnar <mingo@elte.hu>
To: Esben Nielsen <simlo@phys.au.dk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Priority Inheritance Test (Real-Time Preemption)
Date: Sun, 28 Nov 2004 09:42:50 +0100 [thread overview]
Message-ID: <20041128084250.GC9814@elte.hu> (raw)
In-Reply-To: <Pine.OSF.4.05.10411271106151.23754-100000@da410.ifa.au.dk>
* Esben Nielsen <simlo@phys.au.dk> wrote:
> > task-A task-B task-C task-RT
> > -------------------------------------------------------
> > [ 1 ms ] . .
> > UL-1 . .
> > get-L1 .
> > UL-2 .
> Now I see it! The reason is that task-C is _given_ the lock by task A.
> The action of transfering the lock from A to C is done in A's context
> with RT-prio.
correct.
> My line of thinking was that although task-C is in the wait queue of
> lock1 it still actively have to go in and _take_ the lock. In that
> kind of setup task-RT would get i first on UP.
Trying to exclude all locking activity by 'lesser' tasks (unrelated to
the higher-prio tasks) while a higher-prio task is running is a quite
fragile concept i believe, and it's also pointless: just think about
SMP, or an RT task sleeping for short periods of time for whatever
reason.
This effect can be very well avoided by taking both locks, and this also
better matches the real locking scenarios that happen in the Linux
kernel.
> [...] I have a detailed description of such
> a design below but first I have to point out that the formula for the
> worst case delay is not
> N*(N+1)/2
> but
> 2^N-1
ok.
> I.e.
> N f(N)
> 0 0
> 1 1
> 2 3
> 3 7
> 4 15
>
> My tests doesn't show that - but it requires 2^N tasks to reproduce. I
> am trying to do that now.
note that it's (probably worse than-) exponentially more unlikely for a
test to be able to generate the worst-case.
> Ok, back to a design making
> f(N) = N
> on UP:
why? It is quite rare for there to be even 4-deep locking structures in
the kernel, and even then, it's even rarer that they get accessed in
such an arbitrary-deep manner. Note that task-B can only steal the lock
from task-A because the following locking pattern is allowed:
L1,UL1 [X]
besides:
L1,L2,UL1,UL2 [Y]
In Linux, if there's 2-deep locking, it is much more common for only [Y]
to be allowed, for which the formula is still "f(N) = N". Or even if
both [X] and [Y] is allowed, 3-deep or 4-deep locking with [X] and [Y]
allowed as well is quite rare. Not only is this rare, it's _even_ rarer
that no code within that 4-lock-protected region may end up blocking on
an external interrupt. So what you are trying to solve is a very narrow
case i believe.
> When I made the mutex in U9.2-priom I originally made it like that: In
> mutex_unlock() owner was set to NULL and the first task awaken. But a
> high priority task could at that point get in and snap the mutex in
> front of the newly awoken task. That setup would make stuff work
> better on UP.
we could try wakeup-retry instead of pass-lock, although pass-lock still
feels more robust. Relying on UP-starvation to reduce your latencies is
quite ... fragile.
Also, pass-lock performs better because the woken up task does not have
to touch the lock structure anymore, up until it has to release it.
(which gives the CPU(s) more time to optimize things, especially on
SMP.) But if you send a separate patch for that alone (to implement the
'released' state) then we'll be able to see the costs in isolation.
Ingo
next prev parent reply other threads:[~2004-11-28 8:43 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-21 20:29 Priority Inheritance Test (Real-Time Preemption) Esben Nielsen
2004-11-22 0:27 ` Ingo Molnar
2004-11-23 13:34 ` Ingo Molnar
2004-11-23 15:47 ` Esben Nielsen
2004-11-23 23:03 ` Esben Nielsen
2004-11-24 3:42 ` Ingo Molnar
2004-11-24 7:51 ` Ingo Molnar
2004-11-24 8:07 ` Ingo Molnar
2004-11-24 8:33 ` Esben Nielsen
2004-11-24 9:55 ` Ingo Molnar
2004-11-24 10:18 ` Ingo Molnar
2004-11-25 15:46 ` Esben Nielsen
2004-11-25 16:58 ` Ingo Molnar
2004-11-25 16:08 ` Esben Nielsen
2004-11-25 17:14 ` Ingo Molnar
2004-11-25 22:08 ` Esben Nielsen
2004-11-26 1:08 ` Ingo Molnar
2004-11-26 0:34 ` Ingo Molnar
2004-11-26 0:37 ` Ingo Molnar
2004-11-26 8:52 ` Esben Nielsen
2004-11-26 16:26 ` Esben Nielsen
2004-11-26 20:41 ` Ingo Molnar
2004-11-26 21:05 ` Ingo Molnar
2004-11-27 23:05 ` Esben Nielsen
2004-11-28 8:42 ` Ingo Molnar [this message]
2004-11-28 15:55 ` Esben Nielsen
2004-11-29 9:59 ` Ingo Molnar
2004-11-29 15:07 ` Esben Nielsen
2004-11-29 15:56 ` Ingo Molnar
2004-11-29 15:57 ` Ingo Molnar
2004-11-29 16:50 ` Esben Nielsen
2004-11-30 8:49 ` Ingo Molnar
2004-11-22 9:23 ` Bill Huey
2004-11-22 12:37 ` Ingo Molnar
2004-11-22 21:25 ` Bill Huey
2004-11-22 14:16 ` john cooper
2004-11-22 15:24 ` Ingo Molnar
2004-11-23 1:19 ` john cooper
2004-11-23 8:13 ` Esben Nielsen
2004-11-23 9:21 ` Ingo Molnar
2004-11-22 21:30 ` Bill Huey
2004-11-23 1:34 ` john cooper
2004-11-22 16:12 ` Esben Nielsen
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=20041128084250.GC9814@elte.hu \
--to=mingo@elte.hu \
--cc=linux-kernel@vger.kernel.org \
--cc=simlo@phys.au.dk \
/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