Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'cpumask-cleanups' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus

* '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

+33 -45
+17 -32
Documentation/cpu-hotplug.txt
··· 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
+1 -1
arch/x86/kernel/cpu/cpufreq/powernow-k8.c
··· 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) {
+9 -6
drivers/idle/i7300_idle.c
··· 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 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 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 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)) ··· 563 564 564 565 if (i7300_idle_ioat_init()) 565 566 return -ENODEV; 567 + 568 + if (!zalloc_cpumask_var(&idle_cpumask, GFP_KERNEL)) 569 + return -ENOMEM; 566 570 567 571 debugfs_dir = debugfs_create_dir("i7300_idle", NULL); 568 572 if (debugfs_dir) { ··· 591 589 static void __exit i7300_idle_exit(void) 592 590 { 593 591 idle_notifier_unregister(&i7300_idle_nb); 592 + free_cpumask_var(idle_cpumask); 594 593 595 594 if (debugfs_dir) { 596 595 int i = 0;
+1 -1
drivers/scsi/fcoe/fcoe.c
··· 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) {
+1 -1
include/linux/sched.h
··· 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
+1 -1
kernel/perf_event.c
··· 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);
+2 -2
kernel/time/timer_list.c
··· 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
+1 -1
mm/slab.c
··· 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 }