[PATCH] workqueue: Restore cpus_allowed mask for sleeping workqueue rescue threads

From: Ripduman Sohan
Date: Wed Aug 31 2011 - 09:25:37 EST


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@xxxxxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/