lkml.org 
[lkml]   [2004]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: more efficient current_is_keventd macro? [was Re: [lhcs-devel] Re: Kthread_create() never returns when called from worker_thread]
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.056 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site