mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
workqueue: fix freezeable workqueues implementation
Currently ->freezeable is per-cpu, this is wrong. CPU_UP_PREPARE creates cwq->thread which is not freezeable. Move ->freezeable to workqueue_struct. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com> Cc: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com> Cc: Gautham shenoy <ego@in.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
38c3bd96a0
commit
319c2a986e
1 changed files with 9 additions and 9 deletions
|
@ -49,8 +49,6 @@ struct cpu_workqueue_struct {
|
||||||
struct work_struct *current_work;
|
struct work_struct *current_work;
|
||||||
|
|
||||||
int run_depth; /* Detect run_workqueue() recursion depth */
|
int run_depth; /* Detect run_workqueue() recursion depth */
|
||||||
|
|
||||||
int freezeable; /* Freeze the thread during suspend */
|
|
||||||
} ____cacheline_aligned;
|
} ____cacheline_aligned;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -61,6 +59,7 @@ struct workqueue_struct {
|
||||||
struct cpu_workqueue_struct *cpu_wq;
|
struct cpu_workqueue_struct *cpu_wq;
|
||||||
const char *name;
|
const char *name;
|
||||||
struct list_head list; /* Empty if single thread */
|
struct list_head list; /* Empty if single thread */
|
||||||
|
int freezeable; /* Freeze threads during suspend */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* All the per-cpu workqueues on the system, for hotplug cpu to add/remove
|
/* All the per-cpu workqueues on the system, for hotplug cpu to add/remove
|
||||||
|
@ -351,7 +350,7 @@ static int worker_thread(void *__cwq)
|
||||||
struct k_sigaction sa;
|
struct k_sigaction sa;
|
||||||
sigset_t blocked;
|
sigset_t blocked;
|
||||||
|
|
||||||
if (!cwq->freezeable)
|
if (!cwq->wq->freezeable)
|
||||||
current->flags |= PF_NOFREEZE;
|
current->flags |= PF_NOFREEZE;
|
||||||
|
|
||||||
set_user_nice(current, -5);
|
set_user_nice(current, -5);
|
||||||
|
@ -375,7 +374,7 @@ static int worker_thread(void *__cwq)
|
||||||
|
|
||||||
set_current_state(TASK_INTERRUPTIBLE);
|
set_current_state(TASK_INTERRUPTIBLE);
|
||||||
while (!kthread_should_stop()) {
|
while (!kthread_should_stop()) {
|
||||||
if (cwq->freezeable)
|
if (cwq->wq->freezeable)
|
||||||
try_to_freeze();
|
try_to_freeze();
|
||||||
|
|
||||||
add_wait_queue(&cwq->more_work, &wait);
|
add_wait_queue(&cwq->more_work, &wait);
|
||||||
|
@ -546,7 +545,7 @@ out:
|
||||||
EXPORT_SYMBOL_GPL(flush_work);
|
EXPORT_SYMBOL_GPL(flush_work);
|
||||||
|
|
||||||
static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
|
static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
|
||||||
int cpu, int freezeable)
|
int cpu)
|
||||||
{
|
{
|
||||||
struct cpu_workqueue_struct *cwq = per_cpu_ptr(wq->cpu_wq, cpu);
|
struct cpu_workqueue_struct *cwq = per_cpu_ptr(wq->cpu_wq, cpu);
|
||||||
struct task_struct *p;
|
struct task_struct *p;
|
||||||
|
@ -554,7 +553,6 @@ static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
|
||||||
spin_lock_init(&cwq->lock);
|
spin_lock_init(&cwq->lock);
|
||||||
cwq->wq = wq;
|
cwq->wq = wq;
|
||||||
cwq->thread = NULL;
|
cwq->thread = NULL;
|
||||||
cwq->freezeable = freezeable;
|
|
||||||
INIT_LIST_HEAD(&cwq->worklist);
|
INIT_LIST_HEAD(&cwq->worklist);
|
||||||
init_waitqueue_head(&cwq->more_work);
|
init_waitqueue_head(&cwq->more_work);
|
||||||
|
|
||||||
|
@ -586,10 +584,12 @@ struct workqueue_struct *__create_workqueue(const char *name,
|
||||||
}
|
}
|
||||||
|
|
||||||
wq->name = name;
|
wq->name = name;
|
||||||
|
wq->freezeable = freezeable;
|
||||||
|
|
||||||
mutex_lock(&workqueue_mutex);
|
mutex_lock(&workqueue_mutex);
|
||||||
if (singlethread) {
|
if (singlethread) {
|
||||||
INIT_LIST_HEAD(&wq->list);
|
INIT_LIST_HEAD(&wq->list);
|
||||||
p = create_workqueue_thread(wq, singlethread_cpu, freezeable);
|
p = create_workqueue_thread(wq, singlethread_cpu);
|
||||||
if (!p)
|
if (!p)
|
||||||
destroy = 1;
|
destroy = 1;
|
||||||
else
|
else
|
||||||
|
@ -597,7 +597,7 @@ struct workqueue_struct *__create_workqueue(const char *name,
|
||||||
} else {
|
} else {
|
||||||
list_add(&wq->list, &workqueues);
|
list_add(&wq->list, &workqueues);
|
||||||
for_each_online_cpu(cpu) {
|
for_each_online_cpu(cpu) {
|
||||||
p = create_workqueue_thread(wq, cpu, freezeable);
|
p = create_workqueue_thread(wq, cpu);
|
||||||
if (p) {
|
if (p) {
|
||||||
kthread_bind(p, cpu);
|
kthread_bind(p, cpu);
|
||||||
wake_up_process(p);
|
wake_up_process(p);
|
||||||
|
@ -854,7 +854,7 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
|
||||||
mutex_lock(&workqueue_mutex);
|
mutex_lock(&workqueue_mutex);
|
||||||
/* Create a new workqueue thread for it. */
|
/* Create a new workqueue thread for it. */
|
||||||
list_for_each_entry(wq, &workqueues, list) {
|
list_for_each_entry(wq, &workqueues, list) {
|
||||||
if (!create_workqueue_thread(wq, hotcpu, 0)) {
|
if (!create_workqueue_thread(wq, hotcpu)) {
|
||||||
printk("workqueue for %i failed\n", hotcpu);
|
printk("workqueue for %i failed\n", hotcpu);
|
||||||
return NOTIFY_BAD;
|
return NOTIFY_BAD;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue