]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] current_is_keventd() speedup
authorAndrew Morton <akpm@osdl.org>
Fri, 12 Mar 2004 00:18:00 +0000 (16:18 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 12 Mar 2004 00:18:00 +0000 (16:18 -0800)
From: Srivatsa Vaddagiri <vatsa@in.ibm.com>

current_is_keventd() doesn't need to search across all the CPUs to identify
itself.

kernel/workqueue.c

index eee885ccf539162378394fad6ea124178f8b2a7d..2e94fd93abe6f31fbe114e614a62bc0fa290f821 100644 (file)
@@ -333,16 +333,17 @@ int keventd_up(void)
 int current_is_keventd(void)
 {
        struct cpu_workqueue_struct *cwq;
-       int cpu;
+       int cpu = smp_processor_id();   /* preempt-safe: keventd is per-cpu */
+       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;
+
 }
 
 void init_workqueues(void)