From: Robert Love <rml@tech9.net>
To: kevin@koconnor.net
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: Re: lock order in O(1) scheduler
Date: 10 Jan 2002 00:26:08 -0500 [thread overview]
Message-ID: <1010640369.5335.289.camel@phantasy> (raw)
In-Reply-To: <20020110001002.A13456@arizona.localdomain>
In-Reply-To: <20020110001002.A13456@arizona.localdomain>
On Thu, 2002-01-10 at 00:10, kevin@koconnor.net wrote:
> I was unable to figure out what the logic of the '(smp_processor_id() <
> p->cpu)' test is.. (Why should the CPU number of the process being awoken
> matter?) My best guess is that this is to enforce a locking invariant -
> but if so, isn't this test backwards? If p->cpu > current->cpu then
> p->cpu's runqueue is locked first followed by this_rq - locking greatest to
> least, where the rest of the code does least to greatest..
Not so sure of the validity, but it is to respect lock order. Locking
order is to obtain the locks lowest CPU id first to prevent AB/BA
deadlock. See the comment above the runqueue data structure for
explanation.
> Also, this code in set_cpus_allowed() looks bogus:
>
> if (target_cpu < smp_processor_id()) {
> spin_lock_irq(&target_rq->lock);
> spin_lock(&this_rq->lock);
> } else {
> spin_lock_irq(&target_rq->lock);
> spin_lock(&this_rq->lock);
> }
This is certainly wrong, I noticed this earlier today. The unlocking
order is not respected either, I suspect.
I believe the code should be:
if (target_cpu < smp_processor_id()) {
spin_lock_irq(&target_rq->lock);
spin_lock(&this_rq->lock);
} else {
spin_lock_irq(&this_rq->lock);
spin_lock(&target_rq->lock);
}
Not so sure about unlocking. Ingo?
Robert Love
next prev parent reply other threads:[~2002-01-10 5:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-10 5:10 lock order in O(1) scheduler kevin
2002-01-10 5:26 ` Robert Love [this message]
2002-01-10 5:29 ` David S. Miller
2002-01-10 5:49 ` Robert Love
2002-01-10 5:38 ` Davide Libenzi
2002-01-10 6:29 ` kevin
2002-01-10 13:11 ` Ingo Molnar
2002-01-10 5:51 ` Robert Love
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=1010640369.5335.289.camel@phantasy \
--to=rml@tech9.net \
--cc=kevin@koconnor.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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