linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] cpumask: more cpumask updates
@ 2009-01-07 19:58 Mike Travis
  2009-01-07 19:58 ` [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t Mike Travis
                   ` (5 more replies)
  0 siblings, 6 replies; 31+ messages in thread
From: Mike Travis @ 2009-01-07 19:58 UTC (permalink / raw)
  To: Ingo Molnar, Rusty Russell
  Cc: Thomas Gleixner, H. Peter Anvin, Jack Steiner, linux-kernel


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.)

Signed-off-by: Mike Travis <travis@sgi.com>

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t
  2009-01-07 19:58 [PATCH 0/5] cpumask: more cpumask updates Mike Travis
@ 2009-01-07 19:58 ` Mike Travis
  2009-01-07 20:27   ` Yinghai Lu
  2009-01-07 19:58 ` [PATCH 2/5] cpumask: Use topology_core_cpumask()/topology_thread_cpumask() Mike Travis
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 31+ messages in thread
From: Mike Travis @ 2009-01-07 19:58 UTC (permalink / raw)
  To: Ingo Molnar, Rusty Russell
  Cc: Thomas Gleixner, H. Peter Anvin, Jack Steiner, linux-kernel,
	Chris Wright, Jeremy Fitzhardinge, KOSAKI Motohiro,
	Venkatesh Pallipadi, virtualization, xen-devel, Yinghai Lu

[-- Attachment #1: cpumask:update-irq_desc-to-use-cpumask_var_t.patch --]
[-- Type: text/plain, Size: 14894 bytes --]

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

Signed-off-by: Mike Travis <travis@sgi.com>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Cc: virtualization@lists.osdl.org
Cc: xen-devel@lists.xensource.com
Cc: Yinghai Lu <yhlu.kernel@gmail.com>
---
 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(-)

--- linux-2.6-for-ingo.orig/arch/x86/kernel/io_apic.c
+++ linux-2.6-for-ingo/arch/x86/kernel/io_apic.c
@@ -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;
 
--- linux-2.6-for-ingo.orig/arch/x86/kernel/irq_32.c
+++ linux-2.6-for-ingo/arch/x86/kernel/irq_32.c
@@ -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;
--- linux-2.6-for-ingo.orig/arch/x86/kernel/irq_64.c
+++ linux-2.6-for-ingo/arch/x86/kernel/irq_64.c
@@ -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);
--- linux-2.6-for-ingo.orig/drivers/xen/events.c
+++ linux-2.6-for-ingo/drivers/xen/events.c
@@ -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
 
--- linux-2.6-for-ingo.orig/include/linux/irq.h
+++ linux-2.6-for-ingo/include/linux/irq.h
@@ -182,11 +182,11 @@ struct irq_desc {
 	unsigned int		irqs_unhandled;
 	spinlock_t		lock;
 #ifdef CONFIG_SMP
-	cpumask_t		affinity;
+	cpumask_var_t		affinity;
 	unsigned int		cpu;
-#endif
 #ifdef CONFIG_GENERIC_PENDING_IRQ
-	cpumask_t		pending_mask;
+	cpumask_var_t		pending_mask;
+#endif
 #endif
 #ifdef CONFIG_PROC_FS
 	struct proc_dir_entry	*dir;
@@ -422,4 +422,79 @@ extern int set_irq_msi(unsigned int irq,
 
 #endif /* !CONFIG_S390 */
 
+#ifdef CONFIG_SMP
+/**
+ * init_alloc_desc_masks - allocate cpumasks for irq_desc
+ * @desc:	pointer to irq_desc struct
+ * @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,
+								bool boot)
+{
+	if (boot) {
+		alloc_bootmem_cpumask_var(&desc->affinity);
+		cpumask_setall(desc->affinity);
+
+#ifdef CONFIG_GENERIC_PENDING_IRQ
+		alloc_bootmem_cpumask_var(&desc->pending_mask);
+		cpumask_clear(desc->pending_mask);
+#endif
+		return true;
+	}
+
+	if (!alloc_cpumask_var_node(&desc->affinity, GFP_ATOMIC, node))
+		return false;
+	cpumask_setall(desc->affinity);
+
+#ifdef CONFIG_GENERIC_PENDING_IRQ
+	if (!alloc_cpumask_var_node(&desc->pending_mask, GFP_ATOMIC, node)) {
+		free_cpumask_var(desc->affinity);
+		return false;
+	}
+	cpumask_clear(desc->pending_mask);
+#endif
+	return true;
+}
+
+/**
+ * init_copy_desc_masks - copy cpumasks for irq_desc
+ * @old_desc:	pointer to old irq_desc struct
+ * @new_desc:	pointer to new irq_desc struct
+ *
+ * Insures affinity and pending_masks are copied to new irq_desc.
+ * If !CONFIG_CPUMASKS_OFFSTACK the cpumasks are embedded in the
+ * irq_desc struct so the copy is redundant.
+ */
+
+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
+}
+
+#else /* !CONFIG_SMP */
+
+static inline bool init_alloc_desc_masks(struct irq_desc *desc, int node,
+								bool boot)
+{
+	return true;
+}
+
+static inline void init_copy_desc_masks(struct irq_desc *old_desc,
+					struct irq_desc *new_desc)
+{
+}
+
+#endif	/* CONFIG_SMP */
+
 #endif /* _LINUX_IRQ_H */
--- linux-2.6-for-ingo.orig/kernel/irq/chip.c
+++ linux-2.6-for-ingo/kernel/irq/chip.c
@@ -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);
 }
--- linux-2.6-for-ingo.orig/kernel/irq/handle.c
+++ linux-2.6-for-ingo/kernel/irq/handle.c
@@ -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();
 }
 
--- linux-2.6-for-ingo.orig/kernel/irq/manage.c
+++ linux-2.6-for-ingo/kernel/irq/manage.c
@@ -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;
 }
--- linux-2.6-for-ingo.orig/kernel/irq/migration.c
+++ linux-2.6-for-ingo/kernel/irq/migration.c
@@ -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)
--- 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);
 
 	irq_desc_ptrs[irq] = desc;
--- linux-2.6-for-ingo.orig/kernel/irq/proc.c
+++ linux-2.6-for-ingo/kernel/irq/proc.c
@@ -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');

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 2/5] cpumask: Use topology_core_cpumask()/topology_thread_cpumask()
  2009-01-07 19:58 [PATCH 0/5] cpumask: more cpumask updates Mike Travis
  2009-01-07 19:58 ` [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t Mike Travis
@ 2009-01-07 19:58 ` Mike Travis
  2009-01-19 17:11   ` Ben Hutchings
  2009-01-07 19:58 ` [PATCH 3/5] cpumask: convert misc driver functions Mike Travis
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 31+ messages in thread
From: Mike Travis @ 2009-01-07 19:58 UTC (permalink / raw)
  To: Ingo Molnar, Rusty Russell
  Cc: Thomas Gleixner, H. Peter Anvin, Jack Steiner, linux-kernel,
	linux-net-drivers

[-- Attachment #1: cpumask:use-topology_core_cpumask-and-topology_thread_cpumask.patch --]
[-- Type: text/plain, Size: 5231 bytes --]

From: Rusty Russell <rusty@rustcorp.com.au>

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()

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Mike Travis <travis@sgi.com>
Cc: linux-net-drivers@solarflare.com
---
 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(-)

--- linux-2.6-for-ingo.orig/Documentation/cputopology.txt
+++ linux-2.6-for-ingo/Documentation/cputopology.txt
@@ -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
--- linux-2.6-for-ingo.orig/drivers/base/topology.c
+++ linux-2.6-for-ingo/drivers/base/topology.c
@@ -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,
--- linux-2.6-for-ingo.orig/drivers/net/sfc/efx.c
+++ linux-2.6-for-ingo/drivers/net/sfc/efx.c
@@ -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));
 		}
 	}
 
--- linux-2.6-for-ingo.orig/include/linux/topology.h
+++ linux-2.6-for-ingo/include/linux/topology.h
@@ -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 */

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 3/5] cpumask: convert misc driver functions
  2009-01-07 19:58 [PATCH 0/5] cpumask: more cpumask updates Mike Travis
  2009-01-07 19:58 ` [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t Mike Travis
  2009-01-07 19:58 ` [PATCH 2/5] cpumask: Use topology_core_cpumask()/topology_thread_cpumask() Mike Travis
@ 2009-01-07 19:58 ` Mike Travis
  2009-01-10 10:57   ` Rusty Russell
                     ` (2 more replies)
  2009-01-07 19:58 ` [PATCH 4/5] cpumask: convert drivers/net/sfc Mike Travis
                   ` (2 subsequent siblings)
  5 siblings, 3 replies; 31+ messages in thread
From: Mike Travis @ 2009-01-07 19:58 UTC (permalink / raw)
  To: Ingo Molnar, Rusty Russell
  Cc: Thomas Gleixner, H. Peter Anvin, Jack Steiner, linux-kernel,
	Dean Nelson, Robert Richter, oprofile-list, Jeremy Fitzhardinge,
	Chris Wright, virtualization, xen-devel, Ursula Braun, linux390,
	linux-s390

[-- Attachment #1: cpumask:convert-drivers.patch --]
[-- Type: text/plain, Size: 7183 bytes --]

From: Rusty Russell <rusty@rustcorp.com.au>

Impact: use new cpumask API.

Convert misc driver functions to use struct cpumask.

To Do:
  - Convert iucv_buffer_cpumask to cpumask_var_t.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Mike Travis <travis@sgi.com>
Acked-by: Dean Nelson <dcn@sgi.com>
Cc: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list@lists.sf.net
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: virtualization@lists.osdl.org
Cc: xen-devel@lists.xensource.com
Cc: Ursula Braun <ursula.braun@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
 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(-)

--- linux-2.6-for-ingo.orig/drivers/base/cpu.c
+++ linux-2.6-for-ingo/drivers/base/cpu.c
@@ -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);
 
--- linux-2.6-for-ingo.orig/drivers/misc/sgi-xp/xpc_main.c
+++ linux-2.6-for-ingo/drivers/misc/sgi-xp/xpc_main.c
@@ -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);
--- linux-2.6-for-ingo.orig/drivers/oprofile/buffer_sync.c
+++ linux-2.6-for-ingo/drivers/oprofile/buffer_sync.c
@@ -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
--- linux-2.6-for-ingo.orig/drivers/oprofile/buffer_sync.h
+++ linux-2.6-for-ingo/drivers/oprofile/buffer_sync.h
@@ -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 */
--- linux-2.6-for-ingo.orig/drivers/oprofile/oprof.c
+++ linux-2.6-for-ingo/drivers/oprofile/oprof.c
@@ -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();
 }
 
 
--- linux-2.6-for-ingo.orig/drivers/xen/manage.c
+++ linux-2.6-for-ingo/drivers/xen/manage.c
@@ -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;
--- linux-2.6-for-ingo.orig/net/iucv/iucv.c
+++ linux-2.6-for-ingo/net/iucv/iucv.c
@@ -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);

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 4/5] cpumask: convert drivers/net/sfc
  2009-01-07 19:58 [PATCH 0/5] cpumask: more cpumask updates Mike Travis
                   ` (2 preceding siblings ...)
  2009-01-07 19:58 ` [PATCH 3/5] cpumask: convert misc driver functions Mike Travis
@ 2009-01-07 19:58 ` Mike Travis
  2009-01-19 17:08   ` Ben Hutchings
  2009-01-07 19:58 ` [PATCH 5/5] cpumask: convert other misc kernel functions Mike Travis
  2009-01-07 20:52 ` [PATCH 0/5] cpumask: more cpumask updates Ingo Molnar
  5 siblings, 1 reply; 31+ messages in thread
From: Mike Travis @ 2009-01-07 19:58 UTC (permalink / raw)
  To: Ingo Molnar, Rusty Russell
  Cc: Thomas Gleixner, H. Peter Anvin, Jack Steiner, linux-kernel,
	Ben Hutchings, linux-net-drivers

[-- Attachment #1: cpumask:convert-drivers_net_sfc_efx.c.patch --]
[-- Type: text/plain, Size: 1390 bytes --]

From: Rusty Russell <rusty@rustcorp.com.au>

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.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Mike Travis <travis@sgi.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Cc: linux-net-drivers@solarflare.com
---
 drivers/net/sfc/efx.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -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;
 }
 

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 5/5] cpumask: convert other misc kernel functions
  2009-01-07 19:58 [PATCH 0/5] cpumask: more cpumask updates Mike Travis
                   ` (3 preceding siblings ...)
  2009-01-07 19:58 ` [PATCH 4/5] cpumask: convert drivers/net/sfc Mike Travis
@ 2009-01-07 19:58 ` Mike Travis
  2009-01-07 20:52 ` [PATCH 0/5] cpumask: more cpumask updates Ingo Molnar
  5 siblings, 0 replies; 31+ messages in thread
From: Mike Travis @ 2009-01-07 19:58 UTC (permalink / raw)
  To: Ingo Molnar, Rusty Russell
  Cc: Thomas Gleixner, H. Peter Anvin, Jack Steiner, linux-kernel

[-- Attachment #1: cpumask:convert-misc.patch --]
[-- Type: text/plain, Size: 709 bytes --]

From: Rusty Russell <rusty@rustcorp.com.au>

Impact: use new cpumask API.

Convert other misc kernel functions to use struct cpumask.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Mike Travis <travis@sgi.com>
---
 lib/smp_processor_id.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.28.orig/lib/smp_processor_id.c
+++ linux-2.6.28/lib/smp_processor_id.c
@@ -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;
 
 	/*

-- 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t
  2009-01-07 19:58 ` [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t Mike Travis
@ 2009-01-07 20:27   ` Yinghai Lu
  2009-01-07 22:32     ` Mike Travis
  0 siblings, 1 reply; 31+ messages in thread
From: Yinghai Lu @ 2009-01-07 20:27 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, Chris Wright, Jeremy Fitzhardinge,
	KOSAKI Motohiro, Venkatesh Pallipadi, virtualization, xen-devel

On Wed, Jan 7, 2009 at 11:58 AM, Mike Travis <travis@sgi.com> 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 0/5] cpumask: more cpumask updates
  2009-01-07 19:58 [PATCH 0/5] cpumask: more cpumask updates Mike Travis
                   ` (4 preceding siblings ...)
  2009-01-07 19:58 ` [PATCH 5/5] cpumask: convert other misc kernel functions Mike Travis
@ 2009-01-07 20:52 ` Ingo Molnar
  2009-01-07 21:20   ` Mike Travis
  5 siblings, 1 reply; 31+ messages in thread
From: Ingo Molnar @ 2009-01-07 20:52 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel


* Mike Travis <travis@sgi.com> wrote:

> 
> 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.)
> 
> Signed-off-by: Mike Travis <travis@sgi.com>

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 0/5] cpumask: more cpumask updates
  2009-01-07 20:52 ` [PATCH 0/5] cpumask: more cpumask updates Ingo Molnar
@ 2009-01-07 21:20   ` Mike Travis
  0 siblings, 0 replies; 31+ messages in thread
From: Mike Travis @ 2009-01-07 21:20 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel

Ingo Molnar wrote:
> * Mike Travis <travis@sgi.com> wrote:
> 
>> 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.)
>>
>> Signed-off-by: Mike Travis <travis@sgi.com>
> 
> 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

Ok, will do.

Thanks,
Mike

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t
  2009-01-07 20:27   ` Yinghai Lu
@ 2009-01-07 22:32     ` Mike Travis
  2009-01-08  3:15       ` Yinghai Lu
  0 siblings, 1 reply; 31+ messages in thread
From: Mike Travis @ 2009-01-07 22:32 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, Chris Wright, Jeremy Fitzhardinge,
	KOSAKI Motohiro, Venkatesh Pallipadi, virtualization, xen-devel

Yinghai Lu wrote:
> On Wed, Jan 7, 2009 at 11:58 AM, Mike Travis <travis@sgi.com> 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()

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

> 
> | 	irq_desc_ptrs[irq] = desc;
> 
> YH
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t
  2009-01-07 22:32     ` Mike Travis
@ 2009-01-08  3:15       ` Yinghai Lu
  2009-01-08 15:45         ` Mike Travis
  2009-01-08 18:40         ` [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t: fix Mike Travis
  0 siblings, 2 replies; 31+ messages in thread
From: Yinghai Lu @ 2009-01-08  3:15 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, Chris Wright, Jeremy Fitzhardinge,
	KOSAKI Motohiro, Venkatesh Pallipadi, virtualization, xen-devel

Mike Travis wrote:
> Yinghai Lu wrote:
>> On Wed, Jan 7, 2009 at 11:58 AM, Mike Travis <travis@sgi.com> 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()
> 
> 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?

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t
  2009-01-08  3:15       ` Yinghai Lu
@ 2009-01-08 15:45         ` Mike Travis
  2009-01-08 19:31           ` Yinghai Lu
  2009-01-08 18:40         ` [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t: fix Mike Travis
  1 sibling, 1 reply; 31+ messages in thread
From: Mike Travis @ 2009-01-08 15:45 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, Chris Wright, Jeremy Fitzhardinge,
	KOSAKI Motohiro, Venkatesh Pallipadi, virtualization, xen-devel

Yinghai Lu wrote:
...
>> 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t: fix
  2009-01-08  3:15       ` Yinghai Lu
  2009-01-08 15:45         ` Mike Travis
@ 2009-01-08 18:40         ` Mike Travis
  1 sibling, 0 replies; 31+ messages in thread
From: Mike Travis @ 2009-01-08 18:40 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Ingo Molnar, Rusty Russell, Jack Steiner, linux-kernel

Yinghai Lu wrote:
...
> 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.

Signed-off-by: Mike Travis <travis@sgi.com>
Cc: Yinghai Lu <yinghai@kernel.org>
---
 include/linux/irq.h       |    9 +++++++--
 kernel/irq/handle.c       |    8 +-------
 kernel/irq/numa_migrate.c |   13 ++++++++-----
 3 files changed, 16 insertions(+), 14 deletions(-)

--- linux-2.6-for-ingo.orig/include/linux/irq.h
+++ linux-2.6-for-ingo/include/linux/irq.h
@@ -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;
--- linux-2.6-for-ingo.orig/kernel/irq/handle.c
+++ linux-2.6-for-ingo/kernel/irq/handle.c
@@ -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;
--- linux-2.6-for-ingo.orig/kernel/irq/numa_migrate.c
+++ linux-2.6-for-ingo/kernel/irq/numa_migrate.c
@@ -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;
 


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t
  2009-01-08 15:45         ` Mike Travis
@ 2009-01-08 19:31           ` Yinghai Lu
  0 siblings, 0 replies; 31+ messages in thread
From: Yinghai Lu @ 2009-01-08 19:31 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, Chris Wright, Jeremy Fitzhardinge,
	KOSAKI Motohiro, Venkatesh Pallipadi, virtualization, xen-devel

Mike Travis wrote:
> Yinghai Lu wrote:
> ...
>>> 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.

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 3/5] cpumask: convert misc driver functions
  2009-01-07 19:58 ` [PATCH 3/5] cpumask: convert misc driver functions Mike Travis
@ 2009-01-10 10:57   ` Rusty Russell
  2009-01-16 18:42   ` Tony Luck
  2009-01-22 13:11   ` Robert Richter
  2 siblings, 0 replies; 31+ messages in thread
From: Rusty Russell @ 2009-01-10 10:57 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Jack Steiner,
	linux-kernel, Dean Nelson, Robert Richter, oprofile-list,
	Jeremy Fitzhardinge, Chris Wright, virtualization, xen-devel,
	Ursula Braun, linux390, linux-s390

On Thursday 08 January 2009 06:28:35 Mike Travis wrote:
> From: Rusty Russell <rusty@rustcorp.com.au>
> 
> Impact: use new cpumask API.
> 
> Convert misc driver functions to use struct cpumask.
...
> @@ -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;

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.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 3/5] cpumask: convert misc driver functions
  2009-01-07 19:58 ` [PATCH 3/5] cpumask: convert misc driver functions Mike Travis
  2009-01-10 10:57   ` Rusty Russell
@ 2009-01-16 18:42   ` Tony Luck
  2009-01-16 18:55     ` Mike Travis
  2009-01-16 22:02     ` Mike Travis
  2009-01-22 13:11   ` Robert Richter
  2 siblings, 2 replies; 31+ messages in thread
From: Tony Luck @ 2009-01-16 18:42 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, Dean Nelson, Robert Richter,
	oprofile-list, Jeremy Fitzhardinge, Chris Wright, virtualization,
	xen-devel, Ursula Braun, linux390, linux-s390

+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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 3/5] cpumask: convert misc driver functions
  2009-01-16 18:42   ` Tony Luck
@ 2009-01-16 18:55     ` Mike Travis
  2009-01-16 22:02     ` Mike Travis
  1 sibling, 0 replies; 31+ messages in thread
From: Mike Travis @ 2009-01-16 18:55 UTC (permalink / raw)
  To: Tony Luck
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, Dean Nelson, Robert Richter,
	oprofile-list, Jeremy Fitzhardinge, Chris Wright, virtualization,
	xen-devel, Ursula Braun, linux390, linux-s390

Tony Luck wrote:
> +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

Hi Tony,

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

Thanks!
Mike



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 3/5] cpumask: convert misc driver functions
  2009-01-16 18:42   ` Tony Luck
  2009-01-16 18:55     ` Mike Travis
@ 2009-01-16 22:02     ` Mike Travis
  1 sibling, 0 replies; 31+ messages in thread
From: Mike Travis @ 2009-01-16 22:02 UTC (permalink / raw)
  To: Tony Luck
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, Dean Nelson, Robert Richter,
	oprofile-list

Tony Luck wrote:
> +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

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

Signed-off-by: Mike Travis <travis@sgi.com>
Cc: Tony Luck <tony.luck@gmail.com>
Cc: Robert Richter <robert.richter@amd.com>
Cc: <oprofile-list@lists.sf.net>
---
 drivers/oprofile/buffer_sync.c |    6 ++++++
 drivers/oprofile/buffer_sync.h |    1 +
 drivers/oprofile/oprof.c       |    2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

--- linux-2.6-for-ingo.orig/drivers/oprofile/buffer_sync.c
+++ linux-2.6-for-ingo/drivers/oprofile/buffer_sync.c
@@ -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
--- linux-2.6-for-ingo.orig/drivers/oprofile/buffer_sync.h
+++ linux-2.6-for-ingo/drivers/oprofile/buffer_sync.h
@@ -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 */
--- linux-2.6-for-ingo.orig/drivers/oprofile/oprof.c
+++ linux-2.6-for-ingo/drivers/oprofile/oprof.c
@@ -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;

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/5] cpumask: convert drivers/net/sfc
  2009-01-07 19:58 ` [PATCH 4/5] cpumask: convert drivers/net/sfc Mike Travis
@ 2009-01-19 17:08   ` Ben Hutchings
       [not found]     ` <200901201209.34854.rusty@rustcorp.com.au>
  0 siblings, 1 reply; 31+ messages in thread
From: Ben Hutchings @ 2009-01-19 17:08 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, linux-net-drivers

On Wed, 2009-01-07 at 11:58 -0800, Mike Travis wrote:
> From: Rusty Russell <rusty@rustcorp.com.au>
> 
> 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.
> 
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> Signed-off-by: Mike Travis <travis@sgi.com>
> Cc: Ben Hutchings <bhutchings@solarflare.com>
> Cc: linux-net-drivers@solarflare.com
Acked-by: Ben Hutchings <bhutchings@solarflare.com>

This seems to work.

> ---
>  drivers/net/sfc/efx.c |   15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
> --- a/drivers/net/sfc/efx.c
> +++ b/drivers/net/sfc/efx.c
> @@ -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");
[...]

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.


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/5] cpumask: Use topology_core_cpumask()/topology_thread_cpumask()
  2009-01-07 19:58 ` [PATCH 2/5] cpumask: Use topology_core_cpumask()/topology_thread_cpumask() Mike Travis
@ 2009-01-19 17:11   ` Ben Hutchings
  0 siblings, 0 replies; 31+ messages in thread
From: Ben Hutchings @ 2009-01-19 17:11 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, linux-net-drivers

On Wed, 2009-01-07 at 11:58 -0800, Mike Travis wrote:
> From: Rusty Russell <rusty@rustcorp.com.au>
> 
> 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()
> 
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> Signed-off-by: Mike Travis <travis@sgi.com>
> Cc: linux-net-drivers@solarflare.com
Acked-by: Ben Hutchings <bhutchings@solarflare.com>

Ben.

-- 
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.


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/5] cpumask: convert drivers/net/sfc [PATCH supplied]
       [not found]     ` <200901201209.34854.rusty@rustcorp.com.au>
@ 2009-01-20 18:26       ` Mike Travis
  2009-01-26 15:04       ` [PATCH] sfc: modify allocation error message Mike Travis
  1 sibling, 0 replies; 31+ messages in thread
From: Mike Travis @ 2009-01-20 18:26 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Ben Hutchings, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, linux-net-drivers

Rusty Russell wrote:
> On Tuesday 20 January 2009 03:38:30 Ben Hutchings wrote:
>> On Wed, 2009-01-07 at 11:58 -0800, Mike Travis wrote:
>>> From: Rusty Russell <rusty@rustcorp.com.au>
>>>
>>> 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.
>>>
>>> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>>> Signed-off-by: Mike Travis <travis@sgi.com>
>>> Cc: Ben Hutchings <bhutchings@solarflare.com>
>>> Cc: linux-net-drivers@solarflare.com
>> Acked-by: Ben Hutchings <bhutchings@solarflare.com>
>>
>> This seems to work.
>>
>>> ---
>>>  drivers/net/sfc/efx.c |   15 +++++++++++----
>>>  1 file changed, 11 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
>>> --- a/drivers/net/sfc/efx.c
>>> +++ b/drivers/net/sfc/efx.c
>>> @@ -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");
>> [...]
>>
>> 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".
> 
> 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.

Signed-off-by: Mike Travis <travis@sgi.com>
---
 drivers/net/sfc/efx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6-for-ingo.orig/drivers/net/sfc/efx.c
+++ linux-2.6-for-ingo/drivers/net/sfc/efx.c
@@ -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;
 	}
 



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 3/5] cpumask: convert misc driver functions
  2009-01-07 19:58 ` [PATCH 3/5] cpumask: convert misc driver functions Mike Travis
  2009-01-10 10:57   ` Rusty Russell
  2009-01-16 18:42   ` Tony Luck
@ 2009-01-22 13:11   ` Robert Richter
  2009-01-22 13:14     ` [PATCH] cpumask: modifiy oprofile initialization Robert Richter
  2 siblings, 1 reply; 31+ messages in thread
From: Robert Richter @ 2009-01-22 13:11 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Rusty Russell, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, Dean Nelson, oprofile-list,
	Jeremy Fitzhardinge, Chris Wright, virtualization, xen-devel,
	Ursula Braun, linux390, linux-s390

On 07.01.09 11:58:35, Mike Travis wrote:
> From: Rusty Russell <rusty@rustcorp.com.au>
> 
> Impact: use new cpumask API.
> 
> Convert misc driver functions to use struct cpumask.
> 
> To Do:
>   - Convert iucv_buffer_cpumask to cpumask_var_t.
> 
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> Signed-off-by: Mike Travis <travis@sgi.com>
> Acked-by: Dean Nelson <dcn@sgi.com>
> Cc: Robert Richter <robert.richter@amd.com>
> Cc: oprofile-list@lists.sf.net
> Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
> Cc: Chris Wright <chrisw@sous-sol.org>
> Cc: virtualization@lists.osdl.org
> Cc: xen-devel@lists.xensource.com
> Cc: Ursula Braun <ursula.braun@de.ibm.com>
> Cc: linux390@de.ibm.com
> Cc: linux-s390@vger.kernel.org
> ---
>  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 ++++++++-

Acked-by: Robert Richter <robert.richter@amd.com>

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

-Robert

>  drivers/xen/manage.c           |    2 +-
>  net/iucv/iucv.c                |   28 ++++++++++++++++++----------
>  7 files changed, 51 insertions(+), 18 deletions(-)

-- 
Advanced Micro Devices, Inc.
Operating System Research Center
email: robert.richter@amd.com


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] cpumask: modifiy oprofile initialization
  2009-01-22 13:11   ` Robert Richter
@ 2009-01-22 13:14     ` Robert Richter
  2009-01-22 13:37       ` Ingo Molnar
  2009-01-22 16:56       ` Mike Travis
  0 siblings, 2 replies; 31+ messages in thread
From: Robert Richter @ 2009-01-22 13:14 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Tony Luck, LKML, Robert Richter, Rusty Russell, Mike Travis

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 <rusty@rustcorp.com.au>
Cc: Mike Travis <travis@sgi.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
---
 drivers/oprofile/buffer_sync.c |   20 ++++++--------------
 drivers/oprofile/buffer_sync.h |    4 ----
 drivers/oprofile/oprof.c       |    9 +--------
 3 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index c3ea5fa..8574622 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -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
diff --git a/drivers/oprofile/buffer_sync.h b/drivers/oprofile/buffer_sync.h
index 0ebf5db..3110732 100644
--- a/drivers/oprofile/buffer_sync.h
+++ b/drivers/oprofile/buffer_sync.h
@@ -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 */
diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
index ced39f6..3cffce9 100644
--- a/drivers/oprofile/oprof.c
+++ b/drivers/oprofile/oprof.c
@@ -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();
 }
 
 
-- 
1.6.1



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] cpumask: modifiy oprofile initialization
  2009-01-22 13:14     ` [PATCH] cpumask: modifiy oprofile initialization Robert Richter
@ 2009-01-22 13:37       ` Ingo Molnar
  2009-01-22 17:20         ` Mike Travis
  2009-01-22 19:41         ` Mike Travis
  2009-01-22 16:56       ` Mike Travis
  1 sibling, 2 replies; 31+ messages in thread
From: Ingo Molnar @ 2009-01-22 13:37 UTC (permalink / raw)
  To: Robert Richter; +Cc: Tony Luck, LKML, Rusty Russell, Mike Travis


* Robert Richter <robert.richter@amd.com> wrote:

> 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 <rusty@rustcorp.com.au>
> Cc: Mike Travis <travis@sgi.com>
> Signed-off-by: Robert Richter <robert.richter@amd.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] cpumask: modifiy oprofile initialization
  2009-01-22 13:14     ` [PATCH] cpumask: modifiy oprofile initialization Robert Richter
  2009-01-22 13:37       ` Ingo Molnar
@ 2009-01-22 16:56       ` Mike Travis
  2009-01-23 14:12         ` Robert Richter
  1 sibling, 1 reply; 31+ messages in thread
From: Mike Travis @ 2009-01-22 16:56 UTC (permalink / raw)
  To: Robert Richter; +Cc: Ingo Molnar, Tony Luck, LKML, Rusty Russell

Robert Richter wrote:
> 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

> 
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Mike Travis <travis@sgi.com>
> Signed-off-by: Robert Richter <robert.richter@amd.com>
> ---
>  drivers/oprofile/buffer_sync.c |   20 ++++++--------------
>  drivers/oprofile/buffer_sync.h |    4 ----
>  drivers/oprofile/oprof.c       |    9 +--------
>  3 files changed, 7 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
> index c3ea5fa..8574622 100644
> --- a/drivers/oprofile/buffer_sync.c
> +++ b/drivers/oprofile/buffer_sync.c
> @@ -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
> diff --git a/drivers/oprofile/buffer_sync.h b/drivers/oprofile/buffer_sync.h
> index 0ebf5db..3110732 100644
> --- a/drivers/oprofile/buffer_sync.h
> +++ b/drivers/oprofile/buffer_sync.h
> @@ -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 */
> diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
> index ced39f6..3cffce9 100644
> --- a/drivers/oprofile/oprof.c
> +++ b/drivers/oprofile/oprof.c
> @@ -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();
>  }
>  
>  


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] cpumask: modifiy oprofile initialization
  2009-01-22 13:37       ` Ingo Molnar
@ 2009-01-22 17:20         ` Mike Travis
  2009-01-22 17:40           ` Ingo Molnar
  2009-01-22 19:41         ` Mike Travis
  1 sibling, 1 reply; 31+ messages in thread
From: Mike Travis @ 2009-01-22 17:20 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Robert Richter, Tony Luck, LKML, Rusty Russell

Ingo Molnar wrote:
> * Robert Richter <robert.richter@amd.com> wrote:
> 
>> 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 <rusty@rustcorp.com.au>
>> Cc: Mike Travis <travis@sgi.com>
>> Signed-off-by: Robert Richter <robert.richter@amd.com>
>> ---
>>  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

Hi Ingo,

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

Thanks,
Mike

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] cpumask: modifiy oprofile initialization
  2009-01-22 17:20         ` Mike Travis
@ 2009-01-22 17:40           ` Ingo Molnar
  0 siblings, 0 replies; 31+ messages in thread
From: Ingo Molnar @ 2009-01-22 17:40 UTC (permalink / raw)
  To: Mike Travis; +Cc: Robert Richter, Tony Luck, LKML, Rusty Russell


* Mike Travis <travis@sgi.com> wrote:

> Ingo Molnar wrote:
> > * Robert Richter <robert.richter@amd.com> wrote:
> > 
> >> 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 <rusty@rustcorp.com.au>
> >> Cc: Mike Travis <travis@sgi.com>
> >> Signed-off-by: Robert Richter <robert.richter@amd.com>
> >> ---
> >>  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
> 
> 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] cpumask: modifiy oprofile initialization
  2009-01-22 13:37       ` Ingo Molnar
  2009-01-22 17:20         ` Mike Travis
@ 2009-01-22 19:41         ` Mike Travis
  1 sibling, 0 replies; 31+ messages in thread
From: Mike Travis @ 2009-01-22 19:41 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Robert Richter, Tony Luck, LKML, Rusty Russell

Ingo Molnar wrote:
> * Robert Richter <robert.richter@amd.com> wrote:
> 
>> 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 <rusty@rustcorp.com.au>
>> Cc: Mike Travis <travis@sgi.com>
>> Signed-off-by: Robert Richter <robert.richter@amd.com>
>> ---
>>  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

Built and tested on an Altix 4700.

Cheers,
Mike


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] cpumask: modifiy oprofile initialization
  2009-01-22 16:56       ` Mike Travis
@ 2009-01-23 14:12         ` Robert Richter
  0 siblings, 0 replies; 31+ messages in thread
From: Robert Richter @ 2009-01-23 14:12 UTC (permalink / raw)
  To: Mike Travis; +Cc: Ingo Molnar, Tony Luck, LKML, Rusty Russell

On 22.01.09 08:56:51, Mike Travis wrote:
> Robert Richter wrote:
> > 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

-- 
Advanced Micro Devices, Inc.
Operating System Research Center
email: robert.richter@amd.com


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] sfc: modify allocation error message
       [not found]     ` <200901201209.34854.rusty@rustcorp.com.au>
  2009-01-20 18:26       ` [PATCH 4/5] cpumask: convert drivers/net/sfc [PATCH supplied] Mike Travis
@ 2009-01-26 15:04       ` Mike Travis
  2009-01-27 12:13         ` Ben Hutchings
  1 sibling, 1 reply; 31+ messages in thread
From: Mike Travis @ 2009-01-26 15:04 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Ben Hutchings, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, linux-net-drivers

Rusty Russell wrote:
> On Tuesday 20 January 2009 03:38:30 Ben Hutchings wrote:
>> On Wed, 2009-01-07 at 11:58 -0800, Mike Travis wrote:
>>> From: Rusty Russell <rusty@rustcorp.com.au>
>>>
>>> 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.
>>>
>>> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>>> Signed-off-by: Mike Travis <travis@sgi.com>
>>> Cc: Ben Hutchings <bhutchings@solarflare.com>
>>> Cc: linux-net-drivers@solarflare.com
>> Acked-by: Ben Hutchings <bhutchings@solarflare.com>
>>
>> This seems to work.
>>
>>> ---
>>>  drivers/net/sfc/efx.c |   15 +++++++++++----
>>>  1 file changed, 11 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
>>> --- a/drivers/net/sfc/efx.c
>>> +++ b/drivers/net/sfc/efx.c
>>> @@ -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");
>> [...]
>>
>> 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".
> 
> 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.

Signed-off-by: Mike Travis <travis@sgi.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/sfc/efx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6-for-ingo.orig/drivers/net/sfc/efx.c
+++ linux-2.6-for-ingo/drivers/net/sfc/efx.c
@@ -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;
 	}
 


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] sfc: modify allocation error message
  2009-01-26 15:04       ` [PATCH] sfc: modify allocation error message Mike Travis
@ 2009-01-27 12:13         ` Ben Hutchings
  0 siblings, 0 replies; 31+ messages in thread
From: Ben Hutchings @ 2009-01-27 12:13 UTC (permalink / raw)
  To: Mike Travis
  Cc: Rusty Russell, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Jack Steiner, linux-kernel, linux-net-drivers

On Mon, 2009-01-26 at 07:04 -0800, Mike Travis wrote:
[...]
> Subject: sfc: modify allocation error message
> 
> Impact: change error message when alloc_cpumask_var fails.
> 
> Signed-off-by: Mike Travis <travis@sgi.com>
> Cc: Ben Hutchings <bhutchings@solarflare.com>
Acked-by: Ben Hutchings <bhutchings@solarflare.com>

> --
>  drivers/net/sfc/efx.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> --- linux-2.6-for-ingo.orig/drivers/net/sfc/efx.c
> +++ linux-2.6-for-ingo/drivers/net/sfc/efx.c
> @@ -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;
>         }
>  

-- 
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.


^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2009-01-27 12:13 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-07 19:58 [PATCH 0/5] cpumask: more cpumask updates Mike Travis
2009-01-07 19:58 ` [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t Mike Travis
2009-01-07 20:27   ` Yinghai Lu
2009-01-07 22:32     ` Mike Travis
2009-01-08  3:15       ` Yinghai Lu
2009-01-08 15:45         ` Mike Travis
2009-01-08 19:31           ` Yinghai Lu
2009-01-08 18:40         ` [PATCH 1/5] cpumask: update irq_desc to use cpumask_var_t: fix Mike Travis
2009-01-07 19:58 ` [PATCH 2/5] cpumask: Use topology_core_cpumask()/topology_thread_cpumask() Mike Travis
2009-01-19 17:11   ` Ben Hutchings
2009-01-07 19:58 ` [PATCH 3/5] cpumask: convert misc driver functions Mike Travis
2009-01-10 10:57   ` Rusty Russell
2009-01-16 18:42   ` Tony Luck
2009-01-16 18:55     ` Mike Travis
2009-01-16 22:02     ` Mike Travis
2009-01-22 13:11   ` Robert Richter
2009-01-22 13:14     ` [PATCH] cpumask: modifiy oprofile initialization Robert Richter
2009-01-22 13:37       ` Ingo Molnar
2009-01-22 17:20         ` Mike Travis
2009-01-22 17:40           ` Ingo Molnar
2009-01-22 19:41         ` Mike Travis
2009-01-22 16:56       ` Mike Travis
2009-01-23 14:12         ` Robert Richter
2009-01-07 19:58 ` [PATCH 4/5] cpumask: convert drivers/net/sfc Mike Travis
2009-01-19 17:08   ` Ben Hutchings
     [not found]     ` <200901201209.34854.rusty@rustcorp.com.au>
2009-01-20 18:26       ` [PATCH 4/5] cpumask: convert drivers/net/sfc [PATCH supplied] Mike Travis
2009-01-26 15:04       ` [PATCH] sfc: modify allocation error message Mike Travis
2009-01-27 12:13         ` Ben Hutchings
2009-01-07 19:58 ` [PATCH 5/5] cpumask: convert other misc kernel functions Mike Travis
2009-01-07 20:52 ` [PATCH 0/5] cpumask: more cpumask updates Ingo Molnar
2009-01-07 21:20   ` Mike Travis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).