Skip to contentSkip to conversation

cpumask: more cpumask updates

PATCH In review Mike Travis 7 participants 31 messages Jan 7, 2009 – Jan 27, 2009 1 message not in the archive

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

cover cpumask: more cpumask updates

One big change to irq_desc and a few smaller maintenance type updates.

cpumask: update irq_desc to use cpumask_var_t
cpumask: Use topology_core_cpumask()/topology_thread_cpumask()
cpumask: convert misc driver functions
cpumask: convert drivers/net/sfc
cpumask: convert other misc kernel functions

Based on tip/cpus4096: v2.6.28-5703-g1d1a70e

(Ingo - I added a blank line before the From: part and that seems to separate it from the Subject. Hopefully your git-am will still recognizes it - I did try a git-am here and it seemed to work ok.)

#1 lore raw

PATCH 1/5 cpumask: update irq_desc to use cpumask_var_t

Impact: reduce memory usage, use new cpumask API.

Replace the affinity and pending_masks with cpumask_var_t's. This adds to the significant size reduction done with the SPARSE_IRQS changes.

The added functions (init_alloc_desc_masks & init_copy_desc_masks) are in the include file so they can be inlined (and optimized out for the !CONFIG_CPUMASKS_OFFSTACK case.) [Naming chosen to be consistent with the other init*irq functions, as well as the backwards arg declaration of "from, to" instead of the more common "to, from" standard.]

Includes a slight change to the declaration of struct irq_desc to embed the pending_mask within ifdef(CONFIG_SMP) to be consistent with other references, and some small changes to Xen.

Tested: sparse/non-sparse/cpumask_offstack/non-cpumask_offstack/nonuma/nosmp on x86_64

Cc Chris Wright <[email protected]>
Cc Jeremy Fitzhardinge <[email protected]>
Cc KOSAKI Motohiro <[email protected]>
Cc Venkatesh Pallipadi <[email protected]>
Cc Yinghai Lu <[email protected]>
---
 arch/x86/kernel/io_apic.c |   20 +++++------
 arch/x86/kernel/irq_32.c  |    2 -
 arch/x86/kernel/irq_64.c  |    2 -
 drivers/xen/events.c      |    4 +-
 include/linux/irq.h       |   81 ++++++++++++++++++++++++++++++++++++++++++++--
 kernel/irq/chip.c         |    5 ++
 kernel/irq/handle.c       |   26 +++++++-------
 kernel/irq/manage.c       |   12 +++---
 kernel/irq/migration.c    |   12 +++---
 kernel/irq/numa_migrate.c |   12 ++++++
 kernel/irq/proc.c         |    4 +-
 11 files changed, 135 insertions(+), 45 deletions(-)
arch/x86/kernel/io_apic.c +10 -10
@@ -358,7 +358,7 @@ set_extra_move_desc(struct irq_desc *des
 
 	if (!cfg->move_in_progress) {
 		/* it means that domain is not changed */
-		if (!cpumask_intersects(&desc->affinity, mask))
+		if (!cpumask_intersects(desc->affinity, mask))
 			cfg->move_desc_pending = 1;
 	}
 }
@@ -581,9 +581,9 @@ set_desc_affinity(struct irq_desc *desc,
 	if (assign_irq_vector(irq, cfg, mask))
 		return BAD_APICID;
 
-	cpumask_and(&desc->affinity, cfg->domain, mask);
+	cpumask_and(desc->affinity, cfg->domain, mask);
 	set_extra_move_desc(desc, mask);
-	return cpu_mask_to_apicid_and(&desc->affinity, cpu_online_mask);
+	return cpu_mask_to_apicid_and(desc->affinity, cpu_online_mask);
 }
 
 static void
@@ -2385,7 +2385,7 @@ migrate_ioapic_irq_desc(struct irq_desc 
 	if (cfg->move_in_progress)
 		send_cleanup_vector(cfg);
 
-	cpumask_copy(&desc->affinity, mask);
+	cpumask_copy(desc->affinity, mask);
 }
 
 static int migrate_irq_remapped_level_desc(struct irq_desc *desc)
@@ -2407,11 +2407,11 @@ static int migrate_irq_remapped_level_de
 	}
 
 	/* everthing is clear. we have right of way */
-	migrate_ioapic_irq_desc(desc, &desc->pending_mask);
+	migrate_ioapic_irq_desc(desc, desc->pending_mask);
 
 	ret = 0;
 	desc->status &= ~IRQ_MOVE_PENDING;
-	cpumask_clear(&desc->pending_mask);
+	cpumask_clear(desc->pending_mask);
 
 unmask:
 	unmask_IO_APIC_irq_desc(desc);
@@ -2436,7 +2436,7 @@ static void ir_irq_migration(struct work
 				continue;
 			}
 
-			desc->chip->set_affinity(irq, &desc->pending_mask);
+			desc->chip->set_affinity(irq, desc->pending_mask);
 			spin_unlock_irqrestore(&desc->lock, flags);
 		}
 	}
@@ -2450,7 +2450,7 @@ static void set_ir_ioapic_affinity_irq_d
 {
 	if (desc->status & IRQ_LEVEL) {
 		desc->status |= IRQ_MOVE_PENDING;
-		cpumask_copy(&desc->pending_mask, mask);
+		cpumask_copy(desc->pending_mask, mask);
 		migrate_irq_remapped_level_desc(desc);
 		return;
 	}
@@ -2518,7 +2518,7 @@ static void irq_complete_move(struct irq
 
 		/* domain has not changed, but affinity did */
 		me = smp_processor_id();
-		if (cpu_isset(me, desc->affinity)) {
+		if (cpumask_test_cpu(me, desc->affinity)) {
 			*descp = desc = move_irq_desc(desc, me);
 			/* get the new one */
 			cfg = desc->chip_data;
@@ -4041,7 +4041,7 @@ void __init setup_ioapic_dest(void)
 			 */
 			if (desc->status &
 			    (IRQ_NO_BALANCING | IRQ_AFFINITY_SET))
-				mask = &desc->affinity;
+				mask = desc->affinity;
 			else
 				mask = TARGET_CPUS;
 
arch/x86/kernel/irq_32.c +1 -1
@@ -248,7 +248,7 @@ void fixup_irqs(void)
 		if (irq == 2)
 			continue;
 
-		affinity = &desc->affinity;
+		affinity = desc->affinity;
 		if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
 			printk("Breaking affinity for irq %i\n", irq);
 			affinity = cpu_all_mask;
arch/x86/kernel/irq_64.c +1 -1
@@ -100,7 +100,7 @@ void fixup_irqs(void)
 		/* interrupt's are disabled at this point */
 		spin_lock(&desc->lock);
 
-		affinity = &desc->affinity;
+		affinity = desc->affinity;
 		if (!irq_has_action(irq) ||
 		    cpumask_equal(affinity, cpu_online_mask)) {
 			spin_unlock(&desc->lock);
drivers/xen/events.c +2 -2
@@ -125,7 +125,7 @@ static void bind_evtchn_to_cpu(unsigned 
 
 	BUG_ON(irq == -1);
 #ifdef CONFIG_SMP
-	irq_to_desc(irq)->affinity = cpumask_of_cpu(cpu);
+	cpumask_copy(irq_to_desc(irq)->affinity, cpumask_of(cpu));
 #endif
 
 	__clear_bit(chn, cpu_evtchn_mask[cpu_evtchn[chn]]);
@@ -142,7 +142,7 @@ static void init_evtchn_cpu_bindings(voi
 
 	/* By default all event channels notify CPU#0. */
 	for_each_irq_desc(i, desc) {
-		desc->affinity = cpumask_of_cpu(0);
+		cpumask_copy(desc->affinity, cpumask_of(0));
 	}
 #endif
 
include/linux/irq.h +78 -3

93 lines not on this page · raw message

kernel/irq/chip.c +4 -1
@@ -46,7 +46,10 @@ void dynamic_irq_init(unsigned int irq)
 	desc->irq_count = 0;
 	desc->irqs_unhandled = 0;
 #ifdef CONFIG_SMP
-	cpumask_setall(&desc->affinity);
+	cpumask_setall(desc->affinity);
+#ifdef CONFIG_GENERIC_PENDING_IRQ
+	cpumask_clear(desc->pending_mask);
+#endif
 #endif
 	spin_unlock_irqrestore(&desc->lock, flags);
 }
kernel/irq/handle.c +14 -12
@@ -64,9 +64,6 @@ static struct irq_desc irq_desc_init = {
 	.handle_irq = handle_bad_irq,
 	.depth      = 1,
 	.lock       = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
-#ifdef CONFIG_SMP
-	.affinity   = CPU_MASK_ALL
-#endif
 };
 
 void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
@@ -88,6 +85,8 @@ void init_kstat_irqs(struct irq_desc *de
 
 static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu)
 {
+	int node = cpu_to_node(cpu);
+
 	memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
 
 	spin_lock_init(&desc->lock);
@@ -101,6 +100,10 @@ static void init_one_irq_desc(int irq, s
 		printk(KERN_ERR "can not alloc kstat_irqs\n");
 		BUG_ON(1);
 	}
+	if (!init_alloc_desc_masks(desc, node, false)) {
+		printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
+		BUG_ON(1);
+	}
 	arch_init_chip_data(desc, cpu);
 }
 
@@ -119,9 +122,6 @@ static struct irq_desc irq_desc_legacy[N
 		.handle_irq = handle_bad_irq,
 		.depth	    = 1,
 		.lock	    = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
-#ifdef CONFIG_SMP
-		.affinity   = CPU_MASK_ALL
-#endif
 	}
 };
 
@@ -141,7 +141,7 @@ int __init early_irq_init(void)
 		desc[i].irq = i;
 		desc[i].kstat_irqs = kstat_irqs_legacy[i];
 		lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
-
+		init_alloc_desc_masks(&desc[i], 0, true);
 		irq_desc_ptrs[i] = desc + i;
 	}
 
@@ -188,6 +188,10 @@ struct irq_desc *irq_to_desc_alloc_cpu(u
 		printk(KERN_ERR "can not alloc irq_desc\n");
 		BUG_ON(1);
 	}
+	if (!init_alloc_desc_masks(desc, node, false)) {
+		printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
+		BUG_ON(1);
+	}
 	init_one_irq_desc(irq, desc, cpu);
 
 	irq_desc_ptrs[irq] = desc;
@@ -207,9 +211,6 @@ struct irq_desc irq_desc[NR_IRQS] __cach
 		.handle_irq = handle_bad_irq,
 		.depth = 1,
 		.lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
-#ifdef CONFIG_SMP
-		.affinity = CPU_MASK_ALL
-#endif
 	}
 };
 
@@ -222,9 +223,10 @@ int __init early_irq_init(void)
 	desc = irq_desc;
 	count = ARRAY_SIZE(irq_desc);
 
-	for (i = 0; i < count; i++)
+	for (i = 0; i < count; i++) {
 		desc[i].irq = i;
-
+		init_alloc_desc_masks(&desc[i], 0, true);
+	}
 	return arch_early_irq_init();
 }
 
kernel/irq/manage.c +6 -6
@@ -98,14 +98,14 @@ int irq_set_affinity(unsigned int irq, c
 
 #ifdef CONFIG_GENERIC_PENDING_IRQ
 	if (desc->status & IRQ_MOVE_PCNTXT || desc->status & IRQ_DISABLED) {
-		cpumask_copy(&desc->affinity, cpumask);
+		cpumask_copy(desc->affinity, cpumask);
 		desc->chip->set_affinity(irq, cpumask);
 	} else {
 		desc->status |= IRQ_MOVE_PENDING;
-		cpumask_copy(&desc->pending_mask, cpumask);
+		cpumask_copy(desc->pending_mask, cpumask);
 	}
 #else
-	cpumask_copy(&desc->affinity, cpumask);
+	cpumask_copy(desc->affinity, cpumask);
 	desc->chip->set_affinity(irq, cpumask);
 #endif
 	desc->status |= IRQ_AFFINITY_SET;
@@ -127,16 +127,16 @@ int do_irq_select_affinity(unsigned int 
 	 * one of the targets is online.
 	 */
 	if (desc->status & (IRQ_AFFINITY_SET | IRQ_NO_BALANCING)) {
-		if (cpumask_any_and(&desc->affinity, cpu_online_mask)
+		if (cpumask_any_and(desc->affinity, cpu_online_mask)
 		    < nr_cpu_ids)
 			goto set_affinity;
 		else
 			desc->status &= ~IRQ_AFFINITY_SET;
 	}
 
-	cpumask_and(&desc->affinity, cpu_online_mask, irq_default_affinity);
+	cpumask_and(desc->affinity, cpu_online_mask, irq_default_affinity);
 set_affinity:
-	desc->chip->set_affinity(irq, &desc->affinity);
+	desc->chip->set_affinity(irq, desc->affinity);
 
 	return 0;
 }
kernel/irq/migration.c +6 -6
@@ -18,7 +18,7 @@ void move_masked_irq(int irq)
 
 	desc->status &= ~IRQ_MOVE_PENDING;
 
-	if (unlikely(cpumask_empty(&desc->pending_mask)))
+	if (unlikely(cpumask_empty(desc->pending_mask)))
 		return;
 
 	if (!desc->chip->set_affinity)
@@ -38,13 +38,13 @@ void move_masked_irq(int irq)
 	 * For correct operation this depends on the caller
 	 * masking the irqs.
 	 */
-	if (likely(cpumask_any_and(&desc->pending_mask, cpu_online_mask)
+	if (likely(cpumask_any_and(desc->pending_mask, cpu_online_mask)
 		   < nr_cpu_ids)) {
-		cpumask_and(&desc->affinity,
-			    &desc->pending_mask, cpu_online_mask);
-		desc->chip->set_affinity(irq, &desc->affinity);
+		cpumask_and(desc->affinity,
+			    desc->pending_mask, cpu_online_mask);
+		desc->chip->set_affinity(irq, desc->affinity);
 	}
-	cpumask_clear(&desc->pending_mask);
+	cpumask_clear(desc->pending_mask);
 }
 
 void move_native_irq(int irq)
kernel/irq/numa_migrate.c +11 -1
@@ -46,6 +46,7 @@ static void init_copy_one_irq_desc(int i
 	desc->cpu = cpu;
 	lockdep_set_class(&desc->lock, &irq_desc_lock_class);
 	init_copy_kstat_irqs(old_desc, desc, cpu, nr_cpu_ids);
+	init_copy_desc_masks(old_desc, desc);
 	arch_init_copy_chip_data(old_desc, desc, cpu);
 }
 
@@ -76,11 +77,20 @@ static struct irq_desc *__real_move_irq_
 	node = cpu_to_node(cpu);
 	desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
 	if (!desc) {
-		printk(KERN_ERR "irq %d: can not get new irq_desc for migration.\n", irq);
+		printk(KERN_ERR "irq %d: can not get new irq_desc "
+				"for migration.\n", irq);
 		/* still use old one */
 		desc = old_desc;
 		goto out_unlock;
 	}
+	if (!init_alloc_desc_masks(desc, node, false)) {
+		printk(KERN_ERR "irq %d: can not get new irq_desc cpumask "
+				"for migration.\n", irq);
+		/* still use old one */
+		kfree(desc);
+		desc = old_desc;
+		goto out_unlock;
+	}
 	init_copy_one_irq_desc(irq, old_desc, desc, cpu);
 
 	irq_desc_ptrs[irq] = desc;
kernel/irq/proc.c +2 -2
@@ -20,11 +20,11 @@ static struct proc_dir_entry *root_irq_d
 static int irq_affinity_proc_show(struct seq_file *m, void *v)
 {
 	struct irq_desc *desc = irq_to_desc((long)m->private);
-	const struct cpumask *mask = &desc->affinity;
+	const struct cpumask *mask = desc->affinity;
 
 #ifdef CONFIG_GENERIC_PENDING_IRQ
 	if (desc->status & IRQ_MOVE_PENDING)
-		mask = &desc->pending_mask;
+		mask = desc->pending_mask;
 #endif
 	seq_cpumask(m, mask);
 	seq_putc(m, '\n');
#2 lore raw

Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t

On Wed, Jan 7, 2009 at 11:58 AM, Mike Travis <[email protected]> wrote:

| --- linux-2.6-for-ingo.orig/kernel/irq/numa_migrate.c
| +++ linux-2.6-for-ingo/kernel/irq/numa_migrate.c
| @@ -46,6 +46,7 @@ static void init_copy_one_irq_desc(int i
| 	desc->cpu = cpu;
| 	lockdep_set_class(&desc->lock, &irq_desc_lock_class);
| 	init_copy_kstat_irqs(old_desc, desc, cpu, nr_cpu_ids);
|+	init_copy_desc_masks(old_desc, desc);
| 	arch_init_copy_chip_data(old_desc, desc, cpu);
| }
|
|@@ -76,11 +77,20 @@ static struct irq_desc *__real_move_irq_
| 	node = cpu_to_node(cpu);
| 	desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
| 	if (!desc) {
|-		printk(KERN_ERR "irq %d: can not get new irq_desc for migration.\n", irq);
|+		printk(KERN_ERR "irq %d: can not get new irq_desc "
|+				"for migration.\n", irq);
| 		/* still use old one */
| 		desc = old_desc;
| 		goto out_unlock;
| 	}
|+	if (!init_alloc_desc_masks(desc, node, false)) {
|+		printk(KERN_ERR "irq %d: can not get new irq_desc cpumask "
|+				"for migration.\n", irq);
|+		/* still use old one */
|+		kfree(desc);
|+		desc = old_desc;
|+		goto out_unlock;
|+	}
| 	init_copy_one_irq_desc(irq, old_desc, desc, cpu);

desc new mask_var (allocated) aka the pointer is overwritten here... you may need to calling move init_alloc_desc_masks() into init_copy_one_irq_desc()

| irq_desc_ptrs[irq] = desc;

YH

#3 lore raw

Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t

Quoted 32 lines · Yinghai Lu

On Wed, Jan 7, 2009 at 11:58 AM, Mike Travis <[email protected]> wrote:

| --- linux-2.6-for-ingo.orig/kernel/irq/numa_migrate.c
| +++ linux-2.6-for-ingo/kernel/irq/numa_migrate.c
| @@ -46,6 +46,7 @@ static void init_copy_one_irq_desc(int i
| 	desc->cpu = cpu;
| 	lockdep_set_class(&desc->lock, &irq_desc_lock_class);
| 	init_copy_kstat_irqs(old_desc, desc, cpu, nr_cpu_ids);
|+	init_copy_desc_masks(old_desc, desc);
| 	arch_init_copy_chip_data(old_desc, desc, cpu);
| }
|
|@@ -76,11 +77,20 @@ static struct irq_desc *__real_move_irq_
| 	node = cpu_to_node(cpu);
| 	desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
| 	if (!desc) {
|-		printk(KERN_ERR "irq %d: can not get new irq_desc for migration.\n", irq);
|+		printk(KERN_ERR "irq %d: can not get new irq_desc "
|+				"for migration.\n", irq);
| 		/* still use old one */
| 		desc = old_desc;
| 		goto out_unlock;
| 	}
|+	if (!init_alloc_desc_masks(desc, node, false)) {
|+		printk(KERN_ERR "irq %d: can not get new irq_desc cpumask "
|+				"for migration.\n", irq);
|+		/* still use old one */
|+		kfree(desc);
|+		desc = old_desc;
|+		goto out_unlock;
|+	}
| 	init_copy_one_irq_desc(irq, old_desc, desc, cpu);
Quoted 3 lines

desc new mask_var (allocated) aka the pointer is overwritten here... you may need to calling move init_alloc_desc_masks() into init_copy_one_irq_desc()

Wouldn't this in init_copy_one_irq_desc() take care of that?

@@ -46,6 +46,7 @@ static void init_copy_one_irq_desc(int i

        desc->cpu = cpu;
        lockdep_set_class(&desc->lock, &irq_desc_lock_class);
        init_copy_kstat_irqs(old_desc, desc, cpu, nr_cpu_ids);
+       init_copy_desc_masks(old_desc, desc);
        arch_init_copy_chip_data(old_desc, desc, cpu);

where:

static inline void init_copy_desc_masks(struct irq_desc *old_desc,
struct irq_desc *new_desc)
{

#ifdef CONFIG_CPUMASKS_OFFSTACK
        cpumask_copy(new_desc->affinity, old_desc->affinity);
#ifdef CONFIG_GENERIC_PENDING_IRQ
        cpumask_copy(new_desc->pending_mask, old_desc->pending_mask);

#endif
#endif
}

In other words if the masks are not a cpumask[1] but instead a *cpumask pointer, then the old masks are copied to the new desc/

Or am I missing your point?

Thanks!
Mike

Quoted 9 lines

| irq_desc_ptrs[irq] = desc;

YH
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw

Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t

Quoted 56 lines · Mike Travis
Quoted 32 lines · Yinghai Lu

On Wed, Jan 7, 2009 at 11:58 AM, Mike Travis <[email protected]> wrote:

| --- linux-2.6-for-ingo.orig/kernel/irq/numa_migrate.c
| +++ linux-2.6-for-ingo/kernel/irq/numa_migrate.c
| @@ -46,6 +46,7 @@ static void init_copy_one_irq_desc(int i
| 	desc->cpu = cpu;
| 	lockdep_set_class(&desc->lock, &irq_desc_lock_class);
| 	init_copy_kstat_irqs(old_desc, desc, cpu, nr_cpu_ids);
|+	init_copy_desc_masks(old_desc, desc);
| 	arch_init_copy_chip_data(old_desc, desc, cpu);
| }
|
|@@ -76,11 +77,20 @@ static struct irq_desc *__real_move_irq_
| 	node = cpu_to_node(cpu);
| 	desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
| 	if (!desc) {
|-		printk(KERN_ERR "irq %d: can not get new irq_desc for migration.\n", irq);
|+		printk(KERN_ERR "irq %d: can not get new irq_desc "
|+				"for migration.\n", irq);
| 		/* still use old one */
| 		desc = old_desc;
| 		goto out_unlock;
| 	}
|+	if (!init_alloc_desc_masks(desc, node, false)) {
|+		printk(KERN_ERR "irq %d: can not get new irq_desc cpumask "
|+				"for migration.\n", irq);
|+		/* still use old one */
|+		kfree(desc);
|+		desc = old_desc;
|+		goto out_unlock;
|+	}
| 	init_copy_one_irq_desc(irq, old_desc, desc, cpu);
Quoted 3 lines

desc new mask_var (allocated) aka the pointer is overwritten here... you may need to calling move init_alloc_desc_masks() into init_copy_one_irq_desc()

Wouldn't this in init_copy_one_irq_desc() take care of that?

kernel/irq/numa_migrate.c +1 -0
@@ -46,6 +46,7 @@ static void init_copy_one_irq_desc(int i
        desc->cpu = cpu;
        lockdep_set_class(&desc->lock, &irq_desc_lock_class);
        init_copy_kstat_irqs(old_desc, desc, cpu, nr_cpu_ids);
+       init_copy_desc_masks(old_desc, desc);
        arch_init_copy_chip_data(old_desc, desc, cpu);
 

where:

static inline void init_copy_desc_masks(struct irq_desc *old_desc,
struct irq_desc *new_desc)
{

#ifdef CONFIG_CPUMASKS_OFFSTACK
        cpumask_copy(new_desc->affinity, old_desc->affinity);
#ifdef CONFIG_GENERIC_PENDING_IRQ
        cpumask_copy(new_desc->pending_mask, old_desc->pending_mask);
Quoted 8 lines

#endif
#endif
}

In other words if the masks are not a cpumask[1] but instead a *cpumask pointer, then the old masks are copied to the new desc/

Or am I missing your point?

static void init_copy_one_irq_desc(int irq, struct irq_desc *old_desc,
struct irq_desc *desc, int cpu)

{
        memcpy(desc, old_desc, sizeof(struct irq_desc));

will overwrite new_desc->affinity and pending_mask

YH

#5 lore raw

Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t

Yinghai Lu wrote:
...

Quoted 11 lines
Quoted 1 line

Or am I missing your point?

static void init_copy_one_irq_desc(int irq, struct irq_desc *old_desc,
struct irq_desc *desc, int cpu)

{
        memcpy(desc, old_desc, sizeof(struct irq_desc));

will overwrite new_desc->affinity and pending_mask

YH

Yup, apparently I was missing your point (banging on head once more).

Thanks for spotting this!

Ingo - what's the state of tip/cpus4096? Shall I push this as an append patch, or redo the original so bisectability works.

Also, Yinghai - would you know of a straight forward way to test
the irq migration? I have taken cpus offline and back online
but wasn't sure if any irq's were being moved off of cpu 0 which cannot be taken offline.

Thanks,
Mike

#6 lore raw

Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t

Quoted 17 lines · Mike Travis

Yinghai Lu wrote:
...

Quoted 10 lines
Quoted 1 line

Or am I missing your point?

static void init_copy_one_irq_desc(int irq, struct irq_desc *old_desc,
struct irq_desc *desc, int cpu)

{
        memcpy(desc, old_desc, sizeof(struct irq_desc));

will overwrite new_desc->affinity and pending_mask

YH

Yup, apparently I was missing your point (banging on head once more).

Thanks for spotting this!

Quoted 7 lines

Ingo - what's the state of tip/cpus4096? Shall I push this as an append patch, or redo the original so bisectability works.

Also, Yinghai - would you know of a straight forward way to test
the irq migration? I have taken cpus offline and back online
but wasn't sure if any irq's were being moved off of cpu 0 which cannot be taken offline.

use echo "mask" > /proc/irq/xxx/smp_affinity to change affinity

and check /proc/interrupts and in /sys/log/messages i will said allocate new irq desc on some other node/cpu.

YH

#7 lore raw

Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t: fix

In reply to Yinghai Lu

Yinghai Lu wrote:
...

Quoted 9 lines

static void init_copy_one_irq_desc(int irq, struct irq_desc *old_desc,
struct irq_desc *desc, int cpu)

{
        memcpy(desc, old_desc, sizeof(struct irq_desc));

will overwrite new_desc->affinity and pending_mask

YH

I've appended this to the patchset:

Subject: cpumask: fix bug in use cpumask_var_t in irq_desc

Impact: fix bug where new irq_desc uses old cpumask pointers which are freed.

As Yinghai pointed out, init_copy_one_irq_desc() copies the old desc to the new desc overwriting the cpumask pointers. Since the old_desc and the cpumask pointers are freed, then memory corruption will occur if these old pointers are used.

Move the allocation of these pointers to after the copy.

---
 include/linux/irq.h       |    9 +++++++--
 kernel/irq/handle.c       |    8 +-------
 kernel/irq/numa_migrate.c |   13 ++++++++-----
 3 files changed, 16 insertions(+), 14 deletions(-)
include/linux/irq.h +7 -2
@@ -426,15 +426,18 @@ extern int set_irq_msi(unsigned int irq,
 /**
  * init_alloc_desc_masks - allocate cpumasks for irq_desc
  * @desc:	pointer to irq_desc struct
+ * @cpu:	cpu which will be handling the cpumasks
  * @boot:	true if need bootmem
  *
  * Allocates affinity and pending_mask cpumask if required.
  * Returns true if successful (or not required).
  * Side effect: affinity has all bits set, pending_mask has all bits clear.
  */
-static inline bool init_alloc_desc_masks(struct irq_desc *desc, int node,
+static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu,
 								bool boot)
 {
+	int node;
+
 	if (boot) {
 		alloc_bootmem_cpumask_var(&desc->affinity);
 		cpumask_setall(desc->affinity);
@@ -446,6 +449,8 @@ static inline bool init_alloc_desc_masks
 		return true;
 	}
 
+	node = cpu_to_node(cpu);
+
 	if (!alloc_cpumask_var_node(&desc->affinity, GFP_ATOMIC, node))
 		return false;
 	cpumask_setall(desc->affinity);
@@ -484,7 +489,7 @@ static inline void init_copy_desc_masks(
 
 #else /* !CONFIG_SMP */
 
-static inline bool init_alloc_desc_masks(struct irq_desc *desc, int node,
+static inline bool init_alloc_desc_masks(struct irq_desc *desc, int cpu,
 								bool boot)
 {
 	return true;
kernel/irq/handle.c +1 -7
@@ -85,8 +85,6 @@ void init_kstat_irqs(struct irq_desc *de
 
 static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu)
 {
-	int node = cpu_to_node(cpu);
-
 	memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
 
 	spin_lock_init(&desc->lock);
@@ -100,7 +98,7 @@ static void init_one_irq_desc(int irq, s
 		printk(KERN_ERR "can not alloc kstat_irqs\n");
 		BUG_ON(1);
 	}
-	if (!init_alloc_desc_masks(desc, node, false)) {
+	if (!init_alloc_desc_masks(desc, cpu, false)) {
 		printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
 		BUG_ON(1);
 	}
@@ -188,10 +186,6 @@ struct irq_desc *irq_to_desc_alloc_cpu(u
 		printk(KERN_ERR "can not alloc irq_desc\n");
 		BUG_ON(1);
 	}
-	if (!init_alloc_desc_masks(desc, node, false)) {
-		printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
-		BUG_ON(1);
-	}
 	init_one_irq_desc(irq, desc, cpu);
 
 	irq_desc_ptrs[irq] = desc;
kernel/irq/numa_migrate.c +8 -5
@@ -38,16 +38,22 @@ static void free_kstat_irqs(struct irq_d
 	old_desc->kstat_irqs = NULL;
 }
 
-static void init_copy_one_irq_desc(int irq, struct irq_desc *old_desc,
+static bool init_copy_one_irq_desc(int irq, struct irq_desc *old_desc,
 		 struct irq_desc *desc, int cpu)
 {
 	memcpy(desc, old_desc, sizeof(struct irq_desc));
+	if (!init_alloc_desc_masks(desc, cpu, false)) {
+		printk(KERN_ERR "irq %d: can not get new irq_desc cpumask "
+				"for migration.\n", irq);
+		return false;
+	}
 	spin_lock_init(&desc->lock);
 	desc->cpu = cpu;
 	lockdep_set_class(&desc->lock, &irq_desc_lock_class);
 	init_copy_kstat_irqs(old_desc, desc, cpu, nr_cpu_ids);
 	init_copy_desc_masks(old_desc, desc);
 	arch_init_copy_chip_data(old_desc, desc, cpu);
+	return true;
 }
 
 static void free_one_irq_desc(struct irq_desc *old_desc, struct irq_desc *desc)
@@ -83,15 +89,12 @@ static struct irq_desc *__real_move_irq_
 		desc = old_desc;
 		goto out_unlock;
 	}
-	if (!init_alloc_desc_masks(desc, node, false)) {
-		printk(KERN_ERR "irq %d: can not get new irq_desc cpumask "
-				"for migration.\n", irq);
+	if (!init_copy_one_irq_desc(irq, old_desc, desc, cpu)) {
 		/* still use old one */
 		kfree(desc);
 		desc = old_desc;
 		goto out_unlock;
 	}
-	init_copy_one_irq_desc(irq, old_desc, desc, cpu);
 
 	irq_desc_ptrs[irq] = desc;
 
#8 lore raw

PATCH 2/5 cpumask: Use topology_core_cpumask()/topology_thread_cpumask()

In reply to Mike Travis

From: Rusty Russell <[email protected]>

Impact: reduce stack usage, use new cpumask API.

This actually uses topology_core_cpumask() and topology_thread_cpumask(), removing the only users of topology_core_siblings() and topology_thread_siblings()

---
 Documentation/cputopology.txt |    6 +++---
 drivers/base/topology.c       |   35 +++++++++++++++++------------------
 drivers/net/sfc/efx.c         |    4 ++--
 include/linux/topology.h      |    6 ++++++
 4 files changed, 28 insertions(+), 23 deletions(-)
Documentation/cputopology.txt +3 -3
@@ -18,11 +18,11 @@ For an architecture to support this feat
 these macros in include/asm-XXX/topology.h:
 #define topology_physical_package_id(cpu)
 #define topology_core_id(cpu)
-#define topology_thread_siblings(cpu)
-#define topology_core_siblings(cpu)
+#define topology_thread_cpumask(cpu)
+#define topology_core_cpumask(cpu)
 
 The type of **_id is int.
-The type of siblings is cpumask_t.
+The type of siblings is (const) struct cpumask *.
 
 To be consistent on all architectures, include/linux/topology.h
 provides default definitions for any of the above macros that are
drivers/base/topology.c +17 -18
@@ -30,7 +30,10 @@
 #include <linux/module.h>
 #include <linux/topology.h>
 
-#define define_one_ro(_name) 		\
+#define define_one_ro_named(_name, _func)				\
+static SYSDEV_ATTR(_name, 0444, _func, NULL)
+
+#define define_one_ro(_name)				\
 static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
 
 #define define_id_show_func(name)				\
@@ -41,8 +44,8 @@ static ssize_t show_##name(struct sys_de
 	return sprintf(buf, "%d\n", topology_##name(cpu));	\
 }
 
-#if defined(topology_thread_siblings) || defined(topology_core_siblings)
-static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
+#if defined(topology_thread_cpumask) || defined(topology_core_cpumask)
+static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf)
 {
 	ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
 	int n = 0;
@@ -64,7 +67,7 @@ static ssize_t show_##name(struct sys_de
 			   struct sysdev_attribute *attr, char *buf)	\
 {									\
 	unsigned int cpu = dev->id;					\
-	return show_cpumap(0, &(topology_##name(cpu)), buf);		\
+	return show_cpumap(0, topology_##name(cpu), buf);		\
 }
 
 #define define_siblings_show_list(name)					\
@@ -73,7 +76,7 @@ static ssize_t show_##name##_list(struct
 				  char *buf)				\
 {									\
 	unsigned int cpu = dev->id;					\
-	return show_cpumap(1, &(topology_##name(cpu)), buf);		\
+	return show_cpumap(1, topology_##name(cpu), buf);		\
 }
 
 #else
@@ -81,9 +84,7 @@ static ssize_t show_##name##_list(struct
 static ssize_t show_##name(struct sys_device *dev,			\
 			   struct sysdev_attribute *attr, char *buf)	\
 {									\
-	unsigned int cpu = dev->id;					\
-	cpumask_t mask = topology_##name(cpu);				\
-	return show_cpumap(0, &mask, buf);				\
+	return show_cpumap(0, topology_##name(dev->id), buf);		\
 }
 
 #define define_siblings_show_list(name)					\
@@ -91,9 +92,7 @@ static ssize_t show_##name##_list(struct
 				  struct sysdev_attribute *attr,	\
 				  char *buf)				\
 {									\
-	unsigned int cpu = dev->id;					\
-	cpumask_t mask = topology_##name(cpu);				\
-	return show_cpumap(1, &mask, buf);				\
+	return show_cpumap(1, topology_##name(dev->id), buf);		\
 }
 #endif
 
@@ -106,13 +105,13 @@ define_one_ro(physical_package_id);
 define_id_show_func(core_id);
 define_one_ro(core_id);
 
-define_siblings_show_func(thread_siblings);
-define_one_ro(thread_siblings);
-define_one_ro(thread_siblings_list);
-
-define_siblings_show_func(core_siblings);
-define_one_ro(core_siblings);
-define_one_ro(core_siblings_list);
+define_siblings_show_func(thread_cpumask);
+define_one_ro_named(thread_siblings, show_thread_cpumask);
+define_one_ro_named(thread_siblings_list, show_thread_cpumask_list);
+
+define_siblings_show_func(core_cpumask);
+define_one_ro_named(core_siblings, show_core_cpumask);
+define_one_ro_named(core_siblings_list, show_core_cpumask_list);
 
 static struct attribute *default_attrs[] = {
 	&attr_physical_package_id.attr,
drivers/net/sfc/efx.c +2 -2
@@ -863,8 +863,8 @@ static int efx_wanted_rx_queues(void)
 	for_each_online_cpu(cpu) {
 		if (!cpu_isset(cpu, core_mask)) {
 			++count;
-			cpus_or(core_mask, core_mask,
-				topology_core_siblings(cpu));
+			cpumask_or(&core_mask, &core_mask,
+				   topology_core_cpumask(cpu));
 		}
 	}
 
include/linux/topology.h +6 -0
@@ -193,5 +193,11 @@ int arch_update_cpu_topology(void);
 #ifndef topology_core_siblings
 #define topology_core_siblings(cpu)		cpumask_of_cpu(cpu)
 #endif
+#ifndef topology_thread_cpumask
+#define topology_thread_cpumask(cpu)		cpumask_of(cpu)
+#endif
+#ifndef topology_core_cpumask
+#define topology_core_cpumask(cpu)		cpumask_of(cpu)
+#endif
 
 #endif /* _LINUX_TOPOLOGY_H */
Acked-by on v1 2/5
#9 lore raw

Re: [PATCH 2/5] cpumask: Use topology_core_cpumask()/topology_thread_cpumask()

Quoted 11 lines · Mike Travis

From: Rusty Russell <[email protected]>

Impact: reduce stack usage, use new cpumask API.

This actually uses topology_core_cpumask() and topology_thread_cpumask(), removing the only users of topology_core_siblings() and topology_thread_siblings()

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#10 lore raw

PATCH 3/5 cpumask: convert misc driver functions

In reply to Mike Travis

From: Rusty Russell <[email protected]>

Impact: use new cpumask API.

Convert misc driver functions to use struct cpumask.

To Do:
- Convert iucv_buffer_cpumask to cpumask_var_t.

---
 drivers/base/cpu.c             |    2 +-
 drivers/misc/sgi-xp/xpc_main.c |    2 +-
 drivers/oprofile/buffer_sync.c |   22 ++++++++++++++++++----
 drivers/oprofile/buffer_sync.h |    4 ++++
 drivers/oprofile/oprof.c       |    9 ++++++++-
 drivers/xen/manage.c           |    2 +-
 net/iucv/iucv.c                |   28 ++++++++++++++++++----------
 7 files changed, 51 insertions(+), 18 deletions(-)
drivers/base/cpu.c +1 -1
@@ -107,7 +107,7 @@ static SYSDEV_ATTR(crash_notes, 0400, sh
 /*
  * Print cpu online, possible, present, and system maps
  */
-static ssize_t print_cpus_map(char *buf, cpumask_t *map)
+static ssize_t print_cpus_map(char *buf, const struct cpumask *map)
 {
 	int n = cpulist_scnprintf(buf, PAGE_SIZE-2, map);
 
drivers/misc/sgi-xp/xpc_main.c +1 -1
@@ -318,7 +318,7 @@ xpc_hb_checker(void *ignore)
 
 	/* this thread was marked active by xpc_hb_init() */
 
-	set_cpus_allowed_ptr(current, &cpumask_of_cpu(XPC_HB_CHECK_CPU));
+	set_cpus_allowed_ptr(current, cpumask_of(XPC_HB_CHECK_CPU));
 
 	/* set our heartbeating to other partitions into motion */
 	xpc_hb_check_timeout = jiffies + (xpc_hb_check_interval * HZ);
drivers/oprofile/buffer_sync.c +18 -4
@@ -37,7 +37,7 @@
 
 static LIST_HEAD(dying_tasks);
 static LIST_HEAD(dead_tasks);
-static cpumask_t marked_cpus = CPU_MASK_NONE;
+static cpumask_var_t marked_cpus;
 static DEFINE_SPINLOCK(task_mortuary);
 static void process_task_mortuary(void);
 
@@ -489,10 +489,10 @@ static void mark_done(int cpu)
 {
 	int i;
 
-	cpu_set(cpu, marked_cpus);
+	cpumask_set_cpu(cpu, marked_cpus);
 
 	for_each_online_cpu(i) {
-		if (!cpu_isset(i, marked_cpus))
+		if (!cpumask_test_cpu(i, marked_cpus))
 			return;
 	}
 
@@ -501,7 +501,7 @@ static void mark_done(int cpu)
 	 */
 	process_task_mortuary();
 
-	cpus_clear(marked_cpus);
+	cpumask_clear(marked_cpus);
 }
 
 
@@ -595,6 +595,20 @@ void sync_buffer(int cpu)
 	mutex_unlock(&buffer_mutex);
 }
 
+int __init buffer_sync_init(void)
+{
+	if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL))
+		return -ENOMEM;
+
+	cpumask_clear(marked_cpus);
+		return 0;
+}
+
+void __exit buffer_sync_cleanup(void)
+{
+	free_cpumask_var(marked_cpus);
+}
+
 /* The function can be used to add a buffer worth of data directly to
  * the kernel buffer. The buffer is assumed to be a circular buffer.
  * Take the entries from index start and end at index end, wrapping
drivers/oprofile/buffer_sync.h +4 -0
@@ -19,4 +19,8 @@ void sync_stop(void);
 /* sync the given CPU's buffer */
 void sync_buffer(int cpu);
 
+/* initialize/destroy the buffer system. */
+int buffer_sync_init(void);
+void buffer_sync_cleanup(void);
+
 #endif /* OPROFILE_BUFFER_SYNC_H */
drivers/oprofile/oprof.c +8 -1
@@ -183,6 +183,10 @@ static int __init oprofile_init(void)
 {
 	int err;
 
+	err = buffer_sync_init();
+	if (err)
+		return err;
+
 	err = oprofile_arch_init(&oprofile_ops);
 
 	if (err < 0 || timer) {
@@ -191,8 +195,10 @@ static int __init oprofile_init(void)
 	}
 
 	err = oprofilefs_register();
-	if (err)
+	if (err) {
 		oprofile_arch_exit();
+		buffer_sync_cleanup();
+	}
 
 	return err;
 }
@@ -202,6 +208,7 @@ static void __exit oprofile_exit(void)
 {
 	oprofilefs_unregister();
 	oprofile_arch_exit();
+	buffer_sync_cleanup();
 }
 
 
drivers/xen/manage.c +1 -1
@@ -100,7 +100,7 @@ static void do_suspend(void)
 	/* XXX use normal device tree? */
 	xenbus_suspend();
 
-	err = stop_machine(xen_suspend, &cancelled, &cpumask_of_cpu(0));
+	err = stop_machine(xen_suspend, &cancelled, cpumask_of(0));
 	if (err) {
 		printk(KERN_ERR "failed to start xen_suspend: %d\n", err);
 		goto out;
net/iucv/iucv.c +18 -10
@@ -492,15 +492,14 @@ static void iucv_setmask_mp(void)
  *
  * Allow iucv interrupts on a single cpu.
  */
-static void iucv_setmask_up(void)
+static void iucv_setmask_up(struct cpumask *cpumask)
 {
-	cpumask_t cpumask;
 	int cpu;
 
 	/* Disable all cpu but the first in cpu_irq_cpumask. */
-	cpumask = iucv_irq_cpumask;
-	cpu_clear(first_cpu(iucv_irq_cpumask), cpumask);
-	for_each_cpu_mask_nr(cpu, cpumask)
+	cpumask_copy(cpumask, iucv_irq_cpumask);
+	cpumask_clear_cpu(cpumask_first(iucv_irq_cpumask), cpumask);
+	for_each_cpu(cpu, cpumask)
 		smp_call_function_single(cpu, iucv_block_cpu, NULL, 1);
 }
 
@@ -558,7 +557,7 @@ static void iucv_disable(void)
 static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
 				     unsigned long action, void *hcpu)
 {
-	cpumask_t cpumask;
+	cpumask_var_t cpumask;
 	long cpu = (long) hcpu;
 
 	switch (action) {
@@ -593,15 +592,20 @@ static int __cpuinit iucv_cpu_notify(str
 		break;
 	case CPU_DOWN_PREPARE:
 	case CPU_DOWN_PREPARE_FROZEN:
-		cpumask = iucv_buffer_cpumask;
-		cpu_clear(cpu, cpumask);
-		if (cpus_empty(cpumask))
+		if (!alloc_cpumask_var(&cpumask, GFP_KERNEL))
+			return NOTIFY_BAD;
+		cpumask_copy(cpumask, &iucv_buffer_cpumask);
+		cpumask_clear_cpu(cpu, cpumask);
+		if (cpumask_empty(cpumask)) {
 			/* Can't offline last IUCV enabled cpu. */
+			free_cpumask_var(cpumask);
 			return NOTIFY_BAD;
+		}
 		smp_call_function_single(cpu, iucv_retrieve_cpu, NULL, 1);
 		if (cpus_empty(iucv_irq_cpumask))
 			smp_call_function_single(first_cpu(iucv_buffer_cpumask),
 						 iucv_allow_cpu, NULL, 1);
+		free_cpumask_var(cpumask);
 		break;
 	}
 	return NOTIFY_OK;
@@ -686,9 +690,12 @@ static void iucv_cleanup_queue(void)
 int iucv_register(struct iucv_handler *handler, int smp)
 {
 	int rc;
+	cpumask_var_t scratch;
 
 	if (!iucv_available)
 		return -ENOSYS;
+	if (!alloc_cpumask_var(&scratch, GFP_KERNEL))
+		return -ENOMEM;
 	mutex_lock(&iucv_register_mutex);
 	if (!smp)
 		iucv_nonsmp_handler++;
@@ -697,7 +704,7 @@ int iucv_register(struct iucv_handler *h
 		if (rc)
 			goto out_mutex;
 	} else if (!smp && iucv_nonsmp_handler == 1)
-		iucv_setmask_up();
+		iucv_setmask_up(scratch);
 	INIT_LIST_HEAD(&handler->paths);
 
 	spin_lock_bh(&iucv_table_lock);
@@ -706,6 +713,7 @@ int iucv_register(struct iucv_handler *h
 	rc = 0;
 out_mutex:
 	mutex_unlock(&iucv_register_mutex);
+	free_cpumask_var(scratch);
 	return rc;
 }
 EXPORT_SYMBOL(iucv_register);
#11 lore raw

Re: [PATCH 3/5] cpumask: convert misc driver functions

Quoted 5 lines · On Thursday 08 January 2009 06:28:35 Mike Travis wrote:

From: Rusty Russell <[email protected]>

Impact: use new cpumask API.

Convert misc driver functions to use struct cpumask.

...

Quoted 12 lines
net/iucv/iucv.c +5 -3
@@ -593,15 +592,20 @@ static int __cpuinit iucv_cpu_notify(str
 		break;
 	case CPU_DOWN_PREPARE:
 	case CPU_DOWN_PREPARE_FROZEN:
-		cpumask = iucv_buffer_cpumask;
-		cpu_clear(cpu, cpumask);
-		if (cpus_empty(cpumask))
+		if (!alloc_cpumask_var(&cpumask, GFP_KERNEL))
+			return NOTIFY_BAD;
+		cpumask_copy(cpumask, &iucv_buffer_cpumask);
+		cpumask_clear_cpu(cpu, cpumask);
+		if (cpumask_empty(cpumask)) {

net/iucv/iucv.c static int __cpuinit iucv_cpu_notify(str · line 609

Quoted 10 lines
net/iucv/iucv.c +3 -0
 			/* Can't offline last IUCV enabled cpu. */
+			free_cpumask_var(cpumask);
 			return NOTIFY_BAD;
+		}
 		smp_call_function_single(cpu, iucv_retrieve_cpu, NULL, 1);
 		if (cpus_empty(iucv_irq_cpumask))
 			smp_call_function_single(first_cpu(iucv_buffer_cpumask),
 						 iucv_allow_cpu, NULL, 1);
+		free_cpumask_var(cpumask);
 		break;

Minor nit: this can be done better, actually:

@@ -596,9 +594,7 @@ static int __cpuinit iucv_cpu_notify(str
case CPU_DOWN_PREPARE_FROZEN:
if (!iucv_path_table)
break;
- cpumask = iucv_buffer_cpumask;
- cpu_clear(cpu, cpumask);
- if (cpus_empty(cpumask))
+ if (cpumask_any_but(&iucv_buffer_cpumask, cpu) >= nr_cpu_ids)
/* Can't offline last IUCV enabled cpu. */ return NOTIFY_BAD;
smp_call_function_single(cpu, iucv_retrieve_cpu, NULL, 1);

Cheers,
Rusty.

#12 lore raw

Re: [PATCH 3/5] cpumask: convert misc driver functions

In reply to Mike Travis

+void __exit buffer_sync_cleanup(void)
+{
+ free_cpumask_var(marked_cpus);
+}

This breaks ia64 with CONFIG_OPROFILE=y

buffer_sync_cleanup' referenced in section .init.text' of arch/ia64/oprofile/built-in.o: defined in discarded section `.exit.text' of arch/ia64/oprofile/built-in.o
make: *** [.tmp_vmlinux1] Error 1

-Tony

#13 lore raw

Re: [PATCH 3/5] cpumask: convert misc driver functions

Quoted 5 lines · Tony Luck
drivers/oprofile/buffer_sync.c +4 -0
+void __exit buffer_sync_cleanup(void)
+{
+	free_cpumask_var(marked_cpus);
+}
Quoted 8 lines

This breaks ia64 with CONFIG_OPROFILE=y

buffer_sync_cleanup' referenced in section .init.text' of arch/ia64/oprofile/built-in.o: defined in discarded section `.exit.text' of arch/ia64/oprofile/built-in.o
make: *** [.tmp_vmlinux1] Error 1

-Tony

Hi Tony,

Hmm, that is a tricky error. I'll see what can be done to eliminate it.

Thanks!
Mike

#14 lore raw

Re: [PATCH 3/5] cpumask: convert misc driver functions

In reply to Tony Luck
Quoted 5 lines · Tony Luck
(quoted diff) +4 -0
+void __exit buffer_sync_cleanup(void)
+{
+	free_cpumask_var(marked_cpus);
+}
Quoted 8 lines

This breaks ia64 with CONFIG_OPROFILE=y

buffer_sync_cleanup' referenced in section .init.text' of arch/ia64/oprofile/built-in.o: defined in discarded section `.exit.text' of arch/ia64/oprofile/built-in.o
make: *** [.tmp_vmlinux1] Error 1

-Tony

Hi,

It's a bit hackish but I couldn't think of another workaround. And curiously, it doesn't affect x86?

Also, CPUMASK_OFFSTACK=n for ia64 so this is really a nop. (I haven't been able to turn it on for ia64.)

Thanks,
Mike
---

Subject: ia64: fix build error when OPROFILE enabled.

Impact: Fix build error.

Add a buffer_sync_cleanup_init() which duplicates the buffer_sync_cleanup() function but is placed in the .init.text section. This eliminates this build error:

buffer_sync_cleanup' referenced in section .init.text' of arch/ia64/oprofile/built-in.o: defined in discarded section `.exit.text' of arch/ia64/oprofile/built-in.o

---
 drivers/oprofile/buffer_sync.c |    6 ++++++
 drivers/oprofile/buffer_sync.h |    1 +
 drivers/oprofile/oprof.c       |    2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)
drivers/oprofile/buffer_sync.c +6 -0
@@ -579,6 +579,12 @@ void __exit buffer_sync_cleanup(void)
 	free_cpumask_var(marked_cpus);
 }
 
+/* same as above but in the __init section */
+void __init buffer_sync_cleanup_init(void)
+{
+	free_cpumask_var(marked_cpus);
+}
+
 /* The function can be used to add a buffer worth of data directly to
  * the kernel buffer. The buffer is assumed to be a circular buffer.
  * Take the entries from index start and end at index end, wrapping
drivers/oprofile/buffer_sync.h +1 -0
@@ -22,5 +22,6 @@ void sync_buffer(int cpu);
 /* initialize/destroy the buffer system. */
 int buffer_sync_init(void);
 void buffer_sync_cleanup(void);
+void buffer_sync_cleanup_init(void);
 
 #endif /* OPROFILE_BUFFER_SYNC_H */
drivers/oprofile/oprof.c +1 -1
@@ -197,7 +197,7 @@ static int __init oprofile_init(void)
 	err = oprofilefs_register();
 	if (err) {
 		oprofile_arch_exit();
-		buffer_sync_cleanup();
+		buffer_sync_cleanup_init();
 	}
 
 	return err;
Acked-by on v1 3/5
#15 lore raw

Re: [PATCH 3/5] cpumask: convert misc driver functions

In reply to Mike Travis
Quoted 21 lines · Mike Travis

From: Rusty Russell <[email protected]>

Impact: use new cpumask API.

Convert misc driver functions to use struct cpumask.

To Do:
- Convert iucv_buffer_cpumask to cpumask_var_t.

Quoted 6 lines
---
 drivers/base/cpu.c             |    2 +-
 drivers/misc/sgi-xp/xpc_main.c |    2 +-
 drivers/oprofile/buffer_sync.c |   22 ++++++++++++++++++----
 drivers/oprofile/buffer_sync.h |    4 ++++
 drivers/oprofile/oprof.c       |    9 ++++++++-

I will send out a delta patch that changes the initialization.

-Robert

Quoted 3 lines
 drivers/xen/manage.c           |    2 +-
 net/iucv/iucv.c                |   28 ++++++++++++++++++----------
 7 files changed, 51 insertions(+), 18 deletions(-)
Signature · 3 lines
Advanced Micro Devices, Inc.
Operating System Research Center
email: [email protected]
#16 lore raw

PATCH 1/1 cpumask: modifiy oprofile initialization

Delta patch to f7df8ed164996cd2c6aca9674388be6ef78d8b37 for tip/cpus4096.

Moved initialization to sync_start()/sync_stop(). No changes needed in buffer_sync.h and oprof.c anymore.

Cc Rusty Russell <[email protected]>
Cc Mike Travis <[email protected]>
---
 drivers/oprofile/buffer_sync.c |   20 ++++++--------------
 drivers/oprofile/buffer_sync.h |    4 ----
 drivers/oprofile/oprof.c       |    9 +--------
 3 files changed, 7 insertions(+), 26 deletions(-)
drivers/oprofile/buffer_sync.c +6 -14
index c3ea5fa..8574622 100644
@@ -154,6 +154,10 @@ int sync_start(void)
 {
 	int err;
 
+	if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL))
+		return -ENOMEM;
+	cpumask_clear(marked_cpus);
+
 	start_cpu_work();
 
 	err = task_handoff_register(&task_free_nb);
@@ -179,6 +183,7 @@ out2:
 	task_handoff_unregister(&task_free_nb);
 out1:
 	end_sync();
+	free_cpumask_var(marked_cpus);
 	goto out;
 }
 
@@ -190,6 +195,7 @@ void sync_stop(void)
 	profile_event_unregister(PROFILE_TASK_EXIT, &task_exit_nb);
 	task_handoff_unregister(&task_free_nb);
 	end_sync();
+	free_cpumask_var(marked_cpus);
 }
 
 
@@ -565,20 +571,6 @@ void sync_buffer(int cpu)
 	mutex_unlock(&buffer_mutex);
 }
 
-int __init buffer_sync_init(void)
-{
-	if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL))
-		return -ENOMEM;
-
-	cpumask_clear(marked_cpus);
-		return 0;
-}
-
-void __exit buffer_sync_cleanup(void)
-{
-	free_cpumask_var(marked_cpus);
-}
-
 /* The function can be used to add a buffer worth of data directly to
  * the kernel buffer. The buffer is assumed to be a circular buffer.
  * Take the entries from index start and end at index end, wrapping
drivers/oprofile/buffer_sync.h +0 -4
index 0ebf5db..3110732 100644
@@ -19,8 +19,4 @@ void sync_stop(void);
 /* sync the given CPU's buffer */
 void sync_buffer(int cpu);
 
-/* initialize/destroy the buffer system. */
-int buffer_sync_init(void);
-void buffer_sync_cleanup(void);
-
 #endif /* OPROFILE_BUFFER_SYNC_H */
drivers/oprofile/oprof.c +1 -8
index ced39f6..3cffce9 100644
@@ -183,10 +183,6 @@ static int __init oprofile_init(void)
 {
 	int err;
 
-	err = buffer_sync_init();
-	if (err)
-		return err;
-
 	err = oprofile_arch_init(&oprofile_ops);
 
 	if (err < 0 || timer) {
@@ -195,10 +191,8 @@ static int __init oprofile_init(void)
 	}
 
 	err = oprofilefs_register();
-	if (err) {
+	if (err)
 		oprofile_arch_exit();
-		buffer_sync_cleanup();
-	}
 
 	return err;
 }
@@ -208,7 +202,6 @@ static void __exit oprofile_exit(void)
 {
 	oprofilefs_unregister();
 	oprofile_arch_exit();
-	buffer_sync_cleanup();
 }
 
 
Signature · 1 line
1.6.1
Applied
#17 lore raw

Re: [PATCH] cpumask: modifiy oprofile initialization

Quoted 6 lines · Robert Richter

Delta patch to f7df8ed164996cd2c6aca9674388be6ef78d8b37 for tip/cpus4096.

Moved initialization to sync_start()/sync_stop(). No changes needed in buffer_sync.h and oprof.c anymore.

Quoted 8 lines
Cc Rusty Russell <[email protected]>
Cc Mike Travis <[email protected]>
---
 drivers/oprofile/buffer_sync.c |   20 ++++++--------------
 drivers/oprofile/buffer_sync.h |    4 ----
 drivers/oprofile/oprof.c       |    9 +--------
 3 files changed, 7 insertions(+), 26 deletions(-)

applied to tip/cpus4096, thanks Robert!

Ingo

#18 lore raw

Re: [PATCH] cpumask: modifiy oprofile initialization

Quoted 17 lines · Ingo Molnar
Quoted 6 lines · Robert Richter

Delta patch to f7df8ed164996cd2c6aca9674388be6ef78d8b37 for tip/cpus4096.

Moved initialization to sync_start()/sync_stop(). No changes needed in buffer_sync.h and oprof.c anymore.

Quoted 8 lines
Cc Rusty Russell <[email protected]>
Cc Mike Travis <[email protected]>
---
 drivers/oprofile/buffer_sync.c |   20 ++++++--------------
 drivers/oprofile/buffer_sync.h |    4 ----
 drivers/oprofile/oprof.c       |    9 +--------
 3 files changed, 7 insertions(+), 26 deletions(-)
Quoted 3 lines

applied to tip/cpus4096, thanks Robert!

Ingo

Hi Ingo,

Doesn't this need to be pushed upstream as the error was discovered in linux-next on ia64?

Thanks,
Mike

#19 lore raw

Re: [PATCH] cpumask: modifiy oprofile initialization

Quoted 18 lines · Mike Travis
Quoted 17 lines · Ingo Molnar
Quoted 14 lines · Robert Richter

Delta patch to f7df8ed164996cd2c6aca9674388be6ef78d8b37 for tip/cpus4096.

Moved initialization to sync_start()/sync_stop(). No changes needed in buffer_sync.h and oprof.c anymore.

Cc Rusty Russell <[email protected]>
Cc Mike Travis <[email protected]>
---
 drivers/oprofile/buffer_sync.c |   20 ++++++--------------
 drivers/oprofile/buffer_sync.h |    4 ----
 drivers/oprofile/oprof.c       |    9 +--------
 3 files changed, 7 insertions(+), 26 deletions(-)
Quoted 8 lines
Quoted 3 lines

applied to tip/cpus4096, thanks Robert!

Ingo

Hi Ingo,

Doesn't this need to be pushed upstream as the error was discovered in linux-next on ia64?

no, upstream -git does not have these changes yet, they came into linux-next via tip:cpus4096.

Ingo

#20 lore raw

Re: [PATCH] cpumask: modifiy oprofile initialization

In reply to Ingo Molnar
Quoted 17 lines · Ingo Molnar
Quoted 6 lines · Robert Richter

Delta patch to f7df8ed164996cd2c6aca9674388be6ef78d8b37 for tip/cpus4096.

Moved initialization to sync_start()/sync_stop(). No changes needed in buffer_sync.h and oprof.c anymore.

Quoted 8 lines
Cc Rusty Russell <[email protected]>
Cc Mike Travis <[email protected]>
---
 drivers/oprofile/buffer_sync.c |   20 ++++++--------------
 drivers/oprofile/buffer_sync.h |    4 ----
 drivers/oprofile/oprof.c       |    9 +--------
 3 files changed, 7 insertions(+), 26 deletions(-)
Quoted 3 lines

applied to tip/cpus4096, thanks Robert!

Ingo

Built and tested on an Altix 4700.

Cheers,
Mike

#21 lore raw

Re: [PATCH] cpumask: modifiy oprofile initialization

In reply to Robert Richter
Quoted 5 lines · Robert Richter

Delta patch to f7df8ed164996cd2c6aca9674388be6ef78d8b37 for tip/cpus4096.

Moved initialization to sync_start()/sync_stop(). No changes needed in buffer_sync.h and oprof.c anymore.

Great, thanks Robert!

Are you pushing this via some upstream queue so I can drop it from mine?

Thanks,
Mike

Quoted 110 lines
Cc Rusty Russell <[email protected]>
Cc Mike Travis <[email protected]>
---
 drivers/oprofile/buffer_sync.c |   20 ++++++--------------
 drivers/oprofile/buffer_sync.h |    4 ----
 drivers/oprofile/oprof.c       |    9 +--------
 3 files changed, 7 insertions(+), 26 deletions(-)
drivers/oprofile/buffer_sync.c +6 -14
index c3ea5fa..8574622 100644
@@ -154,6 +154,10 @@ int sync_start(void)
 {
 	int err;
 
+	if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL))
+		return -ENOMEM;
+	cpumask_clear(marked_cpus);
+
 	start_cpu_work();
 
 	err = task_handoff_register(&task_free_nb);
@@ -179,6 +183,7 @@ out2:
 	task_handoff_unregister(&task_free_nb);
 out1:
 	end_sync();
+	free_cpumask_var(marked_cpus);
 	goto out;
 }
 
@@ -190,6 +195,7 @@ void sync_stop(void)
 	profile_event_unregister(PROFILE_TASK_EXIT, &task_exit_nb);
 	task_handoff_unregister(&task_free_nb);
 	end_sync();
+	free_cpumask_var(marked_cpus);
 }
 
 
@@ -565,20 +571,6 @@ void sync_buffer(int cpu)
 	mutex_unlock(&buffer_mutex);
 }
 
-int __init buffer_sync_init(void)
-{
-	if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL))
-		return -ENOMEM;
-
-	cpumask_clear(marked_cpus);
-		return 0;
-}
-
-void __exit buffer_sync_cleanup(void)
-{
-	free_cpumask_var(marked_cpus);
-}
-
 /* The function can be used to add a buffer worth of data directly to
  * the kernel buffer. The buffer is assumed to be a circular buffer.
  * Take the entries from index start and end at index end, wrapping
drivers/oprofile/buffer_sync.h +0 -4
index 0ebf5db..3110732 100644
@@ -19,8 +19,4 @@ void sync_stop(void);
 /* sync the given CPU's buffer */
 void sync_buffer(int cpu);
 
-/* initialize/destroy the buffer system. */
-int buffer_sync_init(void);
-void buffer_sync_cleanup(void);
-
 #endif /* OPROFILE_BUFFER_SYNC_H */
drivers/oprofile/oprof.c +1 -8
index ced39f6..3cffce9 100644
@@ -183,10 +183,6 @@ static int __init oprofile_init(void)
 {
 	int err;
 
-	err = buffer_sync_init();
-	if (err)
-		return err;
-
 	err = oprofile_arch_init(&oprofile_ops);
 
 	if (err < 0 || timer) {
@@ -195,10 +191,8 @@ static int __init oprofile_init(void)
 	}
 
 	err = oprofilefs_register();
-	if (err) {
+	if (err)
 		oprofile_arch_exit();
-		buffer_sync_cleanup();
-	}
 
 	return err;
 }
@@ -208,7 +202,6 @@ static void __exit oprofile_exit(void)
 {
 	oprofilefs_unregister();
 	oprofile_arch_exit();
-	buffer_sync_cleanup();
 }
 
 
#22 lore raw

Re: [PATCH] cpumask: modifiy oprofile initialization

Quoted 10 lines · Mike Travis
Quoted 5 lines · Robert Richter

Delta patch to f7df8ed164996cd2c6aca9674388be6ef78d8b37 for tip/cpus4096.

Moved initialization to sync_start()/sync_stop(). No changes needed in buffer_sync.h and oprof.c anymore.

Great, thanks Robert!

Are you pushing this via some upstream queue so I can drop it from mine?

Mike, it is in the tip tree commit id 4c50d9e (tip/cpus4096).

-Robert

Signature · 3 lines
Advanced Micro Devices, Inc.
Operating System Research Center
email: [email protected]
#23 lore raw

PATCH 4/5 cpumask: convert drivers/net/sfc

In reply to Mike Travis

From: Rusty Russell <[email protected]>

Impact: reduce stack usage, use new cpumask API.

Remove a cpumask from the stack. Ben Hutchings indicated that printing a warning and returning 1 was acceptable for the corner case where allocation fails.

---
 drivers/net/sfc/efx.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/sfc/efx.c +11 -4
@@ -854,20 +854,27 @@ static void efx_fini_io(struct efx_nic *
  * interrupts across them. */
 static int efx_wanted_rx_queues(void)
 {
-	cpumask_t core_mask;
+	cpumask_var_t core_mask;
 	int count;
 	int cpu;
 
-	cpus_clear(core_mask);
+	if (!alloc_cpumask_var(&core_mask, GFP_KERNEL)) {
+		printk(KERN_WARNING
+		       "efx.c: allocation failure, irq balancing hobbled\n");
+		return 1;
+	}
+
+	cpumask_clear(core_mask);
 	count = 0;
 	for_each_online_cpu(cpu) {
-		if (!cpu_isset(cpu, core_mask)) {
+		if (!cpumask_test_cpu(cpu, core_mask)) {
 			++count;
-			cpumask_or(&core_mask, &core_mask,
+			cpumask_or(core_mask, core_mask,
 				   topology_core_cpumask(cpu));
 		}
 	}
 
+	free_cpumask_var(core_mask);
 	return count;
 }
 
Acked-by on v1 4/5
#24 lore raw

Re: [PATCH 4/5] cpumask: convert drivers/net/sfc

Quoted 4 lines · Mike Travis

From: Rusty Russell <[email protected]>

Impact: reduce stack usage, use new cpumask API.

Quoted 8 lines

Remove a cpumask from the stack. Ben Hutchings indicated that printing a warning and returning 1 was acceptable for the corner case where allocation fails.

This seems to work.

Quoted 10 lines
---
 drivers/net/sfc/efx.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/sfc/efx.c +0 -0
@@ -854,20 +854,27 @@ static void efx_fini_io(struct efx_nic *
  * interrupts across them. */
 static int efx_wanted_rx_queues(void)

drivers/net/sfc/efx.c static void efx_fini_io(struct efx_nic * · line 863

Quoted 10 lines
drivers/net/sfc/efx.c +4 -2
 {
-	cpumask_t core_mask;
+	cpumask_var_t core_mask;
 	int count;
 	int cpu;
 
-	cpus_clear(core_mask);
+	if (!alloc_cpumask_var(&core_mask, GFP_KERNEL)) {
+		printk(KERN_WARNING
+		       "efx.c: allocation failure, irq balancing hobbled\n");

[...]

This is an exceedingly unlikely error case so the error message is not that important, but if you don't mind re-spinning this then please make it "sfc: RSS disabled due to allocation failure\n".

(Device-related log messages should also include the device address, but I don't want to add a device parameter to the function just for that. Maybe we should call this function just once at module init time since the result is not device-specific.)

Ben.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#26 lore raw

Re: [PATCH 4/5] cpumask: convert drivers/net/sfc [PATCH supplied]

Quoted 44 lines · Rusty Russell
Quoted 39 lines · On Tuesday 20 January 2009 03:38:30 Ben Hutchings wrote:
Quoted 4 lines · Mike Travis

From: Rusty Russell <[email protected]>

Impact: reduce stack usage, use new cpumask API.

Quoted 8 lines

Remove a cpumask from the stack. Ben Hutchings indicated that printing a warning and returning 1 was acceptable for the corner case where allocation fails.

This seems to work.

Quoted 20 lines
---
 drivers/net/sfc/efx.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/sfc/efx.c +4 -2
@@ -854,20 +854,27 @@ static void efx_fini_io(struct efx_nic *
  * interrupts across them. */
 static int efx_wanted_rx_queues(void)
 {
-	cpumask_t core_mask;
+	cpumask_var_t core_mask;
 	int count;
 	int cpu;
 
-	cpus_clear(core_mask);
+	if (!alloc_cpumask_var(&core_mask, GFP_KERNEL)) {
+		printk(KERN_WARNING
+		       "efx.c: allocation failure, irq balancing hobbled\n");

[...]

Quoted 3 lines

This is an exceedingly unlikely error case so the error message is not that important, but if you don't mind re-spinning this then please make it "sfc: RSS disabled due to allocation failure\n".

Quoted 6 lines

OK, I'm away from all my machines, at linux.conf.au. Mike, can you change this if you haven't already?

Thanks,
Rusty.

Subject: sfc: modify allocation error message

Impact: change error message when alloc_cpumask_var fails.

---
 drivers/net/sfc/efx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/sfc/efx.c +2 -2
@@ -858,9 +858,9 @@ static int efx_wanted_rx_queues(void)
 	int count;
 	int cpu;
 
-	if (!alloc_cpumask_var(&core_mask, GFP_KERNEL)) {
+	if (unlikely(!alloc_cpumask_var(&core_mask, GFP_KERNEL))) {
 		printk(KERN_WARNING
-		       "efx.c: allocation failure, irq balancing hobbled\n");
+		       "sfc: RSS disabled due to allocation failure\n");
 		return 1;
 	}
 
#27 lore raw

PATCH 1/1 sfc: modify allocation error message

In reply to a message not in the archive
Quoted 44 lines · Rusty Russell
Quoted 39 lines · On Tuesday 20 January 2009 03:38:30 Ben Hutchings wrote:
Quoted 4 lines · Mike Travis

From: Rusty Russell <[email protected]>

Impact: reduce stack usage, use new cpumask API.

Quoted 8 lines

Remove a cpumask from the stack. Ben Hutchings indicated that printing a warning and returning 1 was acceptable for the corner case where allocation fails.

This seems to work.

Quoted 20 lines
---
 drivers/net/sfc/efx.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/sfc/efx.c +4 -2
@@ -854,20 +854,27 @@ static void efx_fini_io(struct efx_nic *
  * interrupts across them. */
 static int efx_wanted_rx_queues(void)
 {
-	cpumask_t core_mask;
+	cpumask_var_t core_mask;
 	int count;
 	int cpu;
 
-	cpus_clear(core_mask);
+	if (!alloc_cpumask_var(&core_mask, GFP_KERNEL)) {
+		printk(KERN_WARNING
+		       "efx.c: allocation failure, irq balancing hobbled\n");

[...]

Quoted 3 lines

This is an exceedingly unlikely error case so the error message is not that important, but if you don't mind re-spinning this then please make it "sfc: RSS disabled due to allocation failure\n".

Quoted 6 lines

OK, I'm away from all my machines, at linux.conf.au. Mike, can you change this if you haven't already?

Thanks,
Rusty.

Subject: sfc: modify allocation error message

Impact: change error message when alloc_cpumask_var fails.

---
 drivers/net/sfc/efx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/sfc/efx.c +2 -2
@@ -858,9 +858,9 @@ static int efx_wanted_rx_queues(void)
 	int count;
 	int cpu;
 
-	if (!alloc_cpumask_var(&core_mask, GFP_KERNEL)) {
+	if (unlikely(!alloc_cpumask_var(&core_mask, GFP_KERNEL))) {
 		printk(KERN_WARNING
-		       "efx.c: allocation failure, irq balancing hobbled\n");
+		       "sfc: RSS disabled due to allocation failure\n");
 		return 1;
 	}
 
Acked-by on v1 1/1
#28 lore raw

Re: [PATCH] sfc: modify allocation error message

On Mon, 2009-01-26 at 07:04 -0800, Mike Travis wrote:
[...]

Quoted 6 lines

Subject: sfc: modify allocation error message

Impact: change error message when alloc_cpumask_var fails.

Quoted 18 lines

--

 drivers/net/sfc/efx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/sfc/efx.c +2 -2
@@ -858,9 +858,9 @@ static int efx_wanted_rx_queues(void)
        int count;
        int cpu;
 
-       if (!alloc_cpumask_var(&core_mask, GFP_KERNEL)) {
+       if (unlikely(!alloc_cpumask_var(&core_mask, GFP_KERNEL))) {
                printk(KERN_WARNING
-                      "efx.c: allocation failure, irq balancing hobbled\n");
+                      "sfc: RSS disabled due to allocation failure\n");
                return 1;
        }
 
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#29 lore raw

PATCH 5/5 cpumask: convert other misc kernel functions

In reply to Mike Travis

From: Rusty Russell <[email protected]>

Impact: use new cpumask API.

Convert other misc kernel functions to use struct cpumask.

---
 lib/smp_processor_id.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/smp_processor_id.c +1 -1
@@ -22,7 +22,7 @@ notrace unsigned int debug_smp_processor
 	 * Kernel threads bound to a single CPU can safely use
 	 * smp_processor_id():
 	 */
-	if (cpus_equal(current->cpus_allowed, cpumask_of_cpu(this_cpu)))
+	if (cpumask_equal(&current->cpus_allowed, cpumask_of(this_cpu)))
 		goto out;
 
 	/*
#30 lore raw
In reply to Mike Travis
Quoted 9 lines · Mike Travis

One big change to irq_desc and a few smaller maintenance type updates.

cpumask: update irq_desc to use cpumask_var_t
cpumask: Use topology_core_cpumask()/topology_thread_cpumask()
cpumask: convert misc driver functions
cpumask: convert drivers/net/sfc
cpumask: convert other misc kernel functions

Quoted 7 lines

Based on tip/cpus4096: v2.6.28-5703-g1d1a70e

(Ingo - I added a blank line before the From: part and that seems to separate it from the Subject. Hopefully your git-am will still recognizes it - I did try a git-am here and it seemed to work ok.)

Since you have it in a Git tree, why dont you send me a pull request?

I might be more picky about pull requests in general (because it's harder to fix up a pulled tree than to fix up commits that come from emails - and it's also more work for you if i refuse to pull than if i have some comments over email-patches), but it's a much better (more scalable) workflow in the long run than the email path.

Ingo

#31 lore raw
Quoted 20 lines · Ingo Molnar
Quoted 8 lines · Mike Travis

One big change to irq_desc and a few smaller maintenance type updates.

cpumask: update irq_desc to use cpumask_var_t
cpumask: Use topology_core_cpumask()/topology_thread_cpumask()
cpumask: convert misc driver functions
cpumask: convert drivers/net/sfc
cpumask: convert other misc kernel functions

Quoted 7 lines

Based on tip/cpus4096: v2.6.28-5703-g1d1a70e

(Ingo - I added a blank line before the From: part and that seems to separate it from the Subject. Hopefully your git-am will still recognizes it - I did try a git-am here and it seemed to work ok.)

Since you have it in a Git tree, why dont you send me a pull request?

Quoted 7 lines

I might be more picky about pull requests in general (because it's harder to fix up a pulled tree than to fix up commits that come from emails - and it's also more work for you if i refuse to pull than if i have some comments over email-patches), but it's a much better (more scalable) workflow in the long run than the email path.

Ingo

Ok, will do.

Thanks,
Mike