* [PATCH 0/8] percpu: Per cpu code simplification rc8-mm1-fixup
@ 2008-01-21 20:27 travis
2008-01-21 20:27 ` [PATCH 1/8] Modules: Fold percpu_modcopy into module.c rc8-mm1-fixup travis
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: travis @ 2008-01-21 20:27 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
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>
---
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)
- 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] 9+ messages in thread
* [PATCH 1/8] Modules: Fold percpu_modcopy into module.c rc8-mm1-fixup
2008-01-21 20:27 [PATCH 0/8] percpu: Per cpu code simplification rc8-mm1-fixup travis
@ 2008-01-21 20:27 ` travis
2008-01-21 20:27 ` [PATCH 2/8] percpu: Change Kconfig to HAVE_SETUP_PER_CPU_AREA rc8-mm1-fixup travis
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: travis @ 2008-01-21 20:27 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: 4499 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
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>
---
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)
- added back in missing fold-percpu_modcopy pieces
---
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
@@ -422,6 +422,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] 9+ messages in thread
* [PATCH 2/8] percpu: Change Kconfig to HAVE_SETUP_PER_CPU_AREA rc8-mm1-fixup
2008-01-21 20:27 [PATCH 0/8] percpu: Per cpu code simplification rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 1/8] Modules: Fold percpu_modcopy into module.c rc8-mm1-fixup travis
@ 2008-01-21 20:27 ` travis
2008-01-21 20:27 ` [PATCH 3/8] pecpu: Fix size of percpu_data.ptrs array rc8-mm1-fixup travis
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: travis @ 2008-01-21 20:27 UTC (permalink / raw)
To: Andrew Morton, Andi Kleen, mingo
Cc: Christoph Lameter, linux-mm, linux-kernel, Rusty Russell,
Sam Ravnborg
[-- Attachment #1: config-to-select --]
[-- Type: text/plain, Size: 3570 bytes --]
Change "config ARCH_SETS_UP_PER_CPU_AREA" to "select
HAVE_SETUP_PER_CPU_AREA" as suggested by Sam.
Based on: 2.6.24-rc8-mm1
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andi Kleen <ak@suse.de>
Cc: Sam Ravnborg <sam@ravnborg.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)
---
arch/Kconfig | 3 +++
arch/ia64/Kconfig | 4 +---
arch/powerpc/Kconfig | 4 +---
arch/sparc64/Kconfig | 4 +---
arch/x86/Kconfig | 4 +---
include/asm-generic/percpu.h | 2 +-
init/main.c | 4 ++--
7 files changed, 10 insertions(+), 15 deletions(-)
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1,3 +1,6 @@
#
# General architecture dependent options
#
+
+config HAVE_SETUP_PER_CPU_AREA
+ def_bool n
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -17,6 +17,7 @@ config IA64
select ARCH_SUPPORTS_MSI
select HAVE_OPROFILE
select HAVE_KPROBES
+ select HAVE_SETUP_PER_CPU_AREA
default y
help
The Itanium Processor Family is Intel's 64-bit successor to
@@ -82,9 +83,6 @@ config GENERIC_TIME_VSYSCALL
bool
default y
-config ARCH_SETS_UP_PER_CPU_AREA
- def_bool y
-
config DMI
bool
default y
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -42,9 +42,6 @@ config GENERIC_HARDIRQS
bool
default y
-config ARCH_SETS_UP_PER_CPU_AREA
- def_bool PPC64
-
config IRQ_PER_CPU
bool
default y
@@ -89,6 +86,7 @@ config PPC
default y
select HAVE_OPROFILE
select HAVE_KPROBES
+ select HAVE_SETUP_PER_CPU_AREA if PPC64
config EARLY_PRINTK
bool
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -10,6 +10,7 @@ config SPARC
default y
select HAVE_OPROFILE
select HAVE_KPROBES
+ select HAVE_SETUP_PER_CPU_AREA
config SPARC64
bool
@@ -68,9 +69,6 @@ config AUDIT_ARCH
bool
default y
-config ARCH_SETS_UP_PER_CPU_AREA
- def_bool y
-
config ARCH_NO_VIRT_TO_BUS
def_bool y
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -20,6 +20,7 @@ config X86
def_bool y
select HAVE_OPROFILE
select HAVE_KPROBES
+ select HAVE_SETUP_PER_CPU_AREA if X86_64
config GENERIC_LOCKBREAK
def_bool n
@@ -106,9 +107,6 @@ config GENERIC_TIME_VSYSCALL
bool
default X86_64
-config ARCH_SETS_UP_PER_CPU_AREA
- def_bool X86_64
-
config ARCH_SUPPORTS_OPROFILE
bool
default y
--- 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] 9+ messages in thread
* [PATCH 3/8] pecpu: Fix size of percpu_data.ptrs array rc8-mm1-fixup
2008-01-21 20:27 [PATCH 0/8] percpu: Per cpu code simplification rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 1/8] Modules: Fold percpu_modcopy into module.c rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 2/8] percpu: Change Kconfig to HAVE_SETUP_PER_CPU_AREA rc8-mm1-fixup travis
@ 2008-01-21 20:27 ` travis
2008-01-21 20:27 ` [PATCH 4/8] Sparc64: Use generic percpu fixup rc8-mm1-fixup travis
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: travis @ 2008-01-21 20:27 UTC (permalink / raw)
To: Andrew Morton, Andi Kleen, mingo
Cc: Christoph Lameter, linux-mm, linux-kernel
[-- Attachment #1: generic-percpu-fix --]
[-- Type: text/plain, Size: 753 bytes --]
Define the size of the generic percpu pointers array to be NR_CPUS
Based on: 2.6.24-rc8-mm1
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Mike Travis <travis@sgi.com>
---
include/linux/percpu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -58,7 +58,7 @@
#ifdef CONFIG_SMP
struct percpu_data {
- void *ptrs[1];
+ void *ptrs[NR_CPUS];
};
#define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata)
--
--
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] 9+ messages in thread
* [PATCH 4/8] Sparc64: Use generic percpu fixup rc8-mm1-fixup
2008-01-21 20:27 [PATCH 0/8] percpu: Per cpu code simplification rc8-mm1-fixup travis
` (2 preceding siblings ...)
2008-01-21 20:27 ` [PATCH 3/8] pecpu: Fix size of percpu_data.ptrs array rc8-mm1-fixup travis
@ 2008-01-21 20:27 ` travis
2008-01-21 20:27 ` [PATCH 5/8] ia64: " travis
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: travis @ 2008-01-21 20:27 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: 2767 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
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] 9+ messages in thread
* [PATCH 5/8] ia64: Use generic percpu fixup rc8-mm1-fixup
2008-01-21 20:27 [PATCH 0/8] percpu: Per cpu code simplification rc8-mm1-fixup travis
` (3 preceding siblings ...)
2008-01-21 20:27 ` [PATCH 4/8] Sparc64: Use generic percpu fixup rc8-mm1-fixup travis
@ 2008-01-21 20:27 ` travis
2008-01-21 20:27 ` [PATCH 6/8] Powerpc: Use generic per cpu rc8-mm1-fixup travis
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: travis @ 2008-01-21 20:27 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: 2884 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
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()
---
include/asm-ia64/percpu.h | 24 +++++++-----------------
include/linux/percpu.h | 4 ----
2 files changed, 7 insertions(+), 21 deletions(-)
--- 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] 9+ messages in thread
* [PATCH 6/8] Powerpc: Use generic per cpu rc8-mm1-fixup
2008-01-21 20:27 [PATCH 0/8] percpu: Per cpu code simplification rc8-mm1-fixup travis
` (4 preceding siblings ...)
2008-01-21 20:27 ` [PATCH 5/8] ia64: " travis
@ 2008-01-21 20:27 ` travis
2008-01-21 20:27 ` [PATCH 7/8] s390: Use generic percpu rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 8/8] percpu: Add debug of invalid per_cpu usage rc8-mm1-fixup travis
7 siblings, 0 replies; 9+ messages in thread
From: travis @ 2008-01-21 20:27 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: 1896 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
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()
---
include/asm-powerpc/percpu.h | 20 ++------------------
1 file changed, 2 insertions(+), 18 deletions(-)
--- 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] 9+ messages in thread
* [PATCH 7/8] s390: Use generic percpu rc8-mm1-fixup
2008-01-21 20:27 [PATCH 0/8] percpu: Per cpu code simplification rc8-mm1-fixup travis
` (5 preceding siblings ...)
2008-01-21 20:27 ` [PATCH 6/8] Powerpc: Use generic per cpu rc8-mm1-fixup travis
@ 2008-01-21 20:27 ` travis
2008-01-21 20:27 ` [PATCH 8/8] percpu: Add debug of invalid per_cpu usage rc8-mm1-fixup travis
7 siblings, 0 replies; 9+ messages in thread
From: travis @ 2008-01-21 20:27 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: 2963 bytes --]
Change s390 percpu.h to use asm-generic/percpu.h
Based on: 2.6.24-rc8-mm1
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] 9+ messages in thread
* [PATCH 8/8] percpu: Add debug of invalid per_cpu usage rc8-mm1-fixup
2008-01-21 20:27 [PATCH 0/8] percpu: Per cpu code simplification rc8-mm1-fixup travis
` (6 preceding siblings ...)
2008-01-21 20:27 ` [PATCH 7/8] s390: Use generic percpu rc8-mm1-fixup travis
@ 2008-01-21 20:27 ` travis
7 siblings, 0 replies; 9+ messages in thread
From: travis @ 2008-01-21 20:27 UTC (permalink / raw)
To: Andrew Morton, Andi Kleen, mingo
Cc: Christoph Lameter, linux-mm, linux-kernel
[-- Attachment #1: debug-percpu --]
[-- Type: text/plain, Size: 2126 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
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)
---
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
@@ -610,6 +610,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] 9+ messages in thread
end of thread, other threads:[~2008-01-21 20:27 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-21 20:27 [PATCH 0/8] percpu: Per cpu code simplification rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 1/8] Modules: Fold percpu_modcopy into module.c rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 2/8] percpu: Change Kconfig to HAVE_SETUP_PER_CPU_AREA rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 3/8] pecpu: Fix size of percpu_data.ptrs array rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 4/8] Sparc64: Use generic percpu fixup rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 5/8] ia64: " travis
2008-01-21 20:27 ` [PATCH 6/8] Powerpc: Use generic per cpu rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 7/8] s390: Use generic percpu rc8-mm1-fixup travis
2008-01-21 20:27 ` [PATCH 8/8] percpu: Add debug of invalid per_cpu usage rc8-mm1-fixup 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).