Skip to content

Commit 9ec4fa2

Browse files
Yinghai LuIngo Molnar
authored andcommitted
irq, cpumask: correct CPUMASKS_OFFSTACK typo and fix fallout
CPUMASKS_OFFSTACK is not defined anywhere (it is CPUMASK_OFFSTACK). It is a typo and init_allocate_desc_masks() is called before it set affinity to all cpus... Split init_alloc_desc_masks() into all_desc_masks() and init_desc_masks(). Also use CPUMASK_OFFSTACK in alloc_desc_masks(). [ Impact: fix smp_affinity copying/setup when moving irq_desc between CPUs ] Signed-off-by: Yinghai Lu <yinghai@kernel.org> Acked-by: Rusty Russell <rusty@rustcorp.com.au> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Suresh Siddha <suresh.b.siddha@intel.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> LKML-Reference: <49F6546E.3040406@kernel.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent e25c2c8 commit 9ec4fa2

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

‎include/linux/irq.h‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,27 +424,25 @@ extern int set_irq_msi(unsigned int irq, struct msi_desc *entry);
424424

425425
#ifdef CONFIG_SMP
426426
/**
427-
* init_alloc_desc_masks - allocate cpumasks for irq_desc
427+
* alloc_desc_masks - allocate cpumasks for irq_desc
428428
* @desc: pointer to irq_desc struct
429429
* @cpu: cpu which will be handling the cpumasks
430430
* @boot: true if need bootmem
431431
*
432432
* Allocates affinity and pending_mask cpumask if required.
433433
* Returns true if successful (or not required).
434-
* Side effect: affinity has all bits set, pending_mask has all bits clear.
435434
*/
436-
static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu,
435+
static inline bool alloc_desc_masks(struct irq_desc *desc, int cpu,
437436
bool boot)
438437
{
438+
#ifdef CONFIG_CPUMASK_OFFSTACK
439439
int node;
440440

441441
if (boot) {
442442
alloc_bootmem_cpumask_var(&desc->affinity);
443-
cpumask_setall(desc->affinity);
444443

445444
#ifdef CONFIG_GENERIC_PENDING_IRQ
446445
alloc_bootmem_cpumask_var(&desc->pending_mask);
447-
cpumask_clear(desc->pending_mask);
448446
#endif
449447
return true;
450448
}
@@ -453,18 +451,25 @@ static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu,
453451

454452
if (!alloc_cpumask_var_node(&desc->affinity, GFP_ATOMIC, node))
455453
return false;
456-
cpumask_setall(desc->affinity);
457454

458455
#ifdef CONFIG_GENERIC_PENDING_IRQ
459456
if (!alloc_cpumask_var_node(&desc->pending_mask, GFP_ATOMIC, node)) {
460457
free_cpumask_var(desc->affinity);
461458
return false;
462459
}
463-
cpumask_clear(desc->pending_mask);
460+
#endif
464461
#endif
465462
return true;
466463
}
467464

465+
static inline void init_desc_masks(struct irq_desc *desc)
466+
{
467+
cpumask_setall(desc->affinity);
468+
#ifdef CONFIG_GENERIC_PENDING_IRQ
469+
cpumask_clear(desc->pending_mask);
470+
#endif
471+
}
472+
468473
/**
469474
* init_copy_desc_masks - copy cpumasks for irq_desc
470475
* @old_desc: pointer to old irq_desc struct
@@ -478,7 +483,7 @@ static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu,
478483
static inline void init_copy_desc_masks(struct irq_desc *old_desc,
479484
struct irq_desc *new_desc)
480485
{
481-
#ifdef CONFIG_CPUMASKS_OFFSTACK
486+
#ifdef CONFIG_CPUMASK_OFFSTACK
482487
cpumask_copy(new_desc->affinity, old_desc->affinity);
483488

484489
#ifdef CONFIG_GENERIC_PENDING_IRQ
@@ -499,12 +504,16 @@ static inline void free_desc_masks(struct irq_desc *old_desc,
499504

500505
#else /* !CONFIG_SMP */
501506

502-
static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu,
507+
static inline bool alloc_desc_masks(struct irq_desc *desc, int cpu,
503508
bool boot)
504509
{
505510
return true;
506511
}
507512

513+
static inline void init_desc_masks(struct irq_desc *desc)
514+
{
515+
}
516+
508517
static inline void init_copy_desc_masks(struct irq_desc *old_desc,
509518
struct irq_desc *new_desc)
510519
{

‎kernel/irq/handle.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu)
115115
printk(KERN_ERR "can not alloc kstat_irqs\n");
116116
BUG_ON(1);
117117
}
118-
if (!init_alloc_desc_masks(desc, cpu, false)) {
118+
if (!alloc_desc_masks(desc, cpu, false)) {
119119
printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
120120
BUG_ON(1);
121121
}
122+
init_desc_masks(desc);
122123
arch_init_chip_data(desc, cpu);
123124
}
124125

@@ -169,7 +170,8 @@ int __init early_irq_init(void)
169170
desc[i].irq = i;
170171
desc[i].kstat_irqs = kstat_irqs_legacy + i * nr_cpu_ids;
171172
lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
172-
init_alloc_desc_masks(&desc[i], 0, true);
173+
alloc_desc_masks(&desc[i], 0, true);
174+
init_desc_masks(&desc[i]);
173175
irq_desc_ptrs[i] = desc + i;
174176
}
175177

@@ -256,7 +258,8 @@ int __init early_irq_init(void)
256258

257259
for (i = 0; i < count; i++) {
258260
desc[i].irq = i;
259-
init_alloc_desc_masks(&desc[i], 0, true);
261+
alloc_desc_masks(&desc[i], 0, true);
262+
init_desc_masks(&desc[i]);
260263
desc[i].kstat_irqs = kstat_irqs_all[i];
261264
}
262265
return arch_early_irq_init();

‎kernel/irq/numa_migrate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static bool init_copy_one_irq_desc(int irq, struct irq_desc *old_desc,
3737
struct irq_desc *desc, int cpu)
3838
{
3939
memcpy(desc, old_desc, sizeof(struct irq_desc));
40-
if (!init_alloc_desc_masks(desc, cpu, false)) {
40+
if (!alloc_desc_masks(desc, cpu, false)) {
4141
printk(KERN_ERR "irq %d: can not get new irq_desc cpumask "
4242
"for migration.\n", irq);
4343
return false;

0 commit comments

Comments
 (0)