All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] workqueue: Restore cpus_allowed mask for sleeping workqueue rescue threads
@ 2011-09-01 13:36 Ripduman Sohan
  2011-09-02  0:29 ` Tejun Heo
  0 siblings, 1 reply; 14+ messages in thread
From: Ripduman Sohan @ 2011-09-01 13:36 UTC (permalink / raw)
  To: tj; +Cc: linux-kernel, peterz, Ripduman Sohan

Rescuer threads may be migrated (and are bound) to particular CPUs when
active.  However, the allowed_cpus mask is not restored when they return
to sleep rendering inconsistent the presented and actual set of CPUs the
process may potentially run on.  This patch fixes this oversight by
recording the allowed_cpus mask for rescuer threads when it enters the
rescuer_thread() main loop and restoring it every time the thread sleeps.

v2: Heeded Peter Zijlstra's comments and don't allocate cpumask_t on
    stack, manipulate task cpus_allowed struct directly instead

Signed-off-by: Ripduman Sohan <ripduman.sohan@cl.cam.ac.uk>
---
 kernel/workqueue.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 25fb1b0..29d2ddf 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2078,6 +2078,12 @@ repeat:
 		spin_unlock_irq(&gcwq->lock);
 	}
 
+        if (is_unbound)
+                cpumask_setall(&current->cpus_allowed);
+        else
+                for_each_cwq_cpu(cpu, wq)
+                        cpu_set(cpu, current->cpus_allowed);
+
 	schedule();
 	goto repeat;
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread
* [PATCH] workqueue: Restore cpus_allowed mask for sleeping workqueue rescue threads
@ 2011-08-31 13:17 Ripduman Sohan
  2011-08-31 15:20 ` Peter Zijlstra
  0 siblings, 1 reply; 14+ messages in thread
From: Ripduman Sohan @ 2011-08-31 13:17 UTC (permalink / raw)
  To: tj; +Cc: linux-kernel, Ripduman Sohan

Rescuer threads may be migrated (and are bound) to particular CPUs when
active.  However, the allowed_cpus mask is not restored when they return
to sleep rendering inconsistent the presented and actual set of CPUs the
process may potentially run on.  This patch fixes this oversight by
recording the allowed_cpus mask for rescuer threads when it enters the
rescuer_thread() main loop and restoring it every time the thread sleeps.

Signed-off-by: Ripduman Sohan <ripduman.sohan@cl.cam.ac.uk>
---
 kernel/workqueue.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 25fb1b0..0a4e785 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2031,6 +2031,7 @@ static int rescuer_thread(void *__wq)
 	struct list_head *scheduled = &rescuer->scheduled;
 	bool is_unbound = wq->flags & WQ_UNBOUND;
 	unsigned int cpu;
+        cpumask_t allowed_cpus = current->cpus_allowed;
 
 	set_user_nice(current, RESCUER_NICE_LEVEL);
 repeat:
@@ -2078,6 +2079,8 @@ repeat:
 		spin_unlock_irq(&gcwq->lock);
 	}
 
+        set_cpus_allowed_ptr(current, &allowed_cpus);
+
 	schedule();
 	goto repeat;
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-10-01  1:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-01 13:36 [PATCH] workqueue: Restore cpus_allowed mask for sleeping workqueue rescue threads Ripduman Sohan
2011-09-02  0:29 ` Tejun Heo
2011-09-15 16:14   ` Ripduman Sohan
2011-09-17  0:29     ` Tejun Heo
2011-09-18  6:36     ` Gilad Ben-Yossef
2011-09-24  3:07       ` Tejun Heo
2011-09-25  6:02         ` Gilad Ben-Yossef
2011-09-30  8:09           ` Tejun Heo
2011-09-30  8:54             ` Ripduman Sohan
2011-09-30  8:57               ` Tejun Heo
2011-09-30  8:59                 ` Ripduman Sohan
2011-10-01  1:10                   ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2011-08-31 13:17 Ripduman Sohan
2011-08-31 15:20 ` Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.