From: kevin@koconnor.net
To: Robert Love <rml@tech9.net>
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: Re: lock order in O(1) scheduler
Date: Thu, 10 Jan 2002 01:29:57 -0500 [thread overview]
Message-ID: <20020110012957.B13456@arizona.localdomain> (raw)
In-Reply-To: <20020110001002.A13456@arizona.localdomain> <1010640369.5335.289.camel@phantasy>
In-Reply-To: <1010640369.5335.289.camel@phantasy>; from rml@tech9.net on Thu, Jan 10, 2002 at 12:26:08AM -0500
On Thu, Jan 10, 2002 at 12:26:08AM -0500, Robert Love wrote:
> 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.
[...]
Right. It is a confusing though - depending on the value of p->cpu
relative to current->cpu, the synchronous flag may be ignored. Since the
relationship between p->cpu and current->cpu is essentially random, this
makes the behavior of the synchronous flag random - why bother?
I can see that re-grabbing the locks in the proper order would be a pain.
Also, after a quick grep, it appears only fs/pipe.c is interested in the
wake_up_sync() variant. Maybe this feature should just be culled?
-Kevin
The try_to_wake_up function in pre11 (just for reference):
static int try_to_wake_up(task_t * p, int synchronous)
{
unsigned long flags;
int success = 0;
runqueue_t *rq;
lock_task_rq(rq, p, flags);
p->state = TASK_RUNNING;
if (!p->array) {
if (!rt_task(p) && synchronous && (smp_processor_id() < p->cpu)) {
spin_lock(&this_rq()->lock);
p->cpu = smp_processor_id();
activate_task(p, this_rq());
spin_unlock(&this_rq()->lock);
} else {
activate_task(p, rq);
if ((rq->curr == rq->idle) ||
(p->prio < rq->curr->prio))
resched_task(rq->curr);
}
success = 1;
}
unlock_task_rq(rq, p, flags);
return success;
}
--
------------------------------------------------------------------------
| Kevin O'Connor "BTW, IMHO we need a FAQ for |
| kevin@koconnor.net 'IMHO', 'FAQ', 'BTW', etc. !" |
------------------------------------------------------------------------
next prev parent reply other threads:[~2002-01-10 6:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-10 5:10 kevin
2002-01-10 5:26 ` Robert Love
2002-01-10 5:38 ` Davide Libenzi
2002-01-10 5:49 ` Robert Love
2002-01-10 6:29 ` kevin [this message]
2002-01-10 13:11 ` Ingo Molnar
2002-01-10 5:29 ` David S. Miller
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=20020110012957.B13456@arizona.localdomain \
--to=kevin@koconnor.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rml@tech9.net \
/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
all inboxes | Powered by JetHome®