linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] percpu: Per cpu code simplification rc8-mm1-fixup with git-x86
@ 2008-01-21 20:28 travis
  2008-01-21 20:28 ` [PATCH 1/7] Modules: Fold percpu_modcopy into module.c " travis
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: travis @ 2008-01-21 20:28 UTC (permalink / raw)
  To: Andrew Morton, Andi Kleen, mingo
  Cc: Christoph Lameter, linux-mm, linux-kernel

This patchset simplifies the code that arches need to maintain to support
per cpu functionality. Most of the code is moved into arch independent
code. Only a minimal set of definitions is kept for each arch.

The patch also unifies the x86 arch so that there is only a single
asm-x86/percpu.h

Based on 2.6.24-rc8-mm1 + latest (08/1/21) git-x86

Note there are two versions of this patchset:
	- 2.6.24-rc8-mm1
	- 2.6.24-rc8-mm1 + latest (08/1/21) git-x86

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

fixup:

  - rebased from 2.6.24-rc6-mm1 to 2.6.24-rc8-mm1
    (removed changes that are in the git-x86.patch)
  - added back in missing fold-percpu_modcopy pieces

V3->V4:
  - rebased patchset on 2.6.24-rc6-mm1
    (removes the percpu_modcopy changes that are already in.)
  - change config ARCH_SETS_UP_PER_CPU_AREA to a global var
    and use select HAVE_SETUP_PER_CPU_AREA to specify.

V2->V3:
  - fix x86_64 non-SMP case
  - change SHIFT_PTR to SHIFT_PERCPU_PTR
  - fix various percpu_modcopy()'s to reference correct per_cpu_offset()
  - s390 has a special way to determine the pointer to a per cpu area

V1->V2:
- Add support for specifying attributes for per cpu declarations (preserves
  IA64 model(small) attribute).
  - Drop first patch that removes the model(small) attribute for IA64
  - Missing #endif in powerpc generic config /  Wrong Kconfig
  - Follow Randy's suggestions on how to do the Kconfig settings

-- 

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

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

* [PATCH 1/7] Modules: Fold percpu_modcopy into module.c rc8-mm1-fixup with git-x86
  2008-01-21 20:28 [PATCH 0/7] percpu: Per cpu code simplification rc8-mm1-fixup with git-x86 travis
@ 2008-01-21 20:28 ` travis
  2008-01-21 20:28 ` [PATCH 2/7] x86: Change Kconfig to HAVE_SETUP_PER_CPU_AREAF " travis
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: travis @ 2008-01-21 20:28 UTC (permalink / raw)
  To: Andrew Morton, Andi Kleen, mingo
  Cc: Christoph Lameter, linux-mm, linux-kernel, David Miller,
	Rusty Russell

[-- Attachment #1: fold-percpu_modcopy --]
[-- Type: text/plain, Size: 4350 bytes --]

percpu_modcopy() is defined multiple times in arch files. However, the only
user is module.c. Put a static definition into module.c and remove
the definitions from the arch files.

Based on 2.6.24-rc8-mm1 + latest (08/1/21) git-x86

Cc: David Miller <davem@davemloft.net>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Mike Travis <travis@sgi.com>

---
 arch/ia64/kernel/module.c    |   11 -----------
 include/asm-generic/percpu.h |    8 --------
 include/asm-ia64/percpu.h    |    5 -----
 include/asm-powerpc/percpu.h |    9 ---------
 include/asm-s390/percpu.h    |    9 ---------
 kernel/module.c              |    8 ++++++++
 6 files changed, 8 insertions(+), 42 deletions(-)

--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -940,14 +940,3 @@ module_arch_cleanup (struct module *mod)
 	if (mod->arch.core_unw_table)
 		unw_remove_unwind_table(mod->arch.core_unw_table);
 }
-
-#ifdef CONFIG_SMP
-void
-percpu_modcopy (void *pcpudst, const void *src, unsigned long size)
-{
-	unsigned int i;
-	for_each_possible_cpu(i) {
-		memcpy(pcpudst + per_cpu_offset(i), src, size);
-	}
-}
-#endif /* CONFIG_SMP */
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -63,14 +63,6 @@ extern unsigned long __per_cpu_offset[NR
 extern void setup_per_cpu_areas(void);
 #endif
 
-/* A macro to avoid #include hell... */
-#define percpu_modcopy(pcpudst, src, size)			\
-do {								\
-	unsigned int __i;					\
-	for_each_possible_cpu(__i)				\
-		memcpy((pcpudst)+per_cpu_offset(__i),		\
-		       (src), (size));				\
-} while (0)
 #else /* ! SMP */
 
 #define per_cpu(var, cpu)			(*((void)(cpu), &per_cpu_var(var)))
--- a/include/asm-ia64/percpu.h
+++ b/include/asm-ia64/percpu.h
@@ -22,10 +22,6 @@
 #define DECLARE_PER_CPU(type, name)				\
 	extern PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
 
-/*
- * Pretty much a literal copy of asm-generic/percpu.h, except that percpu_modcopy() is an
- * external routine, to avoid include-hell.
- */
 #ifdef CONFIG_SMP
 
 extern unsigned long __per_cpu_offset[NR_CPUS];
@@ -38,7 +34,6 @@ DECLARE_PER_CPU(unsigned long, local_per
 #define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
 #define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
 
-extern void percpu_modcopy(void *pcpudst, const void *src, unsigned long size);
 extern void setup_per_cpu_areas (void);
 extern void *per_cpu_init(void);
 
--- a/include/asm-powerpc/percpu.h
+++ b/include/asm-powerpc/percpu.h
@@ -21,15 +21,6 @@
 #define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()))
 #define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, local_paca->data_offset))
 
-/* A macro to avoid #include hell... */
-#define percpu_modcopy(pcpudst, src, size)			\
-do {								\
-	unsigned int __i;					\
-	for_each_possible_cpu(__i)				\
-		memcpy((pcpudst)+__per_cpu_offset(__i),		\
-		       (src), (size));				\
-} while (0)
-
 extern void setup_per_cpu_areas(void);
 
 #else /* ! SMP */
--- a/include/asm-s390/percpu.h
+++ b/include/asm-s390/percpu.h
@@ -39,15 +39,6 @@ extern unsigned long __per_cpu_offset[NR
 #define per_cpu(var,cpu) __reloc_hide(var,__per_cpu_offset[cpu])
 #define per_cpu_offset(x) (__per_cpu_offset[x])
 
-/* A macro to avoid #include hell... */
-#define percpu_modcopy(pcpudst, src, size)			\
-do {								\
-	unsigned int __i;					\
-	for_each_possible_cpu(__i)				\
-		memcpy((pcpudst)+__per_cpu_offset[__i],		\
-		       (src), (size));				\
-} while (0)
-
 #else /* ! SMP */
 
 #define __get_cpu_var(var) __reloc_hide(var,0)
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -427,6 +427,14 @@ static unsigned int find_pcpusec(Elf_Ehd
 	return find_sec(hdr, sechdrs, secstrings, ".data.percpu");
 }
 
+static void percpu_modcopy(void *pcpudest, const void *from, unsigned long size)
+{
+	int cpu;
+
+	for_each_possible_cpu(cpu)
+		memcpy(pcpudest + per_cpu_offset(cpu), from, size);
+}
+
 static int percpu_modinit(void)
 {
 	pcpu_num_used = 2;

-- 

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

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

* [PATCH 2/7] x86: Change Kconfig to HAVE_SETUP_PER_CPU_AREAF rc8-mm1-fixup with git-x86
  2008-01-21 20:28 [PATCH 0/7] percpu: Per cpu code simplification rc8-mm1-fixup with git-x86 travis
  2008-01-21 20:28 ` [PATCH 1/7] Modules: Fold percpu_modcopy into module.c " travis
@ 2008-01-21 20:28 ` travis
  2008-01-21 20:28 ` [PATCH 3/7] Sparc64: Use generic percpu fixup " travis
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: travis @ 2008-01-21 20:28 UTC (permalink / raw)
  To: Andrew Morton, Andi Kleen, mingo
  Cc: Christoph Lameter, linux-mm, linux-kernel

[-- Attachment #1: x86_generic_percpu --]
[-- Type: text/plain, Size: 1942 bytes --]

Change the Kconfig variable used to indicate that x86 has it's
own per_cpu area setup routine.

Based on 2.6.24-rc8-mm1 + latest (08/1/21) git-x86

Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Mike Travis <travis@sgi.com>
---
Fixup:
    - Because of git-x86 merge, the change to using HAVE_SETUP_PER_CPU_AREA
      was dropped.  This puts it back so both versions are consistent.
---
 arch/x86/Kconfig             |    2 +-
 include/asm-generic/percpu.h |    2 +-
 init/main.c                  |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -100,7 +100,7 @@ config GENERIC_TIME_VSYSCALL
 	bool
 	default X86_64
 
-config ARCH_SETS_UP_PER_CPU_AREA
+config HAVE_SETUP_PER_CPU_AREA
 	def_bool X86_64
 
 config ARCH_SUPPORTS_OPROFILE
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -59,7 +59,7 @@ extern unsigned long __per_cpu_offset[NR
 	(*SHIFT_PERCPU_PTR(&per_cpu_var(var), __my_cpu_offset))
 
 
-#ifdef CONFIG_ARCH_SETS_UP_PER_CPU_AREA
+#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
 extern void setup_per_cpu_areas(void);
 #endif
 
--- a/init/main.c
+++ b/init/main.c
@@ -363,7 +363,7 @@ static inline void smp_prepare_cpus(unsi
 
 #else
 
-#ifndef CONFIG_ARCH_SETS_UP_PER_CPU_AREA
+#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
 unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
 
 EXPORT_SYMBOL(__per_cpu_offset);
@@ -384,7 +384,7 @@ static void __init setup_per_cpu_areas(v
 		ptr += size;
 	}
 }
-#endif /* CONFIG_ARCH_SETS_UP_CPU_AREA */
+#endif /* CONFIG_HAVE_SETUP_PER_CPU_AREA */
 
 /* Called by boot processor to activate the rest. */
 static void __init smp_init(void)

-- 

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

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

* [PATCH 3/7] Sparc64: Use generic percpu fixup rc8-mm1-fixup with git-x86
  2008-01-21 20:28 [PATCH 0/7] percpu: Per cpu code simplification rc8-mm1-fixup with git-x86 travis
  2008-01-21 20:28 ` [PATCH 1/7] Modules: Fold percpu_modcopy into module.c " travis
  2008-01-21 20:28 ` [PATCH 2/7] x86: Change Kconfig to HAVE_SETUP_PER_CPU_AREAF " travis
@ 2008-01-21 20:28 ` travis
  2008-01-21 20:28 ` [PATCH 4/7] ia64: " travis
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: travis @ 2008-01-21 20:28 UTC (permalink / raw)
  To: Andrew Morton, Andi Kleen, mingo
  Cc: Christoph Lameter, linux-mm, linux-kernel, David Miller

[-- Attachment #1: sparc64_generic_percpu --]
[-- Type: text/plain, Size: 2793 bytes --]

Sparc64 has a way of providing the base address for the per cpu area of the
currently executing processor in a global register.

Sparc64 also provides a way to calculate the address of a per cpu area
from a base address instead of performing an array lookup.

Based on 2.6.24-rc8-mm1 + latest (08/1/21) git-x86

Cc: David Miller <davem@davemloft.net>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Mike Travis <travis@sgi.com>
---
rc8-mm1-fixup:
  - rebased from 2.6.24-rc6-mm1 to 2.6.24-rc8-mm1
    (removed changes that are in the git-x86.patch)
---
 arch/sparc64/mm/init.c       |    5 +++++
 include/asm-sparc64/percpu.h |   22 +++-------------------
 2 files changed, 8 insertions(+), 19 deletions(-)

--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -1328,6 +1328,11 @@ pgd_t swapper_pg_dir[2048];
 static void sun4u_pgprot_init(void);
 static void sun4v_pgprot_init(void);
 
+/* Dummy function */
+void __init setup_per_cpu_areas(void)
+{
+}
+
 void __init paging_init(void)
 {
 	unsigned long end_pfn, pages_avail, shift, phys_base;
--- a/include/asm-sparc64/percpu.h
+++ b/include/asm-sparc64/percpu.h
@@ -7,7 +7,6 @@ register unsigned long __local_per_cpu_o
 
 #ifdef CONFIG_SMP
 
-#define setup_per_cpu_areas()			do { } while (0)
 extern void real_setup_per_cpu_areas(void);
 
 extern unsigned long __per_cpu_base;
@@ -16,29 +15,14 @@ extern unsigned long __per_cpu_shift;
 	(__per_cpu_base + ((unsigned long)(__cpu) << __per_cpu_shift))
 #define per_cpu_offset(x) (__per_cpu_offset(x))
 
-/* var is in discarded region: offset to particular copy we want */
-#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)))
-#define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __local_per_cpu_offset))
-#define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __local_per_cpu_offset))
-
-/* A macro to avoid #include hell... */
-#define percpu_modcopy(pcpudst, src, size)			\
-do {								\
-	unsigned int __i;					\
-	for_each_possible_cpu(__i)				\
-		memcpy((pcpudst)+__per_cpu_offset(__i),		\
-		       (src), (size));				\
-} while (0)
+#define __my_cpu_offset __local_per_cpu_offset
+
 #else /* ! SMP */
 
 #define real_setup_per_cpu_areas()		do { } while (0)
 
-#define per_cpu(var, cpu)			(*((void)cpu, &per_cpu__##var))
-#define __get_cpu_var(var)			per_cpu__##var
-#define __raw_get_cpu_var(var)			per_cpu__##var
-
 #endif	/* SMP */
 
-#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
+#include <asm-generic/percpu.h>
 
 #endif /* __ARCH_SPARC64_PERCPU__ */

-- 

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

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

* [PATCH 4/7] ia64: Use generic percpu fixup rc8-mm1-fixup with git-x86
  2008-01-21 20:28 [PATCH 0/7] percpu: Per cpu code simplification rc8-mm1-fixup with git-x86 travis
                   ` (2 preceding siblings ...)
  2008-01-21 20:28 ` [PATCH 3/7] Sparc64: Use generic percpu fixup " travis
@ 2008-01-21 20:28 ` travis
  2008-01-21 20:28 ` [PATCH 5/7] Powerpc: Use generic per cpu " travis
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: travis @ 2008-01-21 20:28 UTC (permalink / raw)
  To: Andrew Morton, Andi Kleen, mingo
  Cc: Christoph Lameter, linux-mm, linux-kernel, linux-ia64, tony.luck

[-- Attachment #1: ia64_generic_percpu --]
[-- Type: text/plain, Size: 3158 bytes --]

ia64 has a special processor specific mapping that can be used to locate the
offset for the current per cpu area.

Based on 2.6.24-rc8-mm1 + latest (08/1/21) git-x86

Cc: linux-ia64@vger.kernel.org
Cc: tony.luck@intel.com
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Mike Travis <travis@sgi.com>
---
rc8-mm1-fixup:
  - rebased from 2.6.24-rc6-mm1 to 2.6.24-rc8-mm1
    (removed changes that are in the git-x86.patch)
---
V1->V2:
- Merge fixes
- Remove transitional check for PER_CPU_ATTRIBUTES from linux/percpu.h

V2-.V3:
- use generic percpy_modcopy()
---
 arch/ia64/Kconfig         |    2 +-
 include/asm-ia64/percpu.h |   24 +++++++-----------------
 include/linux/percpu.h    |    4 ----
 3 files changed, 8 insertions(+), 22 deletions(-)

--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -80,7 +80,7 @@ config GENERIC_TIME_VSYSCALL
 	bool
 	default y
 
-config ARCH_SETS_UP_PER_CPU_AREA
+config HAVE_SETUP_PER_CPU_AREA
 	def_bool y
 
 config DMI
--- a/include/asm-ia64/percpu.h
+++ b/include/asm-ia64/percpu.h
@@ -19,29 +19,14 @@
 # define PER_CPU_ATTRIBUTES	__attribute__((__model__ (__small__)))
 #endif
 
-#define DECLARE_PER_CPU(type, name)				\
-	extern PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
-
 #ifdef CONFIG_SMP
 
-extern unsigned long __per_cpu_offset[NR_CPUS];
-#define per_cpu_offset(x) (__per_cpu_offset[x])
-
-/* Equal to __per_cpu_offset[smp_processor_id()], but faster to access: */
-DECLARE_PER_CPU(unsigned long, local_per_cpu_offset);
-
-#define per_cpu(var, cpu)  (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
-#define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
-#define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
+#define __my_cpu_offset	__ia64_per_cpu_var(local_per_cpu_offset)
 
-extern void setup_per_cpu_areas (void);
 extern void *per_cpu_init(void);
 
 #else /* ! SMP */
 
-#define per_cpu(var, cpu)			(*((void)(cpu), &per_cpu__##var))
-#define __get_cpu_var(var)			per_cpu__##var
-#define __raw_get_cpu_var(var)			per_cpu__##var
 #define per_cpu_init()				(__phys_per_cpu_start)
 
 #endif	/* SMP */
@@ -52,7 +37,12 @@ extern void *per_cpu_init(void);
  * On the positive side, using __ia64_per_cpu_var() instead of __get_cpu_var() is slightly
  * more efficient.
  */
-#define __ia64_per_cpu_var(var)	(per_cpu__##var)
+#define __ia64_per_cpu_var(var)	per_cpu__##var
+
+#include <asm-generic/percpu.h>
+
+/* Equal to __per_cpu_offset[smp_processor_id()], but faster to access: */
+DECLARE_PER_CPU(unsigned long, local_per_cpu_offset);
 
 #endif /* !__ASSEMBLY__ */
 
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -9,10 +9,6 @@
 
 #include <asm/percpu.h>
 
-#ifndef PER_CPU_ATTRIBUTES
-#define PER_CPU_ATTRIBUTES
-#endif
-
 #ifdef CONFIG_SMP
 #define DEFINE_PER_CPU(type, name)					\
 	__attribute__((__section__(".data.percpu")))			\

-- 

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

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

* [PATCH 5/7] Powerpc: Use generic per cpu rc8-mm1-fixup with git-x86
  2008-01-21 20:28 [PATCH 0/7] percpu: Per cpu code simplification rc8-mm1-fixup with git-x86 travis
                   ` (3 preceding siblings ...)
  2008-01-21 20:28 ` [PATCH 4/7] ia64: " travis
@ 2008-01-21 20:28 ` travis
  2008-01-21 20:28 ` [PATCH 6/7] s390: Use generic percpu " travis
  2008-01-21 20:28 ` [PATCH 7/7] percpu: Add debug of invalid per_cpu usage " travis
  6 siblings, 0 replies; 8+ messages in thread
From: travis @ 2008-01-21 20:28 UTC (permalink / raw)
  To: Andrew Morton, Andi Kleen, mingo
  Cc: Christoph Lameter, linux-mm, linux-kernel, Paul Mackerras

[-- Attachment #1: power_generic_percpu --]
[-- Type: text/plain, Size: 2185 bytes --]

Powerpc has a way to determine the address of the per cpu area of the
currently executing processor via the paca and the array of per cpu
offsets is avoided by looking up the per cpu area from the remote
paca's (copying x86_64).

Based on 2.6.24-rc8-mm1 + latest (08/1/21) git-x86

Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Mike Travis <travis@sgi.com>
---
rc8-mm1-fixup:
  - rebased from 2.6.24-rc6-mm1 to 2.6.24-rc8-mm1
    (removed changes that are in the git-x86.patch)

V1->V2:
- add missing #endif

V2->V3:
- use generic percpy_modcopy()

---
 arch/powerpc/Kconfig         |    2 +-
 include/asm-powerpc/percpu.h |   20 ++------------------
 2 files changed, 3 insertions(+), 19 deletions(-)

--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -42,7 +42,7 @@ config GENERIC_HARDIRQS
 	bool
 	default y
 
-config ARCH_SETS_UP_PER_CPU_AREA
+config HAVE_SETUP_PER_CPU_AREA
 	def_bool PPC64
 
 config IRQ_PER_CPU
--- a/include/asm-powerpc/percpu.h
+++ b/include/asm-powerpc/percpu.h
@@ -16,25 +16,9 @@
 #define __my_cpu_offset() get_paca()->data_offset
 #define per_cpu_offset(x) (__per_cpu_offset(x))
 
-/* var is in discarded region: offset to particular copy we want */
-#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)))
-#define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()))
-#define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, local_paca->data_offset))
+#endif /* CONFIG_SMP */
+#endif /* __powerpc64__ */
 
-extern void setup_per_cpu_areas(void);
-
-#else /* ! SMP */
-
-#define per_cpu(var, cpu)			(*((void)(cpu), &per_cpu__##var))
-#define __get_cpu_var(var)			per_cpu__##var
-#define __raw_get_cpu_var(var)			per_cpu__##var
-
-#endif	/* SMP */
-
-#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
-
-#else
 #include <asm-generic/percpu.h>
-#endif
 
 #endif /* _ASM_POWERPC_PERCPU_H_ */

-- 

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

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

* [PATCH 6/7] s390: Use generic percpu rc8-mm1-fixup with git-x86
  2008-01-21 20:28 [PATCH 0/7] percpu: Per cpu code simplification rc8-mm1-fixup with git-x86 travis
                   ` (4 preceding siblings ...)
  2008-01-21 20:28 ` [PATCH 5/7] Powerpc: Use generic per cpu " travis
@ 2008-01-21 20:28 ` travis
  2008-01-21 20:28 ` [PATCH 7/7] percpu: Add debug of invalid per_cpu usage " travis
  6 siblings, 0 replies; 8+ messages in thread
From: travis @ 2008-01-21 20:28 UTC (permalink / raw)
  To: Andrew Morton, Andi Kleen, mingo
  Cc: Christoph Lameter, linux-mm, linux-kernel, schwidefsky

[-- Attachment #1: s390_generic_percpu --]
[-- Type: text/plain, Size: 2989 bytes --]

Change s390 percpu.h to use asm-generic/percpu.h

Based on 2.6.24-rc8-mm1 + latest (08/1/21) git-x86

Cc: schwidefsky@de.ibm.com
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Mike Travis <travis@sgi.com>
---
rc8-mm1-fixup:
  - rebased from 2.6.24-rc6-mm1 to 2.6.24-rc8-mm1
    (removed changes that are in the git-x86.patch)

V2->V3:

On Thu, 29 Nov 2007, Martin Schwidefsky wrote:

> On Wed, 2007-11-28 at 13:09 -0800, Christoph Lameter wrote:
> > s390 has a special way to determine the pointer to a per cpu area
> > plus there is a way to access the base of the per cpu area of the
> > currently executing processor.
> > 
> > Note: I had to do a minor change to ASM code. Please check that
> > this was done right.
> 
> Hi Christoph,
> 
> after fixing the trainwreck with Gregs kset changes I've got rc3-mm2
> compiled with your percpu patches. The new s390 percpu code works fine:
> 
> Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

---
 include/asm-s390/percpu.h |   33 +++++++++------------------------
 1 file changed, 9 insertions(+), 24 deletions(-)

--- a/include/asm-s390/percpu.h
+++ b/include/asm-s390/percpu.h
@@ -13,40 +13,25 @@
  */
 #if defined(__s390x__) && defined(MODULE)
 
-#define __reloc_hide(var,offset) (*({			\
+#define SHIFT_PERCPU_PTR(ptr,offset) (({			\
 	extern int simple_identifier_##var(void);	\
 	unsigned long *__ptr;				\
-	asm ( "larl %0,per_cpu__"#var"@GOTENT"		\
-	    : "=a" (__ptr) : "X" (per_cpu__##var) );	\
-	(typeof(&per_cpu__##var))((*__ptr) + (offset));	}))
+	asm ( "larl %0, %1@GOTENT"		\
+	    : "=a" (__ptr) : "X" (ptr) );		\
+	(typeof(ptr))((*__ptr) + (offset));	}))
 
 #else
 
-#define __reloc_hide(var, offset) (*({				\
+#define SHIFT_PERCPU_PTR(ptr, offset) (({				\
 	extern int simple_identifier_##var(void);		\
 	unsigned long __ptr;					\
-	asm ( "" : "=a" (__ptr) : "0" (&per_cpu__##var) );	\
-	(typeof(&per_cpu__##var)) (__ptr + (offset)); }))
+	asm ( "" : "=a" (__ptr) : "0" (ptr) );			\
+	(typeof(ptr)) (__ptr + (offset)); }))
 
 #endif
 
-#ifdef CONFIG_SMP
+#define __my_cpu_offset S390_lowcore.percpu_offset
 
-extern unsigned long __per_cpu_offset[NR_CPUS];
-
-#define __get_cpu_var(var) __reloc_hide(var,S390_lowcore.percpu_offset)
-#define __raw_get_cpu_var(var) __reloc_hide(var,S390_lowcore.percpu_offset)
-#define per_cpu(var,cpu) __reloc_hide(var,__per_cpu_offset[cpu])
-#define per_cpu_offset(x) (__per_cpu_offset[x])
-
-#else /* ! SMP */
-
-#define __get_cpu_var(var) __reloc_hide(var,0)
-#define __raw_get_cpu_var(var) __reloc_hide(var,0)
-#define per_cpu(var,cpu) __reloc_hide(var,0)
-
-#endif /* SMP */
-
-#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
+#include <asm-generic/percpu.h>
 
 #endif /* __ARCH_S390_PERCPU__ */

-- 

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

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

* [PATCH 7/7] percpu: Add debug of invalid per_cpu usage rc8-mm1-fixup with git-x86
  2008-01-21 20:28 [PATCH 0/7] percpu: Per cpu code simplification rc8-mm1-fixup with git-x86 travis
                   ` (5 preceding siblings ...)
  2008-01-21 20:28 ` [PATCH 6/7] s390: Use generic percpu " travis
@ 2008-01-21 20:28 ` travis
  6 siblings, 0 replies; 8+ messages in thread
From: travis @ 2008-01-21 20:28 UTC (permalink / raw)
  To: Andrew Morton, Andi Kleen, mingo
  Cc: Christoph Lameter, linux-mm, linux-kernel

[-- Attachment #1: debug-percpu --]
[-- Type: text/plain, Size: 2031 bytes --]

Provide a means to trap usages of per_cpu variables before
the per_cpu_areas are setup.  Define CONFIG_DEBUG_PER_CPU to activate.

Based on 2.6.24-rc8-mm1 + latest (08/1/21) git-x86

Signed-off-by: Mike Travis <travis@sgi.com>
---
 include/asm-generic/percpu.h |   11 ++++++++++-
 lib/Kconfig.debug            |   12 ++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -47,12 +47,21 @@ extern unsigned long __per_cpu_offset[NR
 #endif
 
 /*
- * A percpu variable may point to a discarded reghions. The following are
+ * A percpu variable may point to a discarded regions. The following are
  * established ways to produce a usable pointer from the percpu variable
  * offset.
  */
+#ifdef	CONFIG_DEBUG_PER_CPU
+#define per_cpu(var, cpu) (*({		\
+	if (!per_cpu_offset(cpu)) {	\
+		printk("KERN_NOTICE per_cpu(%s,%d): not available!\n", #var, (int)cpu); \
+		dump_stack();		\
+	}				\
+	SHIFT_PERCPU_PTR(&per_cpu_var(var), per_cpu_offset(cpu));}))
+#else
 #define per_cpu(var, cpu) \
 	(*SHIFT_PERCPU_PTR(&per_cpu_var(var), per_cpu_offset(cpu)))
+#endif
 #define __get_cpu_var(var) \
 	(*SHIFT_PERCPU_PTR(&per_cpu_var(var), my_cpu_offset))
 #define __raw_get_cpu_var(var) \
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -570,6 +570,18 @@ config PROVIDE_OHCI1394_DMA_INIT
 
 	  See Documentation/debugging-via-ohci1394.txt for more information.
 
+config DEBUG_PER_CPU
+	bool "Debug per_cpu usage"
+	depends on DEBUG_KERNEL
+	depends on SMP
+	default n
+	help
+	  Say Y here to add code that verifies the per_cpu area is
+	  setup before accessing a per_cpu variable.  It does add a
+	  significant amount of code to kernel memory.
+
+	  If unsure, say N.
+
 source "samples/Kconfig"
 
 source "lib/Kconfig.kgdb"

-- 

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

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

end of thread, other threads:[~2008-01-21 20:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-21 20:28 [PATCH 0/7] percpu: Per cpu code simplification rc8-mm1-fixup with git-x86 travis
2008-01-21 20:28 ` [PATCH 1/7] Modules: Fold percpu_modcopy into module.c " travis
2008-01-21 20:28 ` [PATCH 2/7] x86: Change Kconfig to HAVE_SETUP_PER_CPU_AREAF " travis
2008-01-21 20:28 ` [PATCH 3/7] Sparc64: Use generic percpu fixup " travis
2008-01-21 20:28 ` [PATCH 4/7] ia64: " travis
2008-01-21 20:28 ` [PATCH 5/7] Powerpc: Use generic per cpu " travis
2008-01-21 20:28 ` [PATCH 6/7] s390: Use generic percpu " travis
2008-01-21 20:28 ` [PATCH 7/7] percpu: Add debug of invalid per_cpu usage " 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).