Impact: Reduce memory usage, use new cpumask API. cpu_populated_map becomes a cpumask_var_t, and cpu_singlethread_map is simply a cpumask pointer: it's simply the cpumask containing the first possible CPU anyway.
Showing the changes to kernel/workqueue.c (1 of 1 file). Show all
Unified · Split
| @@ -73,7 +73,7 @@ static DEFINE_SPINLOCK(workqueue_lock); · 72 unmodified lines | ||
| 73 | 73 | static LIST_HEAD(workqueues); |
| 74 | 74 | |
| 75 | 75 | static int singlethread_cpu __read_mostly; |
| 76 | −static cpumask_t cpu_singlethread_map __read_mostly; | |
| 76 | +static const struct cpumask *cpu_singlethread_map __read_mostly; | |
| 77 | 77 | /* |
| 78 | 78 | * _cpu_down() first removes CPU from cpu_online_map, then CPU_DEAD |
| 79 | 79 | * flushes cwq->worklist. This means that flush_workqueue/wait_on_work |
| @@ -81,7 +81,7 @@ static cpumask_t cpu_singlethread_map __read_mostly; · 1 unmodified line | ||
| 81 | 81 | * use cpu_possible_map, the cpumask below is more a documentation |
| 82 | 82 | * than optimization. |
| 83 | 83 | */ |
| 84 | −static cpumask_t cpu_populated_map __read_mostly; | |
| 84 | +static cpumask_var_t cpu_populated_map __read_mostly; | |
| 85 | 85 | |
| 86 | 86 | /* If it's single threaded, it isn't in the list of workqueues. */ |
| 87 | 87 | static inline int is_wq_single_threaded(struct workqueue_struct *wq) |
| @@ -89,10 +89,10 @@ static inline int is_wq_single_threaded(struct workqueue_struct *wq) · 1 unmodified line | ||
| 89 | 89 | return wq->singlethread; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | −static const cpumask_t *wq_cpu_map(struct workqueue_struct *wq) | |
| 92 | +static const struct cpumask *wq_cpu_map(struct workqueue_struct *wq) | |
| 93 | 93 | { |
| 94 | 94 | return is_wq_single_threaded(wq) |
| 95 | − ? &cpu_singlethread_map : &cpu_populated_map; | |
| 95 | + ? cpu_singlethread_map : cpu_populated_map; | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | static |
| @@ -410,7 +410,7 @@ static int flush_cpu_workqueue(struct cpu_workqueue_struct *cwq) · 311 unmodified lines | ||
| 410 | 410 | */ |
| 411 | 411 | void flush_workqueue(struct workqueue_struct *wq) |
| 412 | 412 | { |
| 413 | − const cpumask_t *cpu_map = wq_cpu_map(wq); | |
| 413 | + const struct cpumask *cpu_map = wq_cpu_map(wq); | |
| 414 | 414 | int cpu; |
| 415 | 415 | |
| 416 | 416 | might_sleep(); |
| @@ -532,7 +532,7 @@ static void wait_on_work(struct work_struct *work) · 115 unmodified lines | ||
| 532 | 532 | { |
| 533 | 533 | struct cpu_workqueue_struct *cwq; |
| 534 | 534 | struct workqueue_struct *wq; |
| 535 | − const cpumask_t *cpu_map; | |
| 535 | + const struct cpumask *cpu_map; | |
| 536 | 536 | int cpu; |
| 537 | 537 | |
| 538 | 538 | might_sleep(); |
| @@ -903,7 +903,7 @@ static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq) · 364 unmodified lines | ||
| 903 | 903 | */ |
| 904 | 904 | void destroy_workqueue(struct workqueue_struct *wq) |
| 905 | 905 | { |
| 906 | − const cpumask_t *cpu_map = wq_cpu_map(wq); | |
| 906 | + const struct cpumask *cpu_map = wq_cpu_map(wq); | |
| 907 | 907 | int cpu; |
| 908 | 908 | |
| 909 | 909 | cpu_maps_update_begin(); |
| @@ -933,7 +933,7 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb, · 23 unmodified lines | ||
| 933 | 933 | |
| 934 | 934 | switch (action) { |
| 935 | 935 | case CPU_UP_PREPARE: |
| 936 | − cpu_set(cpu, cpu_populated_map); | |
| 936 | + cpumask_set_cpu(cpu, cpu_populated_map); | |
| 937 | 937 | } |
| 938 | 938 | undo: |
| 939 | 939 | list_for_each_entry(wq, &workqueues, list) { |
| @@ -964,7 +964,7 @@ undo: · 24 unmodified lines | ||
| 964 | 964 | switch (action) { |
| 965 | 965 | case CPU_UP_CANCELED: |
| 966 | 966 | case CPU_POST_DEAD: |
| 967 | − cpu_clear(cpu, cpu_populated_map); | |
| 967 | + cpumask_clear_cpu(cpu, cpu_populated_map); | |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | return ret; |
| @@ -1017,9 +1017,11 @@ EXPORT_SYMBOL_GPL(work_on_cpu); · 46 unmodified lines | ||
| 1017 | 1017 | |
| 1018 | 1018 | void __init init_workqueues(void) |
| 1019 | 1019 | { |
| 1020 | − cpu_populated_map = cpu_online_map; | |
| 1021 | − singlethread_cpu = first_cpu(cpu_possible_map); | |
| 1022 | − cpu_singlethread_map = cpumask_of_cpu(singlethread_cpu); | |
| 1020 | + alloc_cpumask_var(&cpu_populated_map, GFP_KERNEL); | |
| 1021 | + | |
| 1022 | + cpumask_copy(cpu_populated_map, cpu_online_mask); | |
| 1023 | + singlethread_cpu = cpumask_first(cpu_possible_mask); | |
| 1024 | + cpu_singlethread_map = cpumask_of(singlethread_cpu); | |
| 1023 | 1025 | hotcpu_notifier(workqueue_cpu_callback, 0); |
| 1024 | 1026 | keventd_wq = create_workqueue("events"); |
| 1025 | 1027 | BUG_ON(!keventd_wq); |