Showing the changes to kernel/workqueue.c (1 of 1490 files). Show all
Unified · Split
| @@ -985,6 +985,8 @@ undo: · 984 unmodified lines | ||
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | #ifdef CONFIG_SMP |
| 988 | +static struct workqueue_struct *work_on_cpu_wq __read_mostly; | |
| 989 | + | |
| 988 | 990 | struct work_for_cpu { |
| 989 | 991 | struct work_struct work; |
| 990 | 992 | long (*fn)(void *); |
| @@ -1005,8 +1007,8 @@ static void do_work_for_cpu(struct work_struct *w) · 14 unmodified lines | ||
| 1005 | 1007 | * @fn: the function to run |
| 1006 | 1008 | * @arg: the function arg |
| 1007 | 1009 | * |
| 1008 | − * This will return -EINVAL in the cpu is not online, or the return value | |
| 1009 | − * of @fn otherwise. | |
| 1010 | + * This will return the value @fn returns. | |
| 1011 | + * It is up to the caller to ensure that the cpu doesn't go offline. | |
| 1010 | 1012 | */ |
| 1011 | 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) · 2 unmodified lines | ||
| 1015 | 1017 | INIT_WORK(&wfc.work, do_work_for_cpu); |
| 1016 | 1018 | wfc.fn = fn; |
| 1017 | 1019 | wfc.arg = arg; |
| 1018 | − get_online_cpus(); | |
| 1019 | − if (unlikely(!cpu_online(cpu))) | |
| 1020 | − wfc.ret = -EINVAL; | |
| 1021 | − else { | |
| 1022 | − schedule_work_on(cpu, &wfc.work); | |
| 1023 | − flush_work(&wfc.work); | |
| 1024 | − } | |
| 1025 | − put_online_cpus(); | |
| 1020 | + queue_work_on(cpu, work_on_cpu_wq, &wfc.work); | |
| 1021 | + flush_work(&wfc.work); | |
| 1026 | 1022 | |
| 1027 | 1023 | return wfc.ret; |
| 1028 | 1024 | } |
| @@ -1039,4 +1035,8 @@ void __init init_workqueues(void) · 10 unmodified lines | ||
| 1039 | 1035 | hotcpu_notifier(workqueue_cpu_callback, 0); |
| 1040 | 1036 | keventd_wq = create_workqueue("events"); |
| 1041 | 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 | } |