From: Srivatsa Vaddagiri <vatsa@in.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: mingo@redhat.com, rusty@au1.ibm.com, linux-kernel@vger.kernel.org
Subject: Re: more efficient current_is_keventd macro? [was Re: [lhcs-devel] Re: Kthread_create() never returns when called from worker_thread]
Date: Tue, 9 Mar 2004 19:10:29 +0530 [thread overview]
Message-ID: <20040309134028.GA26645@in.ibm.com> (raw)
In-Reply-To: <20040308143658.25c1d378.akpm@osdl.org>
On Mon, Mar 08, 2004 at 02:36:58PM -0800, Andrew Morton wrote:
> Is racy in the presence of preemption. Please replace smp_processor_id()
> with get_cpu(), stick a put_cpu() at the end, avoid having two function
> return points, test it and send me the diff?
Hi Andrew,
I had considered preemption and had thought using just
smp_processor_id() should be safe, since anyway the per-cpu kevent
thread is bound to its cpu alone.
Patch below is booted/tested against 2.6.4-rc2-mm1 on a 4-way x86 SMP box.
For testing, I basically called call_usermodehelper from inside a
work function (activated using schedule_work) and checked that
current_is_keventd() macro was returning true.
--- workqueue.c.org 2004-03-09 11:34:30.000000000 +0530
+++ workqueue.c 2004-03-09 19:06:51.000000000 +0530
@@ -374,16 +374,17 @@
int current_is_keventd(void)
{
struct cpu_workqueue_struct *cwq;
- int cpu;
+ int cpu = smp_processor_id();
+ int ret = 0;
BUG_ON(!keventd_wq);
- for_each_cpu(cpu) {
- cwq = keventd_wq->cpu_wq + cpu;
- if (current == cwq->thread)
- return 1;
- }
- return 0;
+ cwq = keventd_wq->cpu_wq + cpu;
+ if (current == cwq->thread)
+ ret = 1;
+
+ return ret;
+
}
#ifdef CONFIG_HOTPLUG_CPU
--
Thanks and Regards,
Srivatsa Vaddagiri,
Linux Technology Center,
IBM Software Labs,
Bangalore, INDIA - 560017
prev parent reply other threads:[~2004-03-09 13:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-08 12:30 more efficient current_is_keventd macro? [was Re: [lhcs-devel] Re: Kthread_create() never returns when called from worker_thread] Srivatsa Vaddagiri
2004-03-08 22:36 ` Andrew Morton
2004-03-09 1:50 ` Rusty Russell
2004-03-09 13:40 ` Srivatsa Vaddagiri [this message]
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=20040309134028.GA26645@in.ibm.com \
--to=vatsa@in.ibm.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rusty@au1.ibm.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