diff options
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 1fc2bc20603f..e53ee18ef431 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -985,6 +985,8 @@ undo: | |||
985 | } | 985 | } |
986 | 986 | ||
987 | #ifdef CONFIG_SMP | 987 | #ifdef CONFIG_SMP |
988 | static struct workqueue_struct *work_on_cpu_wq __read_mostly; | ||
989 | |||
988 | struct work_for_cpu { | 990 | struct work_for_cpu { |
989 | struct work_struct work; | 991 | struct work_struct work; |
990 | long (*fn)(void *); | 992 | long (*fn)(void *); |
@@ -1005,8 +1007,8 @@ static void do_work_for_cpu(struct work_struct *w) | |||
1005 | * @fn: the function to run | 1007 | * @fn: the function to run |
1006 | * @arg: the function arg | 1008 | * @arg: the function arg |
1007 | * | 1009 | * |
1008 | * This will return -EINVAL in the cpu is not online, or the return value | 1010 | * This will return the value @fn returns. |
1009 | * of @fn otherwise. | 1011 | * It is up to the caller to ensure that the cpu doesn't go offline. |
1010 | */ | 1012 | */ |
1011 | long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg) | 1013 | long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg) |
1012 | { | 1014 | { |
@@ -1015,14 +1017,8 @@ long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg) | |||
1015 | INIT_WORK(&wfc.work, do_work_for_cpu); | 1017 | INIT_WORK(&wfc.work, do_work_for_cpu); |
1016 | wfc.fn = fn; | 1018 | wfc.fn = fn; |
1017 | wfc.arg = arg; | 1019 | wfc.arg = arg; |
1018 | get_online_cpus(); | 1020 | queue_work_on(cpu, work_on_cpu_wq, &wfc.work); |
1019 | if (unlikely(!cpu_online(cpu))) | 1021 | flush_work(&wfc.work); |
1020 | wfc.ret = -EINVAL; | ||
1021 | else { | ||
1022 | schedule_work_on(cpu, &wfc.work); | ||
1023 | flush_work(&wfc.work); | ||
1024 | } | ||
1025 | put_online_cpus(); | ||
1026 | 1022 | ||
1027 | return wfc.ret; | 1023 | return wfc.ret; |
1028 | } | 1024 | } |
@@ -1039,4 +1035,8 @@ void __init init_workqueues(void) | |||
1039 | hotcpu_notifier(workqueue_cpu_callback, 0); | 1035 | hotcpu_notifier(workqueue_cpu_callback, 0); |
1040 | keventd_wq = create_workqueue("events"); | 1036 | keventd_wq = create_workqueue("events"); |
1041 | BUG_ON(!keventd_wq); | 1037 | BUG_ON(!keventd_wq); |
1038 | #ifdef CONFIG_SMP | ||
1039 | work_on_cpu_wq = create_workqueue("work_on_cpu"); | ||
1040 | BUG_ON(!work_on_cpu_wq); | ||
1041 | #endif | ||
1042 | } | 1042 | } |