From: Robert Love <rml@tech9.net>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] set_cpus_allowed() atomicity fix
Date: 09 Oct 2002 19:05:44 -0400 [thread overview]
Message-ID: <1034204745.794.206.camel@phantasy> (raw)
L-Team Captain,
In set_cpus_allowed(), we hold the preempt_disable() over a
wait_for_completition() so it triggers the atomicity debugging.
There is (was) a kernel preemption race here which the preemption
disable is fixing. I do not understand it; if this uncovers it there
should be some light shed on the subject.
Anyhow, attached patch fixes the atomicity debugging error.
Patch is against current BK. Please, apply.
Robert Love
sched.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff -urN linux-bk/kernel/sched.c linux/kernel/sched.c
--- linux-bk/kernel/sched.c 2002-10-09 15:46:43.000000000 -0400
+++ linux/kernel/sched.c 2002-10-09 18:52:06.000000000 -0400
@@ -1953,7 +1953,6 @@
BUG();
#endif
- preempt_disable();
rq = task_rq_lock(p, &flags);
p->cpus_allowed = new_mask;
/*
@@ -1962,7 +1961,7 @@
*/
if (new_mask & (1UL << task_cpu(p))) {
task_rq_unlock(rq, &flags);
- goto out;
+ return;
}
/*
* If the task is not on a runqueue (and not running), then
@@ -1971,17 +1970,21 @@
if (!p->array && !task_running(rq, p)) {
set_task_cpu(p, __ffs(p->cpus_allowed));
task_rq_unlock(rq, &flags);
- goto out;
+ return;
}
init_completion(&req.done);
req.task = p;
list_add(&req.list, &rq->migration_queue);
+
+ /*
+ * counter the subsequent unlock - we do not want to preempt yet
+ */
+ preempt_disable();
task_rq_unlock(rq, &flags);
wake_up_process(rq->migration_thread);
+ preempt_enable();
wait_for_completion(&req.done);
-out:
- preempt_enable();
}
/*
next reply other threads:[~2002-10-09 23:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-09 23:05 Robert Love [this message]
2002-10-09 23:17 ` [PATCH] set_cpus_allowed() atomicity fix Linus Torvalds
2002-10-10 1:05 ` 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=1034204745.794.206.camel@phantasy \
--to=rml@tech9.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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