* 'cpumask-cleanups' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus: cpumask: rename tsk_cpumask to tsk_cpus_allowed cpumask: don't recommend set_cpus_allowed hack in Documentation/cpu-hotplug.txt cpumask: avoid dereferencing struct cpumask cpumask: convert drivers/idle/i7300_idle.c to cpumask_var_t cpumask: use modern cpumask style in drivers/scsi/fcoe/fcoe.c cpumask: avoid deprecated function in mm/slab.c cpumask: use cpu_online in kernel/perf_event.c
Unified · Split
| @@ -315,41 +315,26 @@ A: The following are what is required for CPU hotplug infrastructure to work · 314 unmodified lines | ||
| 315 | 315 | |
| 316 | 316 | Q: I need to ensure that a particular cpu is not removed when there is some |
| 317 | 317 | work specific to this cpu is in progress. |
| 318 | −A: First switch the current thread context to preferred cpu | |
| 318 | +A: There are two ways. If your code can be run in interrupt context, use | |
| 319 | + smp_call_function_single(), otherwise use work_on_cpu(). Note that | |
| 320 | + work_on_cpu() is slow, and can fail due to out of memory: | |
| 319 | 321 | |
| 320 | 322 | int my_func_on_cpu(int cpu) |
| 321 | 323 | { |
| 322 | − cpumask_t saved_mask, new_mask = CPU_MASK_NONE; | |
| 323 | − int curr_cpu, err = 0; | |
| 324 | − | |
| 325 | − saved_mask = current->cpus_allowed; | |
| 326 | − cpu_set(cpu, new_mask); | |
| 327 | − err = set_cpus_allowed(current, new_mask); | |
| 328 | − | |
| 329 | − if (err) | |
| 330 | − return err; | |
| 331 | − | |
| 332 | − /* | |
| 333 | − * If we got scheduled out just after the return from | |
| 334 | − * set_cpus_allowed() before running the work, this ensures | |
| 335 | − * we stay locked. | |
| 336 | − */ | |
| 337 | − curr_cpu = get_cpu(); | |
| 338 | − | |
| 339 | − if (curr_cpu != cpu) { | |
| 340 | − err = -EAGAIN; | |
| 341 | − goto ret; | |
| 342 | − } else { | |
| 343 | − /* | |
| 344 | − * Do work : But cant sleep, since get_cpu() disables preempt | |
| 345 | − */ | |
| 346 | − } | |
| 347 | − ret: | |
| 348 | − put_cpu(); | |
| 349 | − set_cpus_allowed(current, saved_mask); | |
| 350 | − return err; | |
| 351 | − } | |
| 352 | − | |
| 324 | + int err; | |
| 325 | + get_online_cpus(); | |
| 326 | + if (!cpu_online(cpu)) | |
| 327 | + err = -EINVAL; | |
| 328 | + else | |
| 329 | +#if NEEDS_BLOCKING | |
| 330 | + err = work_on_cpu(cpu, __my_func_on_cpu, NULL); | |
| 331 | +#else | |
| 332 | + smp_call_function_single(cpu, __my_func_on_cpu, &err, | |
| 333 | + true); | |
| 334 | +#endif | |
| 335 | + put_online_cpus(); | |
| 336 | + return err; | |
| 337 | + } | |
| 353 | 338 | |
| 354 | 339 | Q: How do we determine how many CPUs are available for hotplug. |
| 355 | 340 | A: There is no clear spec defined way from ACPI that can give us that |
| @@ -1136,7 +1136,7 @@ static int powernowk8_target(struct cpufreq_policy *pol, · 1135 unmodified lines | ||
| 1136 | 1136 | if (!alloc_cpumask_var(&oldmask, GFP_KERNEL)) |
| 1137 | 1137 | return -ENOMEM; |
| 1138 | 1138 | |
| 1139 | − cpumask_copy(oldmask, tsk_cpumask(current)); | |
| 1139 | + cpumask_copy(oldmask, tsk_cpus_allowed(current)); | |
| 1140 | 1140 | set_cpus_allowed_ptr(current, cpumask_of(pol->cpu)); |
| 1141 | 1141 | |
| 1142 | 1142 | if (smp_processor_id() != pol->cpu) { |
| @@ -81,7 +81,7 @@ static u8 i7300_idle_thrtctl_saved; · 80 unmodified lines | ||
| 81 | 81 | static u8 i7300_idle_thrtlow_saved; |
| 82 | 82 | static u32 i7300_idle_mc_saved; |
| 83 | 83 | |
| 84 | −static cpumask_t idle_cpumask; | |
| 84 | +static cpumask_var_t idle_cpumask; | |
| 85 | 85 | static ktime_t start_ktime; |
| 86 | 86 | static unsigned long avg_idle_us; |
| 87 | 87 | |
| @@ -459,9 +459,9 @@ static int i7300_idle_notifier(struct notifier_block *nb, unsigned long val, · 371 unmodified lines | ||
| 459 | 459 | spin_lock_irqsave(&i7300_idle_lock, flags); |
| 460 | 460 | if (val == IDLE_START) { |
| 461 | 461 | |
| 462 | − cpu_set(smp_processor_id(), idle_cpumask); | |
| 462 | + cpumask_set_cpu(smp_processor_id(), idle_cpumask); | |
| 463 | 463 | |
| 464 | − if (cpus_weight(idle_cpumask) != num_online_cpus()) | |
| 464 | + if (cpumask_weight(idle_cpumask) != num_online_cpus()) | |
| 465 | 465 | goto end; |
| 466 | 466 | |
| 467 | 467 | now_ktime = ktime_get(); |
| @@ -478,8 +478,8 @@ static int i7300_idle_notifier(struct notifier_block *nb, unsigned long val, · 10 unmodified lines | ||
| 478 | 478 | i7300_idle_ioat_start(); |
| 479 | 479 | |
| 480 | 480 | } else if (val == IDLE_END) { |
| 481 | − cpu_clear(smp_processor_id(), idle_cpumask); | |
| 482 | − if (cpus_weight(idle_cpumask) == (num_online_cpus() - 1)) { | |
| 481 | + cpumask_clear_cpu(smp_processor_id(), idle_cpumask); | |
| 482 | + if (cpumask_weight(idle_cpumask) == (num_online_cpus() - 1)) { | |
| 483 | 483 | /* First CPU coming out of idle */ |
| 484 | 484 | u64 idle_duration_us; |
| 485 | 485 | |
| @@ -553,7 +553,6 @@ struct debugfs_file_info { · 67 unmodified lines | ||
| 553 | 553 | static int __init i7300_idle_init(void) |
| 554 | 554 | { |
| 555 | 555 | spin_lock_init(&i7300_idle_lock); |
| 556 | − cpus_clear(idle_cpumask); | |
| 557 | 556 | total_us = 0; |
| 558 | 557 | |
| 559 | 558 | if (i7300_idle_platform_probe(&fbd_dev, &ioat_dev, forceload)) |
| @@ -565,6 +564,9 @@ static int __init i7300_idle_init(void) · 5 unmodified lines | ||
| 565 | 564 | if (i7300_idle_ioat_init()) |
| 566 | 565 | return -ENODEV; |
| 567 | 566 | |
| 567 | + if (!zalloc_cpumask_var(&idle_cpumask, GFP_KERNEL)) | |
| 568 | + return -ENOMEM; | |
| 569 | + | |
| 568 | 570 | debugfs_dir = debugfs_create_dir("i7300_idle", NULL); |
| 569 | 571 | if (debugfs_dir) { |
| 570 | 572 | int i = 0; |
| @@ -589,6 +591,7 @@ static int __init i7300_idle_init(void) · 18 unmodified lines | ||
| 589 | 591 | static void __exit i7300_idle_exit(void) |
| 590 | 592 | { |
| 591 | 593 | idle_notifier_unregister(&i7300_idle_nb); |
| 594 | + free_cpumask_var(idle_cpumask); | |
| 592 | 595 | |
| 593 | 596 | if (debugfs_dir) { |
| 594 | 597 | int i = 0; |
| @@ -1260,7 +1260,7 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, · 1259 unmodified lines | ||
| 1260 | 1260 | "CPU.\n"); |
| 1261 | 1261 | |
| 1262 | 1262 | spin_unlock_bh(&fps->fcoe_rx_list.lock); |
| 1263 | − cpu = first_cpu(cpu_online_map); | |
| 1263 | + cpu = cpumask_first(cpu_online_mask); | |
| 1264 | 1264 | fps = &per_cpu(fcoe_percpu, cpu); |
| 1265 | 1265 | spin_lock_bh(&fps->fcoe_rx_list.lock); |
| 1266 | 1266 | if (!fps->thread) { |
| @@ -1553,7 +1553,7 @@ struct task_struct { · 1552 unmodified lines | ||
| 1553 | 1553 | }; |
| 1554 | 1554 | |
| 1555 | 1555 | /* Future-safe accessor for struct task_struct's cpus_allowed. */ |
| 1556 | −#define tsk_cpumask(tsk) (&(tsk)->cpus_allowed) | |
| 1556 | +#define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed) | |
| 1557 | 1557 | |
| 1558 | 1558 | /* |
| 1559 | 1559 | * Priority of a process goes from 0..MAX_PRIO-1, valid RT |
| @@ -1614,7 +1614,7 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu) · 1613 unmodified lines | ||
| 1614 | 1614 | * offline CPU and activate it when the CPU comes up, but |
| 1615 | 1615 | * that's for later. |
| 1616 | 1616 | */ |
| 1617 | − if (!cpu_isset(cpu, cpu_online_map)) | |
| 1617 | + if (!cpu_online(cpu)) | |
| 1618 | 1618 | return ERR_PTR(-ENODEV); |
| 1619 | 1619 | |
| 1620 | 1620 | cpuctx = &per_cpu(perf_cpu_context, cpu); |
| @@ -237,10 +237,10 @@ static void timer_list_show_tickdevices(struct seq_file *m) · 236 unmodified lines | ||
| 237 | 237 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST |
| 238 | 238 | print_tickdevice(m, tick_get_broadcast_device(), -1); |
| 239 | 239 | SEQ_printf(m, "tick_broadcast_mask: %08lx\n", |
| 240 | − tick_get_broadcast_mask()->bits[0]); | |
| 240 | + cpumask_bits(tick_get_broadcast_mask())[0]); | |
| 241 | 241 | #ifdef CONFIG_TICK_ONESHOT |
| 242 | 242 | SEQ_printf(m, "tick_broadcast_oneshot_mask: %08lx\n", |
| 243 | − tick_get_broadcast_oneshot_mask()->bits[0]); | |
| 243 | + cpumask_bits(tick_get_broadcast_oneshot_mask())[0]); | |
| 244 | 244 | #endif |
| 245 | 245 | SEQ_printf(m, "\n"); |
| 246 | 246 | #endif |
| @@ -1132,7 +1132,7 @@ static void __cpuinit cpuup_canceled(long cpu) · 1131 unmodified lines | ||
| 1132 | 1132 | if (nc) |
| 1133 | 1133 | free_block(cachep, nc->entry, nc->avail, node); |
| 1134 | 1134 | |
| 1135 | − if (!cpus_empty(*mask)) { | |
| 1135 | + if (!cpumask_empty(mask)) { | |
| 1136 | 1136 | spin_unlock_irq(&l3->list_lock); |
| 1137 | 1137 | goto free_array_cache; |
| 1138 | 1138 | } |