Skip to content

Commit 55db493

Browse files
committed
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
2 parents efc8e7f + a463681 commit 55db493

8 files changed

Lines changed: 33 additions & 45 deletions

File tree

‎Documentation/cpu-hotplug.txt‎

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -315,41 +315,26 @@ A: The following are what is required for CPU hotplug infrastructure to work
315315

316316
Q: I need to ensure that a particular cpu is not removed when there is some
317317
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:
319321

320322
int my_func_on_cpu(int cpu)
321323
{
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+
}
353338

354339
Q: How do we determine how many CPUs are available for hotplug.
355340
A: There is no clear spec defined way from ACPI that can give us that

‎arch/x86/kernel/cpu/cpufreq/powernow-k8.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ static int powernowk8_target(struct cpufreq_policy *pol,
11361136
if (!alloc_cpumask_var(&oldmask, GFP_KERNEL))
11371137
return -ENOMEM;
11381138

1139-
cpumask_copy(oldmask, tsk_cpumask(current));
1139+
cpumask_copy(oldmask, tsk_cpus_allowed(current));
11401140
set_cpus_allowed_ptr(current, cpumask_of(pol->cpu));
11411141

11421142
if (smp_processor_id() != pol->cpu) {

‎drivers/idle/i7300_idle.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static u8 i7300_idle_thrtctl_saved;
8181
static u8 i7300_idle_thrtlow_saved;
8282
static u32 i7300_idle_mc_saved;
8383

84-
static cpumask_t idle_cpumask;
84+
static cpumask_var_t idle_cpumask;
8585
static ktime_t start_ktime;
8686
static unsigned long avg_idle_us;
8787

@@ -459,9 +459,9 @@ static int i7300_idle_notifier(struct notifier_block *nb, unsigned long val,
459459
spin_lock_irqsave(&i7300_idle_lock, flags);
460460
if (val == IDLE_START) {
461461

462-
cpu_set(smp_processor_id(), idle_cpumask);
462+
cpumask_set_cpu(smp_processor_id(), idle_cpumask);
463463

464-
if (cpus_weight(idle_cpumask) != num_online_cpus())
464+
if (cpumask_weight(idle_cpumask) != num_online_cpus())
465465
goto end;
466466

467467
now_ktime = ktime_get();
@@ -478,8 +478,8 @@ static int i7300_idle_notifier(struct notifier_block *nb, unsigned long val,
478478
i7300_idle_ioat_start();
479479

480480
} 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)) {
483483
/* First CPU coming out of idle */
484484
u64 idle_duration_us;
485485

@@ -553,7 +553,6 @@ struct debugfs_file_info {
553553
static int __init i7300_idle_init(void)
554554
{
555555
spin_lock_init(&i7300_idle_lock);
556-
cpus_clear(idle_cpumask);
557556
total_us = 0;
558557

559558
if (i7300_idle_platform_probe(&fbd_dev, &ioat_dev, forceload))
@@ -565,6 +564,9 @@ static int __init i7300_idle_init(void)
565564
if (i7300_idle_ioat_init())
566565
return -ENODEV;
567566

567+
if (!zalloc_cpumask_var(&idle_cpumask, GFP_KERNEL))
568+
return -ENOMEM;
569+
568570
debugfs_dir = debugfs_create_dir("i7300_idle", NULL);
569571
if (debugfs_dir) {
570572
int i = 0;
@@ -589,6 +591,7 @@ static int __init i7300_idle_init(void)
589591
static void __exit i7300_idle_exit(void)
590592
{
591593
idle_notifier_unregister(&i7300_idle_nb);
594+
free_cpumask_var(idle_cpumask);
592595

593596
if (debugfs_dir) {
594597
int i = 0;

‎drivers/scsi/fcoe/fcoe.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
12601260
"CPU.\n");
12611261

12621262
spin_unlock_bh(&fps->fcoe_rx_list.lock);
1263-
cpu = first_cpu(cpu_online_map);
1263+
cpu = cpumask_first(cpu_online_mask);
12641264
fps = &per_cpu(fcoe_percpu, cpu);
12651265
spin_lock_bh(&fps->fcoe_rx_list.lock);
12661266
if (!fps->thread) {

‎include/linux/sched.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ struct task_struct {
15531553
};
15541554

15551555
/* 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)
15571557

15581558
/*
15591559
* Priority of a process goes from 0..MAX_PRIO-1, valid RT

‎kernel/perf_event.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu)
16141614
* offline CPU and activate it when the CPU comes up, but
16151615
* that's for later.
16161616
*/
1617-
if (!cpu_isset(cpu, cpu_online_map))
1617+
if (!cpu_online(cpu))
16181618
return ERR_PTR(-ENODEV);
16191619

16201620
cpuctx = &per_cpu(perf_cpu_context, cpu);

‎kernel/time/timer_list.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ static void timer_list_show_tickdevices(struct seq_file *m)
237237
#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
238238
print_tickdevice(m, tick_get_broadcast_device(), -1);
239239
SEQ_printf(m, "tick_broadcast_mask: %08lx\n",
240-
tick_get_broadcast_mask()->bits[0]);
240+
cpumask_bits(tick_get_broadcast_mask())[0]);
241241
#ifdef CONFIG_TICK_ONESHOT
242242
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]);
244244
#endif
245245
SEQ_printf(m, "\n");
246246
#endif

‎mm/slab.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ static void __cpuinit cpuup_canceled(long cpu)
11321132
if (nc)
11331133
free_block(cachep, nc->entry, nc->avail, node);
11341134

1135-
if (!cpus_empty(*mask)) {
1135+
if (!cpumask_empty(mask)) {
11361136
spin_unlock_irq(&l3->list_lock);
11371137
goto free_array_cache;
11381138
}

0 commit comments

Comments
 (0)