Skip to contentSkip to conversation

core: fix build error when referencing arch specific structures

PATCH In review [email protected] 4 participants 11 messages Sep 7, 2007

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

cover core: fix build error when referencing arch specific structures

Since the core kernel routines need to reference cpu_sibling_map, whether it be a static array or a per_cpu data variable, an access function has been defined.

In addition, changes have been made to the ia64 and ppc64 arch's to move the cpu_sibling_map from a static cpumask_t array [NR_CPUS] to be per_cpu cpumask_t arrays.

Note that I do not have the ability to build or test patch 3/3, the ppc64 changes.

Patches are referenced against 2.6.23-rc4-mm1 .

Signature · 5 lines
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

PATCH 1/3 core: Provide an arch independent means of accessing cpu_sibling_map

As the block/blktrace.c and kernel/sched.c are common (core) files for all architectures, an access function has been defined for referencing the cpu_sibling_map array.

---
 arch/ia64/Kconfig        |    1 -
 block/blktrace.c         |    2 +-
 include/asm-i386/smp.h   |    1 +
 include/asm-x86_64/smp.h |    1 +
 include/linux/smp.h      |    6 ++++++
 kernel/sched.c           |    8 ++++----
 6 files changed, 13 insertions(+), 6 deletions(-)
arch/ia64/Kconfig +0 -1
@@ -308,7 +308,6 @@
 config SCHED_SMT
 	bool "SMT scheduler support"
 	depends on SMP
-	depends on BROKEN
 	help
 	  Improves the CPU scheduler's decision making when dealing with
 	  Intel IA64 chips with MultiThreading at a cost of slightly increased
block/blktrace.c +1 -1
@@ -536,7 +536,7 @@
 	for_each_online_cpu(cpu) {
 		unsigned long long *cpu_off, *sibling_off;
 
-		for_each_cpu_mask(i, per_cpu(cpu_sibling_map, cpu)) {
+		for_each_cpu_mask(i, cpu_sibling_map(cpu)) {
 			if (i == cpu)
 				continue;
 
kernel/sched.c +4 -4
@@ -5905,7 +5905,7 @@
 			     struct sched_group **sg)
 {
 	int group;
-	cpumask_t mask = per_cpu(cpu_sibling_map, cpu);
+	cpumask_t mask = cpu_sibling_map(cpu);
 	cpus_and(mask, mask, *cpu_map);
 	group = first_cpu(mask);
 	if (sg)
@@ -5934,7 +5934,7 @@
 	cpus_and(mask, mask, *cpu_map);
 	group = first_cpu(mask);
 #elif defined(CONFIG_SCHED_SMT)
-	cpumask_t mask = per_cpu(cpu_sibling_map, cpu);
+	cpumask_t mask = cpu_sibling_map(cpu);
 	cpus_and(mask, mask, *cpu_map);
 	group = first_cpu(mask);
 #else
@@ -6169,7 +6169,7 @@
 		p = sd;
 		sd = &per_cpu(cpu_domains, i);
 		*sd = SD_SIBLING_INIT;
-		sd->span = per_cpu(cpu_sibling_map, i);
+		sd->span = cpu_sibling_map(i);
 		cpus_and(sd->span, sd->span, *cpu_map);
 		sd->parent = p;
 		p->child = sd;
@@ -6180,7 +6180,7 @@
 #ifdef CONFIG_SCHED_SMT
 	/* Set up CPU (sibling) groups */
 	for_each_cpu_mask(i, *cpu_map) {
-		cpumask_t this_sibling_map = per_cpu(cpu_sibling_map, i);
+		cpumask_t this_sibling_map = cpu_sibling_map(i);
 		cpus_and(this_sibling_map, this_sibling_map, *cpu_map);
 		if (i != first_cpu(this_sibling_map))
 			continue;
include/asm-i386/smp.h +1 -0
@@ -32,6 +32,7 @@
 extern int smp_num_siblings;
 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
 DECLARE_PER_CPU(cpumask_t, cpu_core_map);
+#define cpu_sibling_map(cpu) per_cpu(cpu_sibling_map, cpu)
 
 extern void (*mtrr_hook) (void);
 extern void zap_low_mappings (void);
include/asm-x86_64/smp.h +1 -0
@@ -47,6 +47,7 @@
 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
 DECLARE_PER_CPU(cpumask_t, cpu_core_map);
 DECLARE_PER_CPU(u8, cpu_llc_id);
+#define cpu_sibling_map(cpu) per_cpu(cpu_sibling_map, cpu)
 
 #define SMP_TRAMPOLINE_BASE 0x6000
 
include/linux/smp.h +6 -0
@@ -18,6 +18,12 @@
 #include <linux/thread_info.h>
 #include <asm/smp.h>
 
+#ifdef CONFIG_SCHED_SMT
+#ifndef cpu_sibling_map
+#define cpu_sibling_map(cpu) cpu_sibling_map[cpu]
+#endif
+#endif
+
 /*
  * main cross-CPU interfaces, handles INIT, TLB flush, STOP, etc.
  * (defined in asm header):
Signature · 5 lines
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

PATCH 2/3 ia64: Convert cpu_sibling_map to a per_cpu data array

In reply to [email protected]

Convert cpu_sibling_map to a per_cpu cpumask_t array for the ia64 architecture.

There was one access to cpu_sibling_map before the per_cpu data area was created, so that step was moved to after the per_cpu area is setup.

Note also that references to cpu_sibling_map have been changed to use the cpu_sibling_map() function defined in patch 1/3.

Tested and verified on an A4700.

---
 arch/ia64/kernel/setup.c    |    4 ----
 arch/ia64/kernel/smpboot.c  |   18 ++++++++++--------
 arch/ia64/mm/contig.c       |    6 ++++++
 include/asm-ia64/smp.h      |    3 ++-
 include/asm-ia64/topology.h |    2 +-
 5 files changed, 19 insertions(+), 14 deletions(-)
arch/ia64/kernel/setup.c +0 -4
@@ -528,10 +528,6 @@
 
 #ifdef CONFIG_SMP
 	cpu_physical_id(0) = hard_smp_processor_id();
-
-	cpu_set(0, cpu_sibling_map[0]);
-	cpu_set(0, cpu_core_map[0]);
-
 	check_for_logical_procs();
 	if (smp_num_cpucores > 1)
 		printk(KERN_INFO
arch/ia64/kernel/smpboot.c +10 -8
@@ -138,7 +138,9 @@
 EXPORT_SYMBOL(cpu_possible_map);
 
 cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned;
-cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned;
+DEFINE_PER_CPU_SHARED_ALIGNED(cpumask_t, cpu_sibling_map);
+EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
+
 int smp_num_siblings = 1;
 int smp_num_cpucores = 1;
 
@@ -650,12 +652,12 @@
 {
 	int i;
 
-	for_each_cpu_mask(i, cpu_sibling_map[cpu])
-		cpu_clear(cpu, cpu_sibling_map[i]);
+	for_each_cpu_mask(i, cpu_sibling_map(cpu))
+		cpu_clear(cpu, cpu_sibling_map(i));
 	for_each_cpu_mask(i, cpu_core_map[cpu])
 		cpu_clear(cpu, cpu_core_map[i]);
 
-	cpu_sibling_map[cpu] = cpu_core_map[cpu] = CPU_MASK_NONE;
+	cpu_sibling_map(cpu) = cpu_core_map[cpu] = CPU_MASK_NONE;
 }
 
 static void
@@ -666,7 +668,7 @@
 	if (cpu_data(cpu)->threads_per_core == 1 &&
 	    cpu_data(cpu)->cores_per_socket == 1) {
 		cpu_clear(cpu, cpu_core_map[cpu]);
-		cpu_clear(cpu, cpu_sibling_map[cpu]);
+		cpu_clear(cpu, cpu_sibling_map(cpu));
 		return;
 	}
 
@@ -807,8 +809,8 @@
 			cpu_set(i, cpu_core_map[cpu]);
 			cpu_set(cpu, cpu_core_map[i]);
 			if (cpu_data(cpu)->core_id == cpu_data(i)->core_id) {
-				cpu_set(i, cpu_sibling_map[cpu]);
-				cpu_set(cpu, cpu_sibling_map[i]);
+				cpu_set(i, cpu_sibling_map(cpu));
+				cpu_set(cpu, cpu_sibling_map(i));
 			}
 		}
 	}
@@ -839,7 +841,7 @@
 
 	if (cpu_data(cpu)->threads_per_core == 1 &&
 	    cpu_data(cpu)->cores_per_socket == 1) {
-		cpu_set(cpu, cpu_sibling_map[cpu]);
+		cpu_set(cpu, cpu_sibling_map(cpu));
 		cpu_set(cpu, cpu_core_map[cpu]);
 		return 0;
 	}
include/asm-ia64/smp.h +2 -1
@@ -58,7 +58,8 @@
 
 extern cpumask_t cpu_online_map;
 extern cpumask_t cpu_core_map[NR_CPUS];
-extern cpumask_t cpu_sibling_map[NR_CPUS];
+DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
+#define cpu_sibling_map(cpu) per_cpu(cpu_sibling_map, cpu)
 extern int smp_num_siblings;
 extern int smp_num_cpucores;
 extern void __iomem *ipi_base_addr;
include/asm-ia64/topology.h +1 -1
@@ -112,7 +112,7 @@
 #define topology_physical_package_id(cpu)	(cpu_data(cpu)->socket_id)
 #define topology_core_id(cpu)			(cpu_data(cpu)->core_id)
 #define topology_core_siblings(cpu)		(cpu_core_map[cpu])
-#define topology_thread_siblings(cpu)		(cpu_sibling_map[cpu])
+#define topology_thread_siblings(cpu)		(cpu_sibling_map(cpu))
 #define smt_capable() 				(smp_num_siblings > 1)
 #endif
 
arch/ia64/mm/contig.c +6 -0
@@ -212,6 +212,12 @@
 			cpu_data += PERCPU_PAGE_SIZE;
 			per_cpu(local_per_cpu_offset, cpu) = __per_cpu_offset[cpu];
 		}
+		/*
+		 * cpu_sibling_map is now a per_cpu variable - it needs to
+		 * be accessed after per_cpu_init() sets up the per_cpu area.
+		 */
+		cpu_set(0, cpu_sibling_map(0));
+		cpu_set(0, cpu_core_map[0]);
 	}
 	return __per_cpu_start + __per_cpu_offset[smp_processor_id()];
 }
Signature · 5 lines
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw

PATCH 3/3 ppc64: Convert cpu_sibling_map to a per_cpu data array

In reply to [email protected]

Convert cpu_sibling_map to a per_cpu cpumask_t array for the ppc64 architecture.

Note: these changes have not been built nor tested.

Note: I also don't know if these changes are particularly relevant for the ppc64 architecture.

---
 arch/powerpc/kernel/setup-common.c        |    4 ++--
 arch/powerpc/kernel/smp.c                 |    4 ++--
 arch/powerpc/platforms/cell/cbe_cpufreq.c |    2 +-
 include/asm-powerpc/smp.h                 |    3 ++-
 include/asm-powerpc/topology.h            |    2 +-
 5 files changed, 8 insertions(+), 7 deletions(-)
arch/powerpc/kernel/setup-common.c +2 -2
@@ -415,9 +415,9 @@
 	 * Do the sibling map; assume only two threads per processor.
 	 */
 	for_each_possible_cpu(cpu) {
-		cpu_set(cpu, cpu_sibling_map[cpu]);
+		cpu_set(cpu, cpu_sibling_map(cpu));
 		if (cpu_has_feature(CPU_FTR_SMT))
-			cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]);
+			cpu_set(cpu ^ 0x1, cpu_sibling_map(cpu));
 	}
 
 	vdso_data->processorCount = num_present_cpus();
arch/powerpc/kernel/smp.c +2 -2
@@ -61,11 +61,11 @@
 
 cpumask_t cpu_possible_map = CPU_MASK_NONE;
 cpumask_t cpu_online_map = CPU_MASK_NONE;
-cpumask_t cpu_sibling_map[NR_CPUS] = { [0 ... NR_CPUS-1] = CPU_MASK_NONE };
+DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE;
 
 EXPORT_SYMBOL(cpu_online_map);
 EXPORT_SYMBOL(cpu_possible_map);
-EXPORT_SYMBOL(cpu_sibling_map);
+EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
 
 /* SMP operations for this machine */
 struct smp_ops_t *smp_ops;
arch/powerpc/platforms/cell/cbe_cpufreq.c +1 -1
@@ -117,7 +117,7 @@
 	policy->cur = cbe_freqs[cur_pmode].frequency;
 
 #ifdef CONFIG_SMP
-	policy->cpus = cpu_sibling_map[policy->cpu];
+	policy->cpus = cpu_sibling_map(policy->cpu);
 #endif
 
 	cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);
include/asm-powerpc/smp.h +2 -1
@@ -58,7 +58,8 @@
 					(smp_hw_index[(cpu)] = (phys))
 #endif
 
-extern cpumask_t cpu_sibling_map[NR_CPUS];
+DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
+#define cpu_sibling_map(cpu) per_cpu(cpu_sibling_map, cpu)
 
 /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
  *
include/asm-powerpc/topology.h +1 -1
@@ -108,7 +108,7 @@
 #ifdef CONFIG_PPC64
 #include <asm/smp.h>
 
-#define topology_thread_siblings(cpu)	(cpu_sibling_map[cpu])
+#define topology_thread_siblings(cpu)	(cpu_sibling_map(cpu))
 #endif
 #endif
 
Signature · 5 lines
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#4 lore raw

Re: [PATCH 3/3] ppc64: Convert cpu_sibling_map to a per_cpu data array

Quoted 75 lines · [email protected] wrote:

Convert cpu_sibling_map to a per_cpu cpumask_t array for the ppc64 architecture.

Note: these changes have not been built nor tested.

Note: I also don't know if these changes are particularly relevant for the ppc64 architecture.

---
 arch/powerpc/kernel/setup-common.c        |    4 ++--
 arch/powerpc/kernel/smp.c                 |    4 ++--
 arch/powerpc/platforms/cell/cbe_cpufreq.c |    2 +-
 include/asm-powerpc/smp.h                 |    3 ++-
 include/asm-powerpc/topology.h            |    2 +-
 5 files changed, 8 insertions(+), 7 deletions(-)
arch/powerpc/kernel/setup-common.c +2 -2
@@ -415,9 +415,9 @@
 	 * Do the sibling map; assume only two threads per processor.
 	 */
 	for_each_possible_cpu(cpu) {
-		cpu_set(cpu, cpu_sibling_map[cpu]);
+		cpu_set(cpu, cpu_sibling_map(cpu));
 		if (cpu_has_feature(CPU_FTR_SMT))
-			cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]);
+			cpu_set(cpu ^ 0x1, cpu_sibling_map(cpu));
 	}
 
 	vdso_data->processorCount = num_present_cpus();
arch/powerpc/kernel/smp.c +2 -2
@@ -61,11 +61,11 @@
 
 cpumask_t cpu_possible_map = CPU_MASK_NONE;
 cpumask_t cpu_online_map = CPU_MASK_NONE;
-cpumask_t cpu_sibling_map[NR_CPUS] = { [0 ... NR_CPUS-1] = CPU_MASK_NONE };
+DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE;
 
 EXPORT_SYMBOL(cpu_online_map);
 EXPORT_SYMBOL(cpu_possible_map);
-EXPORT_SYMBOL(cpu_sibling_map);
+EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
 
 /* SMP operations for this machine */
 struct smp_ops_t *smp_ops;
arch/powerpc/platforms/cell/cbe_cpufreq.c +1 -1
@@ -117,7 +117,7 @@
 	policy->cur = cbe_freqs[cur_pmode].frequency;
 
 #ifdef CONFIG_SMP
-	policy->cpus = cpu_sibling_map[policy->cpu];
+	policy->cpus = cpu_sibling_map(policy->cpu);
 #endif
 
 	cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);
include/asm-powerpc/smp.h +2 -1
@@ -58,7 +58,8 @@
 					(smp_hw_index[(cpu)] = (phys))
 #endif
 
-extern cpumask_t cpu_sibling_map[NR_CPUS];
+DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
+#define cpu_sibling_map(cpu) per_cpu(cpu_sibling_map, cpu)
 
 /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
  *

include/asm-powerpc/topology.h line 114

Quoted 8 lines
include/asm-powerpc/topology.h +1 -1
@@ -108,7 +108,7 @@
 #ifdef CONFIG_PPC64
 #include <asm/smp.h>
 
-#define topology_thread_siblings(cpu)	(cpu_sibling_map[cpu])
+#define topology_thread_siblings(cpu)	(cpu_sibling_map(cpu))
 #endif
 #endif
 

Hi Mike,

After applying the patch, the build fails with following error

CHK include/linux/version.h
CHK include/linux/utsrelease.h
CC arch/powerpc/kernel/asm-offsets.s
In file included from include/linux/smp.h:19,
from include/linux/topology.h:33,
from include/linux/mmzone.h:660,
from include/linux/gfp.h:4,
from include/linux/slab.h:14,
from include/linux/percpu.h:5,
from include/asm/time.h:18,
from include/asm/cputime.h:26,
from include/linux/sched.h:65,
from arch/powerpc/kernel/asm-offsets.c:17:
include/asm/smp.h:61: error: expected declaration specifiers or ?...? before ?cpu_sibling_map? include/asm/smp.h:61: warning: data definition has no type or storage class include/asm/smp.h:61: warning: type defaults to ?int? in declaration of ?DECLARE_PER_CPU? make[1]: *** [arch/powerpc/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2

Thanks & Regards,
Kamalesh Babulal.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw

Re: [PATCH 3/3] ppc64: Convert cpu_sibling_map to a per_cpu data array

Quoted 109 lines · Kamalesh Babulal
Quoted 77 lines · [email protected] wrote:

Convert cpu_sibling_map to a per_cpu cpumask_t array for the ppc64 architecture.

Note: these changes have not been built nor tested.

Note: I also don't know if these changes are particularly relevant for the ppc64 architecture.

---
 arch/powerpc/kernel/setup-common.c        |    4 ++--
 arch/powerpc/kernel/smp.c                 |    4 ++--
 arch/powerpc/platforms/cell/cbe_cpufreq.c |    2 +-
 include/asm-powerpc/smp.h                 |    3 ++-
 include/asm-powerpc/topology.h            |    2 +-
 5 files changed, 8 insertions(+), 7 deletions(-)
arch/powerpc/kernel/setup-common.c +2 -2
@@ -415,9 +415,9 @@
      * Do the sibling map; assume only two threads per processor.
      */
     for_each_possible_cpu(cpu) {
-        cpu_set(cpu, cpu_sibling_map[cpu]);
+        cpu_set(cpu, cpu_sibling_map(cpu));
         if (cpu_has_feature(CPU_FTR_SMT))
-            cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]);
+            cpu_set(cpu ^ 0x1, cpu_sibling_map(cpu));
     }
 
     vdso_data->processorCount = num_present_cpus();
arch/powerpc/kernel/smp.c +2 -2
@@ -61,11 +61,11 @@
 
 cpumask_t cpu_possible_map = CPU_MASK_NONE;
 cpumask_t cpu_online_map = CPU_MASK_NONE;
-cpumask_t cpu_sibling_map[NR_CPUS] = { [0 ... NR_CPUS-1] = 
 CPU_MASK_NONE };
+DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE;
 
 EXPORT_SYMBOL(cpu_online_map);
 EXPORT_SYMBOL(cpu_possible_map);
-EXPORT_SYMBOL(cpu_sibling_map);
+EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
 
 /* SMP operations for this machine */

struct smp_ops_t *smp_ops;

arch/powerpc/platforms/cell/cbe_cpufreq.c +1 -1
@@ -117,7 +117,7 @@
     policy->cur = cbe_freqs[cur_pmode].frequency;
 
 #ifdef CONFIG_SMP
-    policy->cpus = cpu_sibling_map[policy->cpu];
+    policy->cpus = cpu_sibling_map(policy->cpu);
 #endif
 
     cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);
include/asm-powerpc/smp.h +2 -1
@@ -58,7 +58,8 @@
                     (smp_hw_index[(cpu)] = (phys))
 #endif
 
-extern cpumask_t cpu_sibling_map[NR_CPUS];
+DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
+#define cpu_sibling_map(cpu) per_cpu(cpu_sibling_map, cpu)
 
 /* Since OpenPIC has only 4 IPIs, we use slightly different message 

numbers.
*

include/asm-powerpc/topology.h line 114

Quoted 8 lines
include/asm-powerpc/topology.h +1 -1
@@ -108,7 +108,7 @@
 #ifdef CONFIG_PPC64
 #include <asm/smp.h>
 
-#define topology_thread_siblings(cpu)    (cpu_sibling_map[cpu])
+#define topology_thread_siblings(cpu)    (cpu_sibling_map(cpu))
 #endif
 #endif
 

Hi Mike,

After applying the patch, the build fails with following error

CHK include/linux/version.h
CHK include/linux/utsrelease.h
CC arch/powerpc/kernel/asm-offsets.s
In file included from include/linux/smp.h:19,
from include/linux/topology.h:33,
from include/linux/mmzone.h:660,
from include/linux/gfp.h:4,
from include/linux/slab.h:14,
from include/linux/percpu.h:5,
from include/asm/time.h:18,
from include/asm/cputime.h:26,
from include/linux/sched.h:65,
from arch/powerpc/kernel/asm-offsets.c:17:
include/asm/smp.h:61: error: expected declaration specifiers or ?...? before ?cpu_sibling_map? include/asm/smp.h:61: warning: data definition has no type or storage class include/asm/smp.h:61: warning: type defaults to ?int? in declaration of ?DECLARE_PER_CPU? make[1]: *** [arch/powerpc/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2

Quoted 2 lines

Thanks & Regards,
Kamalesh Babulal.

Hi Make,

I tried to debug and probably the patch below could help the build error

----

include/asm-powerpc/smp.h 2007-09-07 18:16:02.000000000 +0530 renamed from include/asm-powerpc/smp.h 2007-09-07 18:15:43.000000000 +0530 +0 -0
@@ -25,6 +25,7 @@
 

#ifdef CONFIG_PPC64
#include <asm/paca.h>
+#include <asm/percpu.h>
#endif

extern int boot_cpuid;

---
Thanks & Regards,
Kamalesh Babulal.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw

Re: [PATCH 3/3] ppc64: Convert cpu_sibling_map to a per_cpu data array

Quoted 134 lines · Kamalesh Babulal
Quoted 112 lines · Kamalesh Babulal
Quoted 77 lines · [email protected] wrote:

Convert cpu_sibling_map to a per_cpu cpumask_t array for the ppc64 architecture.

Note: these changes have not been built nor tested.

Note: I also don't know if these changes are particularly relevant for the ppc64 architecture.

---
 arch/powerpc/kernel/setup-common.c        |    4 ++--
 arch/powerpc/kernel/smp.c                 |    4 ++--
 arch/powerpc/platforms/cell/cbe_cpufreq.c |    2 +-
 include/asm-powerpc/smp.h                 |    3 ++-
 include/asm-powerpc/topology.h            |    2 +-
 5 files changed, 8 insertions(+), 7 deletions(-)
arch/powerpc/kernel/setup-common.c +2 -2
@@ -415,9 +415,9 @@
      * Do the sibling map; assume only two threads per processor.
      */
     for_each_possible_cpu(cpu) {
-        cpu_set(cpu, cpu_sibling_map[cpu]);
+        cpu_set(cpu, cpu_sibling_map(cpu));
         if (cpu_has_feature(CPU_FTR_SMT))
-            cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]);
+            cpu_set(cpu ^ 0x1, cpu_sibling_map(cpu));
     }
 
     vdso_data->processorCount = num_present_cpus();
arch/powerpc/kernel/smp.c +2 -2
@@ -61,11 +61,11 @@
 
 cpumask_t cpu_possible_map = CPU_MASK_NONE;
 cpumask_t cpu_online_map = CPU_MASK_NONE;
-cpumask_t cpu_sibling_map[NR_CPUS] = { [0 ... NR_CPUS-1] =
 CPU_MASK_NONE };
+DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE;
 
 EXPORT_SYMBOL(cpu_online_map);
 EXPORT_SYMBOL(cpu_possible_map);
-EXPORT_SYMBOL(cpu_sibling_map);
+EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
 
 /* SMP operations for this machine */

struct smp_ops_t *smp_ops;

arch/powerpc/platforms/cell/cbe_cpufreq.c +1 -1
@@ -117,7 +117,7 @@
     policy->cur = cbe_freqs[cur_pmode].frequency;
 
 #ifdef CONFIG_SMP
-    policy->cpus = cpu_sibling_map[policy->cpu];
+    policy->cpus = cpu_sibling_map(policy->cpu);
 #endif
 
     cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);
include/asm-powerpc/smp.h +2 -1
@@ -58,7 +58,8 @@
                     (smp_hw_index[(cpu)] = (phys))
 #endif
 
-extern cpumask_t cpu_sibling_map[NR_CPUS];
+DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
+#define cpu_sibling_map(cpu) per_cpu(cpu_sibling_map, cpu)
 
 /* Since OpenPIC has only 4 IPIs, we use slightly different message

numbers.
*

include/asm-powerpc/topology.h line 114

Quoted 8 lines
include/asm-powerpc/topology.h +1 -1
@@ -108,7 +108,7 @@
 #ifdef CONFIG_PPC64
 #include <asm/smp.h>
 
-#define topology_thread_siblings(cpu)    (cpu_sibling_map[cpu])
+#define topology_thread_siblings(cpu)    (cpu_sibling_map(cpu))
 #endif
 #endif
 

Hi Mike,

After applying the patch, the build fails with following error

CHK include/linux/version.h
CHK include/linux/utsrelease.h
CC arch/powerpc/kernel/asm-offsets.s
In file included from include/linux/smp.h:19,
from include/linux/topology.h:33,
from include/linux/mmzone.h:660,
from include/linux/gfp.h:4,
from include/linux/slab.h:14,
from include/linux/percpu.h:5,
from include/asm/time.h:18,
from include/asm/cputime.h:26,
from include/linux/sched.h:65,
from arch/powerpc/kernel/asm-offsets.c:17:
include/asm/smp.h:61: error: expected declaration specifiers or ?...? before ?cpu_sibling_map?
include/asm/smp.h:61: warning: data definition has no type or storage class
include/asm/smp.h:61: warning: type defaults to ?int? in declaration of ?DECLARE_PER_CPU?
make[1]: *** [arch/powerpc/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2

Quoted 2 lines

Thanks & Regards,
Kamalesh Babulal.

Hi Make,

I tried to debug and probably the patch below could help the build error

----

include/asm-powerpc/smp.h 2007-09-07 18:16:02.000000000 +0530 renamed from include/asm-powerpc/smp.h 2007-09-07 18:15:43.000000000 +0530 +1 -1
@@ -25,6 +25,7 @@
 
 #ifdef CONFIG_PPC64
 #include <asm/paca.h>
+#include <asm/percpu.h>
 #endif
 
 extern int boot_cpuid;
 
---
Quoted 5 lines

Thanks & Regards,
Kamalesh Babulal.

Thanks! I'll merge the above in...

Mike

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw
In reply to [email protected]
Quoted 4 lines · On Friday 07 September 2007 05:09, [email protected] wrote:

Since the core kernel routines need to reference cpu_sibling_map, whether it be a static array or a per_cpu data variable, an access function has been defined.

Quoted 8 lines

In addition, changes have been made to the ia64 and ppc64 arch's to move the cpu_sibling_map from a static cpumask_t array [NR_CPUS] to be per_cpu cpumask_t arrays.

Note that I do not have the ability to build or test patch 3/3, the ppc64 changes.

Patches are referenced against 2.6.23-rc4-mm1 .

It would be better if you could redo the patches with the original patches reverted, not incremental changes. In the end we'll need a full patch set with full changelog anyways, not a series of incremental fixes.

Also I guess some powerpc testers would be needed. Perhaps cc the maintainers?

-Andi

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#8 lore raw
Quoted 10 lines · On Fri, 7 Sep 2007 08:28:05 +0100 Andi Kleen <[email protected]> wrote:
Quoted 8 lines · On Friday 07 September 2007 05:09, [email protected] wrote:

Since the core kernel routines need to reference cpu_sibling_map, whether it be a static array or a per_cpu data variable, an access function has been defined.

In addition, changes have been made to the ia64 and ppc64 arch's to move the cpu_sibling_map from a static cpumask_t array [NR_CPUS] to be per_cpu cpumask_t arrays.

Quoted 8 lines
Quoted 4 lines

Note that I do not have the ability to build or test patch 3/3, the ppc64 changes.

Patches are referenced against 2.6.23-rc4-mm1 .

It would be better if you could redo the patches with the original patches reverted, not incremental changes. In the end we'll need a full patch set with full changelog anyways, not a series of incremental fixes.

yup

Quoted 3 lines

Also I guess some powerpc testers would be needed. Perhaps cc the maintainers?

yup

All architectures except sparc64 are now done - please have a shot at doing sparc64 as well.

I'd suggest that we not implement that cpu_sibling_map() macro and just open-code the per_cpu() everywhere. So henceforth any architecture which implements CONFIG_SCHED_SMT must implement the per-cpu sibling map.

That's nice and simple, and avoids the unpleasant pretend-function-used-as-an-lvalue trick. (Well OK, per_cpu() does that, but let's avoid resinning).

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#9 lore raw
Quoted 20 lines · Andrew Morton
Quoted 10 lines · On Fri, 7 Sep 2007 08:28:05 +0100 Andi Kleen <[email protected]> wrote:
Quoted 8 lines · On Friday 07 September 2007 05:09, [email protected] wrote:

Since the core kernel routines need to reference cpu_sibling_map, whether it be a static array or a per_cpu data variable, an access function has been defined.

In addition, changes have been made to the ia64 and ppc64 arch's to move the cpu_sibling_map from a static cpumask_t array [NR_CPUS] to be per_cpu cpumask_t arrays.

Quoted 7 lines
Quoted 4 lines

Note that I do not have the ability to build or test patch 3/3, the ppc64 changes.

Patches are referenced against 2.6.23-rc4-mm1 .

It would be better if you could redo the patches with the original patches reverted, not incremental changes. In the end we'll need a full patch set with full changelog anyways, not a series of incremental fixes.

yup

Quoted 8 lines
Quoted 3 lines

Also I guess some powerpc testers would be needed. Perhaps cc the maintainers?

yup

All architectures except sparc64 are now done - please have a shot at doing sparc64 as well.

Ok, will do. I didn't realize there was only one more that used the SCHED_SMT code.

Quoted 4 lines

I'd suggest that we not implement that cpu_sibling_map() macro and just open-code the per_cpu() everywhere. So henceforth any architecture which implements CONFIG_SCHED_SMT must implement the per-cpu sibling map.

Yes, with only one more to do it's not that daunting. ;-)

Quoted 3 lines

That's nice and simple, and avoids the unpleasant pretend-function-used-as-an-lvalue trick. (Well OK, per_cpu() does that, but let's avoid resinning).

Yes, the per_cpu macro is quite the specimen. ;-)

Thanks!
Mike

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw
In reply to Andi Kleen
Quoted 9 lines · Andi Kleen
Quoted 8 lines · On Friday 07 September 2007 05:09, [email protected] wrote:

Since the core kernel routines need to reference cpu_sibling_map, whether it be a static array or a per_cpu data variable, an access function has been defined.

In addition, changes have been made to the ia64 and ppc64 arch's to move the cpu_sibling_map from a static cpumask_t array [NR_CPUS] to be per_cpu cpumask_t arrays.

Quoted 8 lines
Quoted 4 lines

Note that I do not have the ability to build or test patch 3/3, the ppc64 changes.

Patches are referenced against 2.6.23-rc4-mm1 .

It would be better if you could redo the patches with the original patches reverted, not incremental changes. In the end we'll need a full patch set with full changelog anyways, not a series of incremental fixes.

Will do. Thanks.

I take it I should run a diff against rc4 (w/o mm1) to regenerate a complete patch, including the prior ones?

Quoted 3 lines

Also I guess some powerpc testers would be needed. Perhaps cc the maintainers?

I've been looking for where to Cc: those guys (as Andrew probably realizes from his extra "spam" from me. ;-)

Thanks!
Mike

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>