FRV: Fix the section attribute on UP DECLARE_PER_CPU()
Subsystems (39)
PATCH 1/1 FRV: Fix the section attribute on UP DECLARE_PER_CPU()
In non-SMP mode, the section specified by DECLARE_PER_CPU() does not agree with that of DEFINE_PER_CPU*(). This means architectures that have a small data section references relative to a base register may throw up linkage errors due to too great a displacement between where the base register points and the per-CPU variable.
On FRV, the .h declaration says that the variable is in the .sdata section, but the .c definition says it's actually in the .data section. The linker throws up the following errors:
kernel/built-in.o: In function `release_task':kernel/exit.c:78: relocation truncated to fit: R_FRV_GPREL12 against symbol per_cpu__process_counts' defined in .data section in kernel/built-in.o kernel/exit.c:78: relocation truncated to fit: R_FRV_GPREL12 against symbol per_cpu__process_counts' defined in .data section in kernel/built-in.o
To fix this, DECLARE_PER_CPU() should simply interpose the same section attribute as does DEFINE_PER_CPU(). However, this is made slightly more complex by virtue of the fact that there are several variants on DEFINE, so these need to be matched by variants of DECLARE.
---
arch/alpha/include/asm/percpu.h | 2 +- arch/ia64/include/asm/smp.h | 2 +- arch/x86/include/asm/desc.h | 2 +- arch/x86/include/asm/hardirq.h | 2 +- arch/x86/include/asm/processor.h | 6 +++-- arch/x86/include/asm/tlbflush.h | 2 +- include/asm-generic/percpu.h | 43 ++++++++++++++++++++++++++++++++++++-- include/linux/percpu.h | 24 --------------------- net/rds/rds.h | 2 +- 9 files changed, 50 insertions(+), 35 deletions(-)
arch/alpha/include/asm/percpu.h +1 -1
@@ -73,6 +73,6 @@ extern unsigned long __per_cpu_offset[NR_CPUS];#endif /* SMP */ -#define DECLARE_PER_CPU (type, name) extern __typeof__(type) per_cpu_var(name) +#include <asm-generic/percpu.h> #endif /* __ALPHA_PERCPU_H */
arch/ia64/include/asm/smp.h +1 -1
@@ -58,7 +58,7 @@ extern struct smp_boot_data {extern char no_int_routing__devinitdata ;extern cpumask_t cpu_core_map[NR_CPUS ]; -DECLARE_PER_CPU (cpumask_t, cpu_sibling_map); +DECLARE_PER_CPU_SHARED_ALIGNED (cpumask_t, cpu_sibling_map);extern int smp_num_siblings;extern void __iomem *ipi_base_addr;extern unsigned char smp_int_redirect;
arch/x86/include/asm/desc.h +1 -1
@@ -37,7 +37,7 @@ extern gate_desc idt_table[];struct gdt_page {struct desc_struct gdt[GDT_ENTRIES ]; } __attribute__((aligned (PAGE_SIZE ))); -DECLARE_PER_CPU(struct gdt_page, gdt_page); +DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);static inline struct desc_struct *get_cpu_gdt_table (unsigned int cpu) {
arch/x86/include/asm/hardirq.h +1 -1
@@ -26,7 +26,7 @@ typedef struct {#endif }____cacheline_aligned irq_cpustat_t; -DECLARE_PER_CPU (irq_cpustat_t, irq_stat); +DECLARE_PER_CPU_SHARED_ALIGNED (irq_cpustat_t, irq_stat);/* We can have at most NR_VECTORS irqs routed to a cpu at a time */ #define MAX_HARDIRQS_PER_CPU NR_VECTORS
arch/x86/include/asm/processor.h +3 -3
@@ -138,7 +138,7 @@ extern struct tss_struct doublefault_tss;extern __u32 cleared_cpu_caps[NCAPINTS ];#ifdef CONFIG_SMP -DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info); +DECLARE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);#define cpu_data (cpu) per_cpu(cpu_info, cpu)#define current_cpu_data __get_cpu_var(cpu_info)#else
@@ -270,7 +270,7 @@ struct tss_struct { }____cacheline_aligned ; -DECLARE_PER_CPU(struct tss_struct, init_tss); +DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);/* * Save the original ist values for checking stack pointers during debugging
@@ -393,7 +393,7 @@ union irq_stack_union { }; }; -DECLARE_PER_CPU(union irq_stack_union, irq_stack_union); +DECLARE_PER_CPU_FIRST(union irq_stack_union, irq_stack_union);DECLARE_INIT_PER_CPU (irq_stack_union); DECLARE_PER_CPU(char *, irq_stack_ptr);
arch/x86/include/asm/tlbflush.h +1 -1
@@ -152,7 +152,7 @@ struct tlb_state {struct mm_struct *active_mm;int state; }; -DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate); +DECLARE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate);static inline void reset_lazy_tlbstate (void ) {
include/asm-generic/percpu.h +41 -2
52 lines not on this page · raw message
include/linux/percpu.h +0 -24
@@ -9,30 +9,6 @@#include <asm/percpu.h> -#ifndef PER_CPU_BASE_SECTION -#ifdef CONFIG_SMP -#define PER_CPU_BASE_SECTION ".data.percpu" -#else -#define PER_CPU_BASE_SECTION ".data" -#endif -#endif - -#ifdef CONFIG_SMP - -#ifdef MODULE -#define PER_CPU_SHARED_ALIGNED_SECTION "" -#else -#define PER_CPU_SHARED_ALIGNED_SECTION ".shared_aligned" -#endif -#define PER_CPU_FIRST_SECTION ".first" - -#else - -#define PER_CPU_SHARED_ALIGNED_SECTION "" -#define PER_CPU_FIRST_SECTION "" - -#endif -#define DEFINE_PER_CPU_SECTION (type, name, section) \ __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
net/rds/rds.h +1 -1
@@ -638,7 +638,7 @@ struct rds_message *rds_send_get_message(struct rds_connection *,void rds_rdma_unuse (struct rds_sock *rs,u32 r_key,int force);/* stats.c */ -DECLARE_PER_CPU(struct rds_statistics, rds_stats); +DECLARE_PER_CPU_SHARED_ALIGNED(struct rds_statistics, rds_stats);#define rds_stats_inc_which (which, member) do { \ per_cpu(which, get_cpu()).member++; \ put_cpu(); \
Quoted 5 lines · David Howells
To fix this,
DECLARE_PER_CPU()should simply interpose the same section attribute as doesDEFINE_PER_CPU(). However, this is made slightly more complex by virtue of the fact that there are several variants on DEFINE, so these need to be matched by variants of DECLARE.
This needs to be fixed.
We should have the DECLARE_PER_CPU() #defines next to the DEFINE_PER_CPU ones, rather than somewhere else.
So moving the logic to <asm-generic/percpu.h> is wrong - make it all be in <linux/percpu.h> so that they can be maintained together.
Linus
Quoted 5 lines · Linus Torvalds
We should have the
DECLARE_PER_CPU()#defines next to theDEFINE_PER_CPUones, rather than somewhere else.So moving the logic to <
asm-generic/percpu.h> is wrong - make it all be in <linux/percpu.h> so that they can be maintained together.
Agreed, it would be nice. However, x86 requires it to be declared in the middle of asm/percpu.h (ie: in asm-generic/percpu.h). I'm trying to sort it out, but it's like trying to juggle hyperdimensional spaghetti:-/ How much header file overhaul do you wish to indulge in? And can I split some headers into separate headers for declarations and inline functions?
David
Quoted 3 lines · David Howells
Agreed, it would be nice. However, x86 requires it to be declared in the middle of
asm/percpu.h(ie: inasm-generic/percpu.h).
Hmm. Why not move it all above the '#include <asm/percpu.h>'?
Sure, then the odd architectures (read: ia64) that actually want to re-define things like PER_CPU_BASE_SECTION would have to now do
#undef PER_CPU_BASE_SECTION #define PER_CPU_BASE_SECTION ".data.percpu"
but wouldn't that all actually be much CLEANER than the insane crap we do today?
But yeah, I didn't look at all the details. It _looked_ pretty straightforward to just move the DEFINE/DECLARE stuff up, but there may well be something subtle I'm missing.
Linus
Quoted 1 line · Linus Torvalds
Hmm. Why not move it all above the '#include <
asm/percpu.h>'?
There are circular dependencies between the x86 arch headers that both use this and are used to implement this, and it's a bit fragile.
David
---
Compilation started at Wed Apr 15 11:20:49
LANG=C nice -19 make -C //warthog/nfs/linux-2.6-fscache -j3
make: Entering directory `/warthog/nfs/linux-2.6-fscache'
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
CC arch/x86/kernel/asm-offsets.s
In file included from /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h:5,
from /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:15,
from include/linux/prefetch.h:14,
from include/linux/list.h:6,
from include/linux/module.h:9,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_64.c:7,
from arch/x86/kernel/asm-offsets.c:4:/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/percpu.h:156: error: expected declaration specifiers or '...' before 'this_cpu_off' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/percpu.h:156: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/percpu.h:156: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' In file included from /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:15,
from include/linux/prefetch.h:14,
from include/linux/list.h:6,
from include/linux/module.h:9,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_64.c:7,
from arch/x86/kernel/asm-offsets.c:4:/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h:10: error: expected declaration specifiers or '...' before 'current_task' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h:10: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h:10: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h:10: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/percpu.h:156: error: previous declaration of 'DECLARE_PER_CPU' was here /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h: In function 'get_current':
/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h:14: error: 'per_cpu__current_task' undeclared (first use in this function) /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h:14: error: (Each undeclared identifier is reported only once /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h:14: error: for each function it appears in.) /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h:14: warning: type defaults to 'int' in declaration of 'ret__' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/current.h:14: warning: return makes pointer from integer without a cast In file included from include/linux/prefetch.h:14,
from include/linux/list.h:6,
from include/linux/module.h:9,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_64.c:7,
from arch/x86/kernel/asm-offsets.c:4:/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h: At top level:
/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:141: error: expected declaration specifiers or '...' before 'cpu_info' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:141: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:141: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU_SHARED_ALIGNED' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:273: error: expected declaration specifiers or '...' before 'init_tss' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:273: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:273: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU_SHARED_ALIGNED' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:273: error: conflicting types for 'DECLARE_PER_CPU_SHARED_ALIGNED' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:141: error: previous declaration of 'DECLARE_PER_CPU_SHARED_ALIGNED' was here /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:381: error: expected declaration specifiers or '...' before 'orig_ist' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:381: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:381: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:381: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/percpu.h:156: error: previous declaration of 'DECLARE_PER_CPU' was here /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:396: error: expected declaration specifiers or '...' before 'irq_stack_union' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:396: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:396: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU_FIRST' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:397: error: implicit declaration of function 'per_cpu_var' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:397: error: 'irq_stack_union' undeclared here (not in a function) /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:399: error: expected declaration specifiers or '...' before 'irq_stack_ptr' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:399: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:399: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:399: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/percpu.h:156: error: previous declaration of 'DECLARE_PER_CPU' was here /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:400: error: expected declaration specifiers or '...' before 'irq_count' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:400: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:400: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/processor.h:400: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/percpu.h:156: error: previous declaration of 'DECLARE_PER_CPU' was here
In file included from include/linux/thread_info.h:55,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:29,
from include/linux/time.h:8,
from include/linux/stat.h:60,
from include/linux/module.h:10,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_64.c:7,
from arch/x86/kernel/asm-offsets.c:4:/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: error: expected declaration specifiers or '...' before 'kernel_stack' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h: In function 'current_thread_info':
/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:214: error: 'per_cpu__kernel_stack' undeclared (first use in this function) /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:214: warning: type defaults to 'int' in declaration of 'ret__' In file included from /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:13,
from include/linux/smp.h:36,
from include/linux/topology.h:33,
from include/linux/gfp.h:7,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_64.c:7,
from arch/x86/kernel/asm-offsets.c:4:/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h: At top level:
/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h:435: error: expected declaration specifiers or '...' before 'x2apic_extra_bits' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h:435: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h:435: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h:435: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: error: previous declaration of 'DECLARE_PER_CPU' was here In file included from /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:13,
from include/linux/smp.h:36,
from include/linux/topology.h:33,
from include/linux/gfp.h:7,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_64.c:7,
from arch/x86/kernel/asm-offsets.c:4:/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h:466: error: expected declaration specifiers or '...' before 'x86_bios_cpu_apicid' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h:466: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h:466: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h:466: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: error: previous declaration of 'DECLARE_PER_CPU' was here /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h: In function '__default_cpu_present_to_apicid':
/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h:545: error: implicit declaration of function 'per_cpu' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/apic.h:545: error: 'x86_bios_cpu_apicid' undeclared (first use in this function) In file included from include/linux/smp.h:36,
from include/linux/topology.h:33,
from include/linux/gfp.h:7,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_64.c:7,
from arch/x86/kernel/asm-offsets.c:4:/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h: At top level:
/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:24: error: expected declaration specifiers or '...' before 'cpu_sibling_map' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:24: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:24: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:24: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: error: previous declaration of 'DECLARE_PER_CPU' was here /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:25: error: expected declaration specifiers or '...' before 'cpu_core_map' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:25: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:25: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:25: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: error: previous declaration of 'DECLARE_PER_CPU' was here /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:26: error: expected declaration specifiers or '...' before 'cpu_llc_id' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:26: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:26: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:26: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: error: previous declaration of 'DECLARE_PER_CPU' was here /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:27: error: expected declaration specifiers or '...' before 'cpu_number' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:27: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:27: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:27: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: error: previous declaration of 'DECLARE_PER_CPU' was here /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h: In function 'cpu_sibling_mask':
/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:31: error: 'cpu_sibling_map' undeclared (first use in this function) /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:31: warning: return makes pointer from integer without a cast /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h: In function 'cpu_core_mask':
/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:36: error: 'cpu_core_map' undeclared (first use in this function) /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:36: warning: return makes pointer from integer without a cast /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h: At top level:
/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:39: error: expected declaration specifiers or '...' before 'x86_cpu_to_apicid' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:39: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:39: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:39: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: error: previous declaration of 'DECLARE_PER_CPU' was here /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:40: error: expected declaration specifiers or '...' before 'x86_bios_cpu_apicid' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:40: warning: data definition has no type or storage class /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:40: warning: type defaults to 'int' in declaration of 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/smp.h:40: error: conflicting types for 'DECLARE_PER_CPU' /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/thread_info.h:209: error: previous declaration of 'DECLARE_PER_CPU' was here In file included from include/linux/kmod.h:22,
from include/linux/module.h:13,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_64.c:7,
from arch/x86/kernel/asm-offsets.c:4:include/linux/gfp.h: In function 'alloc_pages_node':include/linux/gfp.h:198: error: 'per_cpu__cpu_number' undeclared (first use in this function) include/linux/gfp.h:198: warning: type defaults to 'int' in declaration of 'ret__' In file included from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_64.c:7,
from arch/x86/kernel/asm-offsets.c:4:include/linux/module.h: In function '__module_get':include/linux/module.h:450: error: 'per_cpu__cpu_number' undeclared (first use in this function) include/linux/module.h:450: warning: type defaults to 'int' in declaration of 'ret__' include/linux/module.h: In function 'try_module_get':include/linux/module.h:460: error: 'per_cpu__cpu_number' undeclared (first use in this function) include/linux/module.h:460: warning: type defaults to 'int' in declaration of 'ret__' In file included from include/linux/mm.h:595,
from include/linux/suspend.h:8,
from arch/x86/kernel/asm-offsets_64.c:12,
from arch/x86/kernel/asm-offsets.c:4:include/linux/vmstat.h: In function '__count_vm_event':include/linux/vmstat.h:78: error: 'per_cpu__this_cpu_off' undeclared (first use in this function) include/linux/vmstat.h:78: warning: type defaults to 'int' in declaration of 'ret__' include/linux/vmstat.h: In function 'count_vm_event':include/linux/vmstat.h:83: error: 'per_cpu__this_cpu_off' undeclared (first use in this function) include/linux/vmstat.h:83: warning: type defaults to 'int' in declaration of 'ret__' include/linux/vmstat.h: In function '__count_vm_events':include/linux/vmstat.h:89: error: 'per_cpu__this_cpu_off' undeclared (first use in this function) include/linux/vmstat.h:89: warning: type defaults to 'int' in declaration of 'ret__' include/linux/vmstat.h: In function 'count_vm_events':include/linux/vmstat.h:94: error: 'per_cpu__this_cpu_off' undeclared (first use in this function) include/linux/vmstat.h:94: warning: type defaults to 'int' in declaration of 'ret__' In file included from /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/suspend_64.h:9,
from /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/suspend.h:4,
from arch/x86/kernel/asm-offsets_64.c:19,
from arch/x86/kernel/asm-offsets.c:4:/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/desc.h: In function 'native_set_ldt':
/warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/desc.h:202: error: 'per_cpu__cpu_number' undeclared (first use in this function) /warthog/nfs/linux-2.6-fscache/arch/x86/include/asm/desc.h:202: warning: type defaults to 'int' in declaration of 'ret__' make[1]: *** [arch/x86/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2
make: Leaving directory `/warthog/nfs/linux-2.6-fscache'
Compilation exited abnormally with code 2 at Wed Apr 15 11:20:49
Quoted 6 lines · David Howells
Quoted 1 line · Linus Torvalds
Hmm. Why not move it all above the '#include <
asm/percpu.h>'?There are circular dependencies between the x86 arch headers that both use this and are used to implement this, and it's a bit fragile.
Grr. Indeed it seems to be. Nasty. Header files seem to want that DECLARE_PER_CPU() thing without all the other baggage that is implied by including all of <linux/percpu.h>, so they just include <asm/percpu.h> directly instead.
What a mess.
So maybe we could move DEFINE_PER_CPU in there too? It's less than perfect, but at least we'd have things together rather than split in really odd ways.
Linus
Quoted 13 lines · Linus Torvalds
Quoted 6 lines · David Howells
Quoted 1 line · Linus Torvalds
Hmm. Why not move it all above the '#include <
asm/percpu.h>'?There are circular dependencies between the x86 arch headers that both use this and are used to implement this, and it's a bit fragile.
Grr. Indeed it seems to be. Nasty. Header files seem to want that
DECLARE_PER_CPU()thing without all the other baggage that is implied by including all of <linux/percpu.h>, so they just include <asm/percpu.h> directly instead.
Quoted 5 lines
What a mess.
So maybe we could move
DEFINE_PER_CPUin there too? It's less than perfect, but at least we'd have things together rather than split in really odd ways.
I think splitting the type related defines away into percpu_types.h, and updating the lowlevel headers to include linux/percpu_types.h [which would include asm/percpu.h] would do the trick.
Even the exising percpu.h could be made lighter:
slab.h: is needed for the kzalloc in the !SMP wrapper case. That
could be eliminated by uninlining the UP wrappers.
preempt.h: is needed for preempt_disable/enable() in the
get_cpu_var()/put_cpu_var() methods.
smp.h: not sure what it's needed for - nothing obvious at first
sight.
Most of them could be eliminated.
Ingo
Quoted 3 lines · Linus Torvalds
But yeah, I didn't look at all the details. It _looked_ pretty straightforward to just move the DEFINE/DECLARE stuff up, but there may well be something subtle I'm missing.
The problem is mainly one of #include recursion. There's way too much of it.
I wonder if we should replace the standard headerfile boilerplate:
#ifndef _THIS_HEADER_H #define _THIS_HEADER_H ... #endif /* _THIS_HEADER_H */
with something a bit nastier:
#ifndef _THIS_HEADER_H #define _THIS_HEADER_H 1 ... #undef _THIS_HEADER_H #define _THIS_HEADER_H 2 #elif _THIS_HEADER_H == 1 #error Recursive inclusion is not permitted #endif /* _THIS_HEADER_H */
and make people break up their header files to avoid getting this error.
There are a number of problems with doing this, of course; the least of which is that cpp has special code for handling the first case efficiently, IIRC.
David
Quoted 8 lines · David Howells
Quoted 3 lines · Linus Torvalds
But yeah, I didn't look at all the details. It _looked_ pretty straightforward to just move the DEFINE/DECLARE stuff up, but there may well be something subtle I'm missing.
The problem is mainly one of #include recursion. There's way too much of it.
that should be mapped and eliminated then.
Quoted 18 lines
I wonder if we should replace the standard headerfile boilerplate:
#ifndef _THIS_HEADER_H #define _THIS_HEADER_H ... #endif /* _THIS_HEADER_H */with something a bit nastier:
#ifndef _THIS_HEADER_H #define _THIS_HEADER_H 1 ... #undef _THIS_HEADER_H #define _THIS_HEADER_H 2 #elif _THIS_HEADER_H == 1 #error Recursive inclusion is not permitted #endif /* _THIS_HEADER_H */
Quoted 6 lines
and make people break up their header files to avoid getting this error.
There are a number of problems with doing this, of course; the least of which is that cpp has special code for handling the first case efficiently, IIRC.
The other problem with your scheme is that this does not make much sense.
There is absolutely _nothing_ wrong about defining structures in a hierarchical way! For example task_struct does have to combine a lot of derived types. It can use types directly and indirectly as well. Hierarchical data structures are _good_.
What _is_ wrong here is to allow inline functions _combine_ unrelated types randomly and 'mix up' an otherwise clean and logical hierarchy of data types.
The solution to this is the creation of a separate data versus method include file hiearchy: for example mm_types.h and spinlock_types.h.
Without having looked very deep into this particular problem you are hitting, this seems to be the problem here too.
There's three too 'thick' headers: linux/percpu.h, linux/prefetch.h and asm/processor.h.
include/linux/percpu.h, which provides essential data types and core primitives, also includes:
#include <linux/preempt.h>
#include <linux/slab.h> /* For kmalloc() */
#include <linux/smp.h>
#include <linux/cpumask.h>
#include <linux/pfn.h>
Just to be able to define an inline method:
static inline void *__alloc_percpu(size_t size, size_t align)
{
/*
* Can't easily make larger alignment work with kmalloc. WARN
* on it. Larger alignment should only be used for module
* percpu sections on SMP for which this path isn't used.
*/
WARN_ON_ONCE(align > SMP_CACHE_BYTES);
return kzalloc(size, GFP_KERNEL);
}Tada - now we've the combined 'percpu' and 'slab' spaces, on a very low level! These kinds of cross-dependencies quickly explode and create circular dependencies the moment you try to include any of this supposedly-simple header below the 'level' of slab.
The solution for this one?
Please create include/linux/percpu_types.h for basic data types and simple, self-sufficient primitives. Also have an include/linux/percpu_api.h or include/linux/percpu.h include file for convenience/speedup inlines. The latter will only be included in .c files, where 'combination' of type spaces is not a problem. (it is a virtue there.)
We did this in a number of other cases, and the concept works well. There are a number of details along the way, and a lot of build breakages and wide changes to overcome - but once the basics are in place that is mostly a mechanic, machine-helped spreading of the concept, not fragile or troublesome in any way.
The other problem is processor.h:
#include <asm/vm86.h>
#include <asm/math_emu.h>
#include <asm/segment.h>
#include <asm/types.h>
#include <asm/sigcontext.h>
#include <asm/current.h>
#include <asm/cpufeature.h>
#include <asm/system.h>
#include <asm/page.h>
#include <asm/pgtable_types.h>
#include <asm/percpu.h>
#include <asm/msr.h>
#include <asm/desc_defs.h>
#include <asm/nops.h>
#include <asm/ds.h>
#include <linux/personality.h>
#include <linux/cpumask.h>
#include <linux/cache.h>
#include <linux/threads.h>
#include <linux/init.h>
That too seems quite wide. linux/prefetch.h as well:
#include <linux/types.h>
#include <asm/processor.h>
#include <asm/cache.h>
It brings in processor.h which brings in a lot of other dependencies. For a supposedly simple-looking primitive - which is used in an inline function in processor.h.
Ingo
Quoted 4 lines · Ingo Molnar
Quoted 2 lines
The problem is mainly one of #include recursion. There's way too much of it.
that should be mapped and eliminated then.
Indeed. My suggestion was intended for after elimination to discourage it from returning.
Quoted 4 lines
There is absolutely _nothing_ wrong about defining structures in a hierarchical way! For example
task_structdoes have to combine a lot of derived types. It can use types directly and indirectly as well. Hierarchical data structures are _good_.
Indeed. I didn't say you shouldn't include one header file from another, just that you shouldn't have a cycle of header files that include one another.
Quoted 3 lines
The solution to this is the creation of a separate data versus method include file hiearchy: for example
mm_types.handspinlock_types.h.
That's what I've been doing - but it's not as simple as just splitting each header file in to two, however.
Quoted 2 lines
There's three too 'thick' headers:
linux/percpu.h,linux/prefetch.handasm/processor.h.
Yes, I noticed.
linux/percpu.h needs to be split three ways for instance: definitions, access methods, and alocators.
linux/prefetch.h isn't too bad: what it needs is the prefetch stuff splitting out of asm/processor.h into asm/prefetch.h.
Quoted 5 lines
Please create
include/linux/percpu_types.hfor basic data types and simple, self-sufficient primitives. Also have aninclude/linux/percpu_api.horinclude/linux/percpu.hinclude file for convenience/speedup inlines. The latter will only be included in .c files, where 'combination' of type spaces is not a problem.
Not so. The problem is that various header files make use of per-cpu variable accessors (asm/current.h and asm/thread_info.h to name a couple) to build inline asm.
Anyway, here are a pair of patches on top of the one I've already sent to Linus. The second breaks a number of header files into pieces and rearranges the percpu headers to put the DECLARE and DEFINE macros together.
The first patch could potentially be applied immediately. It adds #inclusions and forward refs that are required to iron out compile errors from the second patch.
Note that these only work for the configuration I routinely use on my x86_64 test machine. It will break all other arches and many other i386 and x86_64 configurations.
David
Add #inclusions and forward type declarations to a number of files to support future rearrangement of the header files.
---
arch/x86/ia32/ia32entry.S | 2 ++ arch/x86/include/asm/uaccess.h | 1 + arch/x86/include/asm/vmware.h | 2 ++ arch/x86/kernel/alternative.c | 1 + arch/x86/kernel/apic/nmi.c | 1 + arch/x86/kernel/cpu/mcheck/mce_64.c | 1 + arch/x86/kernel/cpu/vmware.c | 1 + arch/x86/kernel/head64.c | 1 + arch/x86/kernel/hpet.c | 1 + arch/x86/kernel/i387.c | 1 + arch/x86/kernel/tsc.c | 1 + arch/x86/lib/copy_user_64.S | 1 + arch/x86/lib/putuser.S | 1 + arch/x86/mm/pat.c | 1 + arch/x86/vdso/vma.c | 1 + drivers/base/bus.c | 1 + drivers/base/devres.c | 1 + drivers/base/driver.c | 1 + drivers/base/firmware_class.c | 1 + drivers/base/iommu.c | 1 + drivers/base/module.c | 1 + drivers/char/pty.c | 1 + drivers/char/tty_audit.c | 1 + drivers/cpufreq/cpufreq_stats.c | 1 + drivers/cpuidle/sysfs.c | 1 + drivers/firmware/dmi-id.c | 1 + drivers/firmware/memmap.c | 1 + drivers/i2c/i2c-boardinfo.c | 1 + drivers/input/ff-core.c | 1 + drivers/input/ff-memless.c | 1 + drivers/input/serio/i8042.c | 1 + drivers/power/power_supply_sysfs.c | 1 + drivers/rtc/class.c | 1 + drivers/serial/8250.c | 1 + drivers/thermal/thermal_sys.c | 1 + drivers/usb/core/driver.c | 1 + drivers/usb/core/endpoint.c | 1 + drivers/usb/core/file.c | 1 + drivers/video/fb_ddc.c | 1 + drivers/video/fbcvt.c | 1 + drivers/video/fbsysfs.c | 1 + drivers/video/modedb.c | 1 + drivers/video/output.c | 1 + fs/eventfd.c | 1 + fs/ext3/balloc.c | 1 + fs/fscache/operation.c | 1 + fs/fscache/page.c | 1 + fs/libfs.c | 4 ++-- fs/open.c | 1 + fs/ramfs/inode.c | 1 + fs/signalfd.c | 1 + fs/sync.c | 1 + fs/sysfs/inode.c | 1 + fs/sysfs/mount.c | 1 + fs/timerfd.c | 1 + include/linux/fsnotify.h | 1 + include/linux/jbd.h | 1 + include/linux/security.h | 1 + kernel/async.c | 1 + kernel/power/snapshot.c | 1 + kernel/power/swsusp.c | 1 + kernel/sched_cpupri.c | 1 + kernel/time/timecompare.c | 1 + kernel/timer.c | 1 + lib/kasprintf.c | 1 + lib/kref.c | 1 + lib/scatterlist.c | 1 + mm/sparse-vmemmap.c | 1 + mm/sparse.c | 1 + net/sunrpc/xdr.c | 1 + security/device_cgroup.c | 1 + 71 files changed, 74 insertions(+), 2 deletions(-)
arch/x86/ia32/ia32entry.S +2 -0
@@ -13,7 +13,9 @@ #include <asm/thread_info.h> #include <asm/segment.h> #include <asm/irqflags.h> +#include <asm/page_types.h> #include <linux/linkage.h> +#include <linux/percpu.h> /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */ #include <linux/elf-em.h>
arch/x86/include/asm/uaccess.h +1 -0
@@ -8,6 +8,7 @@#include <linux/thread_info.h> #include <linux/prefetch.h> #include <linux/string.h> +#include <linux/cache.h> #include <asm/asm.h> #include <asm/page.h>
arch/x86/include/asm/vmware.h +2 -0
@@ -20,6 +20,8 @@#ifndef ASM_X86__VMWARE_H #define ASM_X86__VMWARE_H +struct cpuinfo_x86 ; +extern unsigned long vmware_get_tsc_khz (void );extern int vmware_platform (void );extern void vmware_set_feature_bits (struct cpuinfo_x86 *c);
arch/x86/kernel/alternative.c +1 -0
@@ -6,6 +6,7 @@#include <linux/mm.h> #include <linux/vmalloc.h> #include <linux/memory.h> +#include <linux/slab.h> #include <asm/alternative.h> #include <asm/sections.h> #include <asm/pgtable.h>
arch/x86/kernel/apic/nmi.c +1 -0
@@ -26,6 +26,7 @@#include <linux/kernel_stat.h> #include <linux/kdebug.h> #include <linux/smp.h> +#include <linux/slab.h> #include <asm/i8259.h> #include <asm/io_apic.h>
arch/x86/kernel/cpu/mcheck/mce_64.c +1 -0
@@ -29,6 +29,7 @@#include <linux/kobject.h> #include <linux/sysfs.h> #include <linux/ratelimit.h> +#include <linux/slab.h> #include <asm/processor.h> #include <asm/msr.h> #include <asm/mce.h>
arch/x86/kernel/cpu/vmware.c +1 -0
@@ -24,6 +24,7 @@#include <linux/dmi.h> #include <asm/div64.h> #include <asm/vmware.h> +#include <asm/processor.h> #define CPUID_VMWARE_INFO_LEAF 0x40000000#define VMWARE_HYPERVISOR_MAGIC 0x564D5868
arch/x86/kernel/head64.c +1 -0
@@ -25,6 +25,7 @@#include <asm/e820.h> #include <asm/bios_ebda.h> #include <asm/trampoline.h> +#include <asm/fixmap.h> static void __init zap_identity_mappings (void ) {
arch/x86/kernel/hpet.c +1 -0
@@ -9,6 +9,7 @@#include <linux/cpu.h> #include <linux/pm.h> #include <linux/io.h> +#include <linux/slab.h> #include <asm/fixmap.h> #include <asm/i8253.h>
arch/x86/kernel/i387.c +1 -0
@@ -8,6 +8,7 @@#include <linux/module.h> #include <linux/regset.h> #include <linux/sched.h> +#include <linux/slab.h> #include <asm/sigcontext.h> #include <asm/processor.h>
arch/x86/kernel/tsc.c +1 -0
@@ -16,6 +16,7 @@#include <asm/time.h> #include <asm/delay.h> #include <asm/hypervisor.h> +#include <asm/apic.h> unsigned int __read_mostly cpu_khz;/* TSC clocks / usec, not used here */ EXPORT_SYMBOL (cpu_khz);
arch/x86/lib/copy_user_64.S +1 -0
@@ -15,6 +15,7 @@ #include <asm/asm-offsets.h> #include <asm/thread_info.h> #include <asm/cpufeature.h> +#include <asm/page_types.h> .macro ALTERNATIVE_JUMP feature,orig,alt 0:
arch/x86/lib/putuser.S +1 -0
@@ -13,6 +13,7 @@ #include <linux/linkage.h> #include <asm/dwarf2.h> #include <asm/thread_info.h> +#include <asm/page_types.h> #include <asm/errno.h> #include <asm/asm.h>
arch/x86/mm/pat.c +1 -0
@@ -15,6 +15,7 @@#include <linux/gfp.h> #include <linux/mm.h> #include <linux/fs.h> +#include <linux/slab.h> #include <asm/cacheflush.h> #include <asm/processor.h>
arch/x86/vdso/vma.c +1 -0
@@ -8,6 +8,7 @@#include <linux/sched.h> #include <linux/init.h> #include <linux/random.h> +#include <linux/slab.h> #include <asm/vsyscall.h> #include <asm/vgtod.h> #include <asm/proto.h>
drivers/base/bus.c +1 -0
@@ -15,6 +15,7 @@#include <linux/errno.h> #include <linux/init.h> #include <linux/string.h> +#include <linux/slab.h> #include "base.h" #include "power/power.h"
drivers/base/devres.c +1 -0
@@ -9,6 +9,7 @@#include <linux/device.h> #include <linux/module.h> +#include <linux/slab.h> #include "base.h"
drivers/base/driver.c +1 -0
@@ -14,6 +14,7 @@#include <linux/module.h> #include <linux/errno.h> #include <linux/string.h> +#include <linux/slab.h> #include "base.h" static struct device *next_device (struct klist_iter *i)
drivers/base/firmware_class.c +1 -0
@@ -17,6 +17,7 @@#include <linux/bitops.h> #include <linux/mutex.h> #include <linux/kthread.h> +#include <linux/slab.h> #include <linux/firmware.h> #include "base.h"
drivers/base/iommu.c +1 -0
@@ -20,6 +20,7 @@#include <linux/types.h> #include <linux/errno.h> #include <linux/iommu.h> +#include <linux/slab.h> static struct iommu_ops *iommu_ops;
drivers/base/module.c +1 -0
@@ -8,6 +8,7 @@#include <linux/module.h> #include <linux/errno.h> #include <linux/string.h> +#include <linux/slab.h> #include "base.h" static char *make_driver_name (struct device_driver *drv)
drivers/char/pty.c +1 -0
@@ -27,6 +27,7 @@#include <linux/uaccess.h> #include <linux/bitops.h> #include <linux/devpts_fs.h> +#include <linux/slab.h> #include <asm/system.h>
drivers/char/tty_audit.c +1 -0
@@ -11,6 +11,7 @@#include <linux/audit.h> #include <linux/tty.h> +#include <linux/slab.h> struct tty_audit_buf {atomic_t count;
drivers/cpufreq/cpufreq_stats.c +1 -0
@@ -19,6 +19,7 @@#include <linux/kobject.h> #include <linux/spinlock.h> #include <linux/notifier.h> +#include <linux/slab.h> #include <asm/cputime.h> static spinlock_t cpufreq_stats_lock;
drivers/cpuidle/sysfs.c +1 -0
@@ -10,6 +10,7 @@#include <linux/cpuidle.h> #include <linux/sysfs.h> #include <linux/cpu.h> +#include <linux/slab.h> #include "cpuidle.h"
drivers/firmware/dmi-id.c +1 -0
@@ -11,6 +11,7 @@#include <linux/init.h> #include <linux/dmi.h> #include <linux/device.h> +#include <linux/slab.h> struct dmi_device_attribute {struct device_attribute dev_attr;
drivers/firmware/memmap.c +1 -0
@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/types.h> #include <linux/bootmem.h> +#include <linux/slab.h> /* * Data types ------------------------------------------------------------------
drivers/i2c/i2c-boardinfo.c +1 -0
@@ -18,6 +18,7 @@#include <linux/kernel.h> #include <linux/i2c.h> +#include <linux/slab.h> #include "i2c-core.h"
drivers/input/ff-core.c +1 -0
@@ -29,6 +29,7 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/sched.h> +#include <linux/slab.h> /* * Check that the effect_id is a valid effect and whether the user
drivers/input/ff-memless.c +1 -0
@@ -30,6 +30,7 @@#include <linux/mutex.h> #include <linux/spinlock.h> #include <linux/jiffies.h> +#include <linux/slab.h> #include "fixp-arith.h"
drivers/input/serio/i8042.c +1 -0
@@ -20,6 +20,7 @@#include <linux/rcupdate.h> #include <linux/platform_device.h> #include <linux/i8042.h> +#include <linux/slab.h> #include <asm/io.h>
drivers/power/power_supply_sysfs.c +1 -0
@@ -13,6 +13,7 @@#include <linux/ctype.h> #include <linux/power_supply.h> +#include <linux/slab.h> #include "power_supply.h"
drivers/rtc/class.c +1 -0
@@ -15,6 +15,7 @@#include <linux/rtc.h> #include <linux/kdev_t.h> #include <linux/idr.h> +#include <linux/slab.h> #include "rtc-core.h"
drivers/serial/8250.c +1 -0
@@ -38,6 +38,7 @@#include <linux/serial_8250.h> #include <linux/nmi.h> #include <linux/mutex.h> +#include <linux/slab.h> #include <asm/io.h> #include <asm/irq.h>
drivers/thermal/thermal_sys.c +1 -0
@@ -31,6 +31,7 @@#include <linux/thermal.h> #include <linux/spinlock.h> #include <linux/reboot.h> +#include <linux/slab.h> MODULE_AUTHOR ("Zhang Rui" );MODULE_DESCRIPTION ("Generic thermal management sysfs support" );
drivers/usb/core/driver.c +1 -0
@@ -26,6 +26,7 @@#include <linux/usb.h> #include <linux/usb/quirks.h> #include <linux/workqueue.h> +#include <linux/slab.h> #include "hcd.h" #include "usb.h"
drivers/usb/core/endpoint.c +1 -0
@@ -13,6 +13,7 @@#include <linux/spinlock.h> #include <linux/idr.h> #include <linux/usb.h> +#include <linux/slab.h> #include "usb.h" #define MAX_ENDPOINT_MINORS (64*128*32)
drivers/usb/core/file.c +1 -0
@@ -20,6 +20,7 @@#include <linux/rwsem.h> #include <linux/smp_lock.h> #include <linux/usb.h> +#include <linux/slab.h> #include "usb.h"
drivers/video/fb_ddc.c +1 -0
@@ -12,6 +12,7 @@#include <linux/device.h> #include <linux/fb.h> #include <linux/i2c-algo-bit.h> +#include <linux/slab.h> #include "edid.h"
drivers/video/fbcvt.c +1 -0
@@ -13,6 +13,7 @@* */ #include <linux/fb.h> +#include <linux/slab.h> #define FB_CVT_CELLSIZE 8#define FB_CVT_GTF_C 40
drivers/video/fbsysfs.c +1 -0
@@ -19,6 +19,7 @@#include <linux/fb.h> #include <linux/console.h> #include <linux/module.h> +#include <linux/slab.h> #define FB_SYSFS_FLAG_ATTR 1
drivers/video/modedb.c +1 -0
@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/fb.h> +#include <linux/slab.h> #undef DEBUG
drivers/video/output.c +1 -0
@@ -25,6 +25,7 @@#include <linux/video_output.h> #include <linux/err.h> #include <linux/ctype.h> +#include <linux/slab.h> MODULE_DESCRIPTION ("Display Output Switcher Lowlevel Control Abstraction" );
fs/eventfd.c +1 -0
@@ -16,6 +16,7 @@#include <linux/anon_inodes.h> #include <linux/eventfd.h> #include <linux/syscalls.h> +#include <linux/slab.h> struct eventfd_ctx {wait_queue_head_t wqh;
fs/ext3/balloc.c +1 -0
@@ -19,6 +19,7 @@#include <linux/ext3_jbd.h> #include <linux/quotaops.h> #include <linux/buffer_head.h> +#include <linux/slab.h> /* * balloc.c contains the blocks allocation and deallocation routines
fs/fscache/operation.c +1 -0
@@ -13,6 +13,7 @@#define FSCACHE_DEBUG_LEVEL OPERATION#include <linux/module.h> +#include <linux/slab.h> #include "internal.h" atomic_t fscache_op_debug_id;
fs/fscache/page.c +1 -0
@@ -14,6 +14,7 @@#include <linux/fscache-cache.h> #include <linux/buffer_head.h> #include <linux/pagevec.h> +#include <linux/slab.h> #include "internal.h" /*
fs/libfs.c +2 -2
@@ -9,8 +9,8 @@#include <linux/vfs.h> #include <linux/mutex.h> #include <linux/exportfs.h> - -#include <asm/uaccess.h> +#include <linux/slab.h> +#include <linux/uaccess.h> int simple_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat)
fs/open.c +1 -0
@@ -30,6 +30,7 @@#include <linux/audit.h> #include <linux/falloc.h> #include <linux/fs_struct.h> +#include <linux/slab.h> int vfs_statfs (struct dentry *dentry,struct kstatfs *buf) {
fs/ramfs/inode.c +1 -0
@@ -34,6 +34,7 @@#include <linux/ramfs.h> #include <linux/sched.h> #include <linux/parser.h> +#include <linux/slab.h> #include <asm/uaccess.h> #include "internal.h"
fs/signalfd.c +1 -0
@@ -28,6 +28,7 @@#include <linux/anon_inodes.h> #include <linux/signalfd.h> #include <linux/syscalls.h> +#include <linux/slab.h> struct signalfd_ctx {sigset_t sigmask;
fs/sync.c +1 -0
@@ -13,6 +13,7 @@#include <linux/pagemap.h> #include <linux/quotaops.h> #include <linux/buffer_head.h> +#include <linux/slab.h> #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \ SYNC_FILE_RANGE_WAIT_AFTER)
fs/sysfs/inode.c +1 -0
@@ -18,6 +18,7 @@#include <linux/capability.h> #include <linux/errno.h> #include <linux/sched.h> +#include <linux/slab.h> #include "sysfs.h" extern struct super_block * sysfs_sb;
fs/sysfs/mount.c +1 -0
@@ -18,6 +18,7 @@#include <linux/init.h> #include <linux/module.h> #include <linux/magic.h> +#include <linux/slab.h> #include "sysfs.h"
fs/timerfd.c +1 -0
@@ -21,6 +21,7 @@#include <linux/anon_inodes.h> #include <linux/timerfd.h> #include <linux/syscalls.h> +#include <linux/slab.h> struct timerfd_ctx {struct hrtimer tmr;
include/linux/fsnotify.h +1 -0
@@ -14,6 +14,7 @@#include <linux/dnotify.h> #include <linux/inotify.h> #include <linux/audit.h> +#include <linux/slab.h> /* * fsnotify_d_instantiate - instantiate a dentry for inode
include/linux/jbd.h +1 -0
@@ -31,6 +31,7 @@#include <linux/mutex.h> #include <linux/timer.h> #include <linux/lockdep.h> +#include <linux/slab.h> #define journal_oom_retry 1
include/linux/security.h +1 -0
@@ -33,6 +33,7 @@#include <linux/key.h> #include <linux/xfrm.h> #include <linux/gfp.h> +#include <linux/slab.h> #include <net/flow.h> /* Maximum number of letters for an LSM name string */
kernel/async.c +1 -0
@@ -56,6 +56,7 @@ asynchronous and synchronous parts of the kernel.#include <linux/init.h> #include <linux/kthread.h> #include <linux/delay.h> +#include <linux/slab.h> #include <asm/atomic.h> static async_cookie_t next_cookie =1 ;
kernel/power/snapshot.c +1 -0
@@ -26,6 +26,7 @@#include <linux/console.h> #include <linux/highmem.h> #include <linux/list.h> +#include <linux/slab.h> #include <asm/uaccess.h> #include <asm/mmu_context.h>
kernel/power/swsusp.c +1 -0
@@ -52,6 +52,7 @@#include <linux/time.h> #include <linux/rbtree.h> #include <linux/io.h> +#include <linux/slab.h> #include "power.h"
kernel/sched_cpupri.c +1 -0
@@ -27,6 +27,7 @@* of the License. */ +#include <linux/gfp.h> #include "sched_cpupri.h" /* Convert between a 140 based task->prio, and our 102 based cpupri */
kernel/time/timecompare.c +1 -0
@@ -20,6 +20,7 @@#include <linux/timecompare.h> #include <linux/module.h> #include <linux/math64.h> +#include <linux/slab.h> /* * fixed point arithmetic scale factor for skew
kernel/timer.c +1 -0
@@ -37,6 +37,7 @@#include <linux/delay.h> #include <linux/tick.h> #include <linux/kallsyms.h> +#include <linux/slab.h> #include <asm/uaccess.h> #include <asm/unistd.h>
lib/kasprintf.c +1 -0
@@ -8,6 +8,7 @@#include <linux/module.h> #include <linux/types.h> #include <linux/string.h> +#include <linux/slab.h> /* Simplified asprintf. */ char *kvasprintf (gfp_t gfp,const char *fmt,va_list ap)
lib/kref.c +1 -0
@@ -13,6 +13,7 @@#include <linux/kref.h> #include <linux/module.h> +#include <linux/slab.h> /** * kref_set - initialize object and set refcount to requested number.
lib/scatterlist.c +1 -0
@@ -9,6 +9,7 @@#include <linux/module.h> #include <linux/scatterlist.h> #include <linux/highmem.h> +#include <linux/slab.h> /** * sg_next - return the next scatterlist entry in a list
mm/sparse-vmemmap.c +1 -0
@@ -25,6 +25,7 @@#include <linux/spinlock.h> #include <linux/vmalloc.h> #include <linux/sched.h> +#include <linux/slab.h> #include <asm/dma.h> #include <asm/pgalloc.h> #include <asm/pgtable.h>
mm/sparse.c +1 -0
@@ -8,6 +8,7 @@#include <linux/module.h> #include <linux/spinlock.h> #include <linux/vmalloc.h> +#include <linux/slab.h> #include "internal.h" #include <asm/dma.h> #include <asm/pgalloc.h>
net/sunrpc/xdr.c +1 -0
@@ -12,6 +12,7 @@#include <linux/kernel.h> #include <linux/pagemap.h> #include <linux/errno.h> +#include <linux/slab.h> #include <linux/sunrpc/xdr.h> #include <linux/sunrpc/msg_prot.h>
security/device_cgroup.c +1 -0
@@ -12,6 +12,7 @@#include <linux/seq_file.h> #include <linux/rcupdate.h> #include <linux/mutex.h> +#include <linux/slab.h> #define ACC_MKNOD 1#define ACC_READ 2
Move DECLARE_/DEFINE_PER_CPU*() to before the #inclusion of <asm/percpu.h> in linux/percpu.h. This puts the DECLARE and DEFINE macros together.
The declarations have to be before the #inclusion of <asm/percpu.h> because some asm/percpu.h's declare such variables - something that is probably done in the wrong place.
To make this work, this patch also has to rearrange and split a number of header files to eliminate circular references.
---
arch/alpha/include/asm/percpu.h | 6 - arch/x86/include/asm/alternative.h | 4 + arch/x86/include/asm/apic-defs.h | 14 +++ arch/x86/include/asm/apic.h | 5 - arch/x86/include/asm/current.h | 3 - arch/x86/include/asm/irq_regs.h | 2 arch/x86/include/asm/mm_types.h | 12 ++ arch/x86/include/asm/percpu-defs.h | 67 +++++++++++++ arch/x86/include/asm/percpu.h | 66 ------------ arch/x86/include/asm/prefetch.h | 49 +++++++++ arch/x86/include/asm/processor.h | 49 --------- arch/x86/include/asm/smp.h | 12 +- arch/x86/include/asm/stackprotector.h | 2 arch/x86/include/asm/thread_info-defs.h | 165 +++++++++++++++++++++++++++++++ arch/x86/include/asm/thread_info.h | 166 ++----------------------------- arch/x86/kernel/acpi/cstate.c | 1 drivers/net/loopback.c | 1 fs/nfs/iostat.h | 1 include/asm-generic/percpu-defs.h | 33 ++++++ include/asm-generic/percpu.h | 46 --------- include/linux/completion-defs.h | 30 ++++++ include/linux/completion.h | 18 --- include/linux/fs.h | 2 include/linux/genhd.h | 1 include/linux/gfp.h | 10 +- include/linux/mmzone.h | 6 + include/linux/percpu-alloc.h | 42 ++++++++ include/linux/percpu-defs.h | 79 +++++++++++++++ include/linux/percpu.h | 52 +--------- include/linux/preempt.h | 2 include/linux/prefetch.h | 3 - include/linux/rcupdate.h | 2 include/linux/seqlock-defs.h | 37 +++++++ include/linux/seqlock.h | 20 ++-- include/linux/spinlock.h | 1 include/linux/thread_info-defs.h | 54 ++++++++++ include/linux/thread_info.h | 44 -------- include/linux/wait-defs.h | 25 +++++ include/linux/wait.h | 21 ---- kernel/module.c | 1 kernel/srcu.c | 2 kernel/stop_machine.c | 1 kernel/workqueue.c | 1 lib/percpu_counter.c | 1 net/core/neighbour.c | 1 net/ipv4/af_inet.c | 1 46 files changed, 684 insertions(+), 477 deletions(-) create mode 100644 arch/x86/include/asm/apic-defs.h create mode 100644 arch/x86/include/asm/mm_types.h create mode 100644 arch/x86/include/asm/percpu-defs.h create mode 100644 arch/x86/include/asm/prefetch.h create mode 100644 arch/x86/include/asm/thread_info-defs.h create mode 100644 include/asm-generic/percpu-defs.h create mode 100644 include/linux/completion-defs.h create mode 100644 include/linux/percpu-alloc.h create mode 100644 include/linux/percpu-defs.h create mode 100644 include/linux/seqlock-defs.h create mode 100644 include/linux/thread_info-defs.h create mode 100644 include/linux/wait-defs.h
arch/alpha/include/asm/percpu.h +0 -6
@@ -3,12 +3,6 @@#include <linux/compiler.h> #include <linux/threads.h> -/* -* Determine the real variable name from the name visible in the -* kernel sources. -*/ -#define per_cpu_var (var) per_cpu__##var -#ifdef CONFIG_SMP /*
arch/x86/include/asm/alternative.h +4 -0
@@ -1,6 +1,8 @@#ifndef _ASM_X86_ALTERNATIVE_H#define _ASM_X86_ALTERNATIVE_H +#ifndef __ASSEMBLER__ +#include <linux/types.h> #include <linux/stddef.h> #include <asm/asm.h>
@@ -180,4 +182,6 @@ extern void add_nops(void *insns, unsigned int len);extern void *text_poke (void *addr,const void *opcode,size_t len);extern void *text_poke_early (void *addr,const void *opcode,size_t len); +#endif /* !__ASSEMBLER__ */ +#endif /* _ASM_X86_ALTERNATIVE_H */
arch/x86/include/asm/apic-defs.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _ASM_X86_APIC_DEFS_H +#define _ASM_X86_APIC_DEFS_H + +#include <linux/percpu-defs.h> + +#ifdef CONFIG_X86_64 +DECLARE_PER_CPU (int, x2apic_extra_bits); +#endif + +#ifdef CONFIG_X86_LOCAL_APIC +DECLARE_EARLY_PER_CPU (u16, x86_bios_cpu_apicid); +#endif + +#endif /* _ASM_X86_APIC_DEFS_H */
arch/x86/include/asm/apic.h +2 -3
@@ -4,7 +4,9 @@#include <linux/cpumask.h> #include <linux/delay.h> #include <linux/pm.h> +#include <linux/percpu.h> +#include <asm/apic-defs.h> #include <asm/alternative.h> #include <asm/cpufeature.h> #include <asm/processor.h>
@@ -432,7 +434,6 @@ extern int default_acpi_madt_oem_check(char *, char *);extern void apic_send_IPI_self (int vector);extern struct apic apic_x2apic_uv_x; -DECLARE_PER_CPU (int, x2apic_extra_bits);extern int default_cpu_present_to_apicid (int mps_cpu);extern int default_check_phys_apicid_present (int boot_cpu_physical_apicid);
@@ -463,8 +464,6 @@ static inline const struct cpumask *default_target_cpus(void)#endif } -DECLARE_EARLY_PER_CPU (u16, x86_bios_cpu_apicid); -static inline unsigned int read_apic_id (void ) {
arch/x86/include/asm/current.h +2 -1
@@ -2,9 +2,10 @@#define _ASM_X86_CURRENT_H#include <linux/compiler.h> -#include <asm/percpu.h> #ifndef __ASSEMBLY__ +#include <linux/percpu.h> +struct task_struct ; DECLARE_PER_CPU(struct task_struct *, current_task);
arch/x86/include/asm/irq_regs.h +1 -1
@@ -7,7 +7,7 @@#ifndef _ASM_X86_IRQ_REGS_H#define _ASM_X86_IRQ_REGS_H -#include <asm/percpu.h> +#include <linux/percpu-defs.h> #define ARCH_HAS_OWN_IRQ_REGS
arch/x86/include/asm/mm_types.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef _ASM_X86_MM_TYPES_H +#define _ASM_X86_MM_TYPES_H + +#ifndef __ASSEMBLY__ + +typedef struct { +unsigned long seg; +}mm_segment_t ; + +#endif /* __ASSEMBLY__ */ + +#endif /* _ASM_X86_MM_TYPES_H */
arch/x86/include/asm/percpu-defs.h new file +67 -0
67 lines not on this page · raw message
arch/x86/include/asm/percpu.h +2 -64
88 lines not on this page · raw message
arch/x86/include/asm/prefetch.h new file +49 -0
49 lines not on this page · raw message
arch/x86/include/asm/processor.h +2 -47
80 lines not on this page · raw message
arch/x86/include/asm/smp.h +7 -5
@@ -3,14 +3,14 @@#ifndef __ASSEMBLY__#include <linux/cpumask.h> #include <linux/init.h> -#include <asm/percpu.h> +#include <linux/percpu-defs.h> /* * We need the APIC definitions automatically as part of 'smp.h' */ #ifdef CONFIG_X86_LOCAL_APIC # include <asm/mpspec.h> -# include <asm/apic.h> +# include <asm/apic-defs.h> # ifdef CONFIG_X86_IO_APIC # include <asm/io_apic.h> # endif
@@ -26,6 +26,11 @@ DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);DECLARE_PER_CPU (u16, cpu_llc_id);DECLARE_PER_CPU (int, cpu_number); +DECLARE_EARLY_PER_CPU (u16, x86_cpu_to_apicid); +DECLARE_EARLY_PER_CPU (u16, x86_bios_cpu_apicid); + +#include <linux/percpu.h> +static inline struct cpumask *cpu_sibling_mask (int cpu) {return per_cpu (cpu_sibling_map, cpu);
@@ -36,9 +41,6 @@ static inline struct cpumask *cpu_core_mask(int cpu)return per_cpu (cpu_core_map, cpu); } -DECLARE_EARLY_PER_CPU (u16, x86_cpu_to_apicid); -DECLARE_EARLY_PER_CPU (u16, x86_bios_cpu_apicid); -/* Static state in head.S used to set up a CPU */ extern struct { void *sp;
arch/x86/include/asm/stackprotector.h +1 -1
@@ -37,7 +37,7 @@#include <asm/tsc.h> #include <asm/processor.h> -#include <asm/percpu.h> +#include <linux/percpu-defs.h> #include <asm/system.h> #include <asm/desc.h> #include <linux/random.h>
arch/x86/include/asm/thread_info-defs.h new file +165 -0
165 lines not on this page · raw message
arch/x86/include/asm/thread_info.h +12 -154
221 lines not on this page · raw message
arch/x86/kernel/acpi/cstate.c +1 -0
@@ -10,6 +10,7 @@#include <linux/acpi.h> #include <linux/cpu.h> #include <linux/sched.h> +#include <linux/percpu-alloc.h> #include <acpi/processor.h> #include <asm/acpi.h>
drivers/net/loopback.c +1 -0
@@ -40,6 +40,7 @@#include <linux/fcntl.h> #include <linux/in.h> #include <linux/init.h> +#include <linux/percpu-alloc.h> #include <asm/system.h> #include <asm/uaccess.h>
fs/nfs/iostat.h +1 -0
@@ -11,6 +11,7 @@#define _NFS_IOSTAT#include <linux/percpu.h> +#include <linux/percpu-alloc.h> #include <linux/cache.h> #include <linux/nfs_iostat.h>
include/asm-generic/percpu-defs.h new file +33 -0
@@ -0,0 +1,33 @@ +#ifndef _ASM_GENERIC_PERCPU_DEFS_H +#define _ASM_GENERIC_PERCPU_DEFS_H + + +#ifndef PER_CPU_BASE_SECTION +#ifdef CONFIG_SMP +#define PER_CPU_BASE_SECTION ".data.percpu" +#else +#define PER_CPU_BASE_SECTION ".data" +#endif +#endif + +#ifdef CONFIG_SMP + +#ifdef MODULE +#define PER_CPU_SHARED_ALIGNED_SECTION "" +#else +#define PER_CPU_SHARED_ALIGNED_SECTION ".shared_aligned" +#endif +#define PER_CPU_FIRST_SECTION ".first" + +#else + +#define PER_CPU_SHARED_ALIGNED_SECTION "" +#define PER_CPU_FIRST_SECTION "" + +#endif + +#ifndef PER_CPU_ATTRIBUTES +#define PER_CPU_ATTRIBUTES +#endif + +#endif /* _ASM_GENERIC_PERCPU_DEFS_H */
include/asm-generic/percpu.h +0 -46
50 lines not on this page · raw message
include/linux/completion-defs.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef __LINUX_COMPLETION_DEFS_H +#define __LINUX_COMPLETION_DEFS_H + +/* +* (C) Copyright 2001 Linus Torvalds +* +* Atomic wait-for-completion handler data structures. +* See kernel/sched.c for details. +*/ + +#include <linux/wait-defs.h> + +/** +* struct completion - structure used to maintain state for a "completion" +* +* This is the opaque structure used to maintain the state for a "completion". +* Completions currently use a FIFO to queue threads that have to wait for +* the "completion" event. +* +* See also: complete(), wait_for_completion() (and friends _timeout, +* _interruptible, _interruptible_timeout, and _killable), init_completion(), +* and macros DECLARE_COMPLETION(), DECLARE_COMPLETION_ONSTACK(), and +* INIT_COMPLETION(). +*/ +struct completion { +unsigned int done; +wait_queue_head_t wait; +}; + +#endif /* __LINUX_COMPLETION_DEFS_H */
include/linux/completion.h +1 -17
@@ -8,25 +8,9 @@* See kernel/sched.c for details. */ +#include <linux/completion-defs.h> #include <linux/wait.h> -/** -* struct completion - structure used to maintain state for a "completion" -* -* This is the opaque structure used to maintain the state for a "completion". -* Completions currently use a FIFO to queue threads that have to wait for -* the "completion" event. -* -* See also: complete(), wait_for_completion() (and friends _timeout, -* _interruptible, _interruptible_timeout, and _killable), init_completion(), -* and macros DECLARE_COMPLETION(), DECLARE_COMPLETION_ONSTACK(), and -* INIT_COMPLETION(). -*/ -struct completion { -unsigned int done; -wait_queue_head_t wait; -}; -#define COMPLETION_INITIALIZER (work) \ { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
include/linux/fs.h +1 -1
@@ -297,7 +297,7 @@ struct inodes_stat_t {#ifdef __KERNEL__#include <linux/linkage.h> -#include <linux/wait.h> +#include <linux/wait-defs.h> #include <linux/types.h> #include <linux/kdev_t.h> #include <linux/dcache.h>
include/linux/genhd.h +1 -0
@@ -12,6 +12,7 @@#include <linux/types.h> #include <linux/kdev_t.h> #include <linux/rcupdate.h> +#include <linux/percpu-alloc.h> #ifdef CONFIG_BLOCK
include/linux/gfp.h +6 -4
@@ -1,10 +1,7 @@#ifndef __LINUX_GFP_H#define __LINUX_GFP_H -#include <linux/mmzone.h> -#include <linux/stddef.h> -#include <linux/linkage.h> -#include <linux/topology.h> +#include <linux/types.h> struct vm_area_struct ;
@@ -99,6 +96,11 @@ struct vm_area_struct;/* 4GB DMA on some platforms */ #define GFP_DMA32 __GFP_DMA32 +#include <linux/mmzone.h> +#include <linux/stddef.h> +#include <linux/linkage.h> +#include <linux/topology.h> +/* Convert GFP flags to their corresponding migrate type */ static inline int allocflags_to_migratetype (gfp_t gfp_flags) {
include/linux/mmzone.h +3 -3
@@ -4,15 +4,15 @@#ifndef __ASSEMBLY__#ifndef __GENERATING_BOUNDS_H -#include <linux/spinlock.h> +#include <linux/spinlock_types.h> #include <linux/list.h> -#include <linux/wait.h> +#include <linux/wait-defs.h> #include <linux/bitops.h> #include <linux/cache.h> #include <linux/threads.h> #include <linux/numa.h> #include <linux/init.h> -#include <linux/seqlock.h> +#include <linux/seqlock-defs.h> #include <linux/nodemask.h> #include <linux/pageblock-flags.h> #include <linux/bounds.h>
include/linux/percpu-alloc.h new file +42 -0
42 lines not on this page · raw message
include/linux/percpu-defs.h new file +79 -0
79 lines not on this page · raw message
include/linux/percpu.h +6 -46
85 lines not on this page · raw message
include/linux/preempt.h +1 -1
@@ -6,7 +6,7 @@* preempt_count (used for kernel preemption, interrupt count, etc.) */ -#include <linux/thread_info.h> +#include <linux/thread_info-defs.h> #include <linux/linkage.h> #include <linux/list.h>
include/linux/prefetch.h +1 -2
@@ -11,8 +11,7 @@#define _LINUX_PREFETCH_H#include <linux/types.h> -#include <asm/processor.h> -#include <asm/cache.h> +#include <asm/prefetch.h> /* prefetch(x) attempts to pre-emptively get the memory pointed to
include/linux/rcupdate.h +1 -1
@@ -39,7 +39,7 @@#include <linux/cpumask.h> #include <linux/seqlock.h> #include <linux/lockdep.h> -#include <linux/completion.h> +#include <linux/completion-defs.h> /** * struct rcu_head - callback structure for use with RCU
include/linux/seqlock-defs.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Reader/writer consistent mechanism without starving writers. This type of +* lock for data where the reader wants a consistent set of information +* and is willing to retry if the information changes. Readers never +* block but they may have to retry if a writer is in +* progress. Writers do not wait for readers. +* +* This is not as cache friendly as brlock. Also, this will not work +* for data that contains pointers, because any writer could +* invalidate a pointer that a reader was following. +* +* Expected reader usage: +* do { +* seq = read_seqbegin(&foo); +* ... +* } while (read_seqretry(&foo, seq)); +* +* +* On non-SMP the spin locks disappear but the writer still needs +* to increment the sequence variables because an interrupt routine could +* change the state of the data. +* +* Based on x86_64 vsyscall gettimeofday +* by Keith Owens and Andrea Arcangeli +*/ + +#ifndef __LINUX_SEQLOCK_DEFS_H +#define __LINUX_SEQLOCK_DEFS_H + +#include <linux/spinlock_types.h> + +typedef struct { +unsigned sequence; +spinlock_t lock; +}seqlock_t ; + +#endif /* __LINUX_SEQLOCK_DEFS_H */
include/linux/seqlock.h +9 -11
@@ -1,11 +1,9 @@ -#ifndef __LINUX_SEQLOCK_H -#define __LINUX_SEQLOCK_H/* * Reader/writer consistent mechanism without starving writers. This type of * lock for data where the reader wants a consistent set of information * and is willing to retry if the information changes. Readers never * block but they may have to retry if a writer is in -* progress. Writers do not wait for readers. +* progress. Writers do not wait for readers. * * This is not as cache friendly as brlock. Also, this will not work * for data that contains pointers, because any writer could
@@ -22,17 +20,16 @@* to increment the sequence variables because an interrupt routine could * change the state of the data. * -* Based on x86_64 vsyscall gettimeofday +* Based on x86_64 vsyscall gettimeofday * by Keith Owens and Andrea Arcangeli */ -#include <linux/spinlock.h> -#include <linux/preempt.h> +#ifndef __LINUX_SEQLOCK_H +#define __LINUX_SEQLOCK_H -typedef struct { -unsigned sequence; -spinlock_t lock; -}seqlock_t ; +#include <linux/seqlock-defs.h> +#include <linux/preempt.h> +#include <linux/spinlock.h> /* * These macros triggered gcc-3.x compile-time problems. We think these are
@@ -53,7 +50,8 @@ typedef struct {#define DEFINE_SEQLOCK (x) \ seqlock_t x = __SEQLOCK_UNLOCKED(x) -/* Lock out other writers and update the count. +/* +* Lock out other writers and update the count. * Acts like a normal spin_lock/unlock. * Don't need preempt_disable() because that is in the spin_lock already. */
include/linux/spinlock.h +0 -1
@@ -50,7 +50,6 @@#include <linux/preempt.h> #include <linux/linkage.h> #include <linux/compiler.h> -#include <linux/thread_info.h> #include <linux/kernel.h> #include <linux/stringify.h> #include <linux/bottom_half.h>
include/linux/thread_info-defs.h new file +54 -0
54 lines not on this page · raw message
include/linux/thread_info.h +2 -42
54 lines not on this page · raw message
include/linux/wait-defs.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef _LINUX_WAIT_DEFS_H +#define _LINUX_WAIT_DEFS_H + +#include <linux/spinlock_types.h> +#include <linux/list.h> + +struct __wait_queue_head { +spinlock_t lock; +struct list_head task_list; +}; +typedef struct __wait_queue_head wait_queue_head_t ; + +typedef struct __wait_queue wait_queue_t ; + +typedef int (*wait_queue_func_t )(wait_queue_t *wait,unsigned mode,int sync,void *key); + +struct __wait_queue { +unsigned int flags; +#define WQ_FLAG_EXCLUSIVE 0x01 +void *private; +wait_queue_func_t func; +struct list_head task_list; +}; + +#endif /* _LINUX_WAIT_DEFS_H */
include/linux/wait.h +2 -19
@@ -21,22 +21,10 @@#include <linux/list.h> #include <linux/stddef.h> -#include <linux/spinlock.h> +#include <linux/wait-defs.h> #include <asm/system.h> #include <asm/current.h> -typedef struct __wait_queue wait_queue_t ; -typedef int (*wait_queue_func_t )(wait_queue_t *wait,unsigned mode,int sync,void *key); -int default_wake_function (wait_queue_t *wait,unsigned mode,int sync,void *key); - -struct __wait_queue { -unsigned int flags; -#define WQ_FLAG_EXCLUSIVE 0x01 -void *private; -wait_queue_func_t func; -struct list_head task_list; -}; -struct wait_bit_key {void *flags;int bit_nr;
@@ -47,17 +35,12 @@ struct wait_bit_queue {wait_queue_t wait; }; -struct __wait_queue_head { -spinlock_t lock; -struct list_head task_list; -}; -typedef struct __wait_queue_head wait_queue_head_t ; -struct task_struct ;/* * Macros for declaration and initialisaton of the datatypes */ +extern int default_wake_function (wait_queue_t *wait,unsigned mode,int sync,void *key);#define __WAITQUEUE_INITIALIZER (name, tsk) { \ .private = tsk, \
kernel/module.c +1 -0
@@ -52,6 +52,7 @@#include <linux/ftrace.h> #include <linux/async.h> #include <linux/percpu.h> +#include <linux/percpu-alloc.h> #if 0 #define DEBUGP printk
kernel/srcu.c +1 -1
@@ -26,7 +26,7 @@#include <linux/module.h> #include <linux/mutex.h> -#include <linux/percpu.h> +#include <linux/percpu-alloc.h> #include <linux/preempt.h> #include <linux/rcupdate.h> #include <linux/sched.h>
kernel/stop_machine.c +1 -0
@@ -9,6 +9,7 @@#include <linux/stop_machine.h> #include <linux/syscalls.h> #include <linux/interrupt.h> +#include <linux/percpu-alloc.h> #include <asm/atomic.h> #include <asm/uaccess.h>
kernel/workqueue.c +1 -0
@@ -33,6 +33,7 @@#include <linux/kallsyms.h> #include <linux/debug_locks.h> #include <linux/lockdep.h> +#include <linux/percpu-alloc.h> #include <trace/workqueue.h> /*
lib/percpu_counter.c +1 -0
@@ -3,6 +3,7 @@*/ #include <linux/percpu_counter.h> +#include <linux/percpu-alloc.h> #include <linux/notifier.h> #include <linux/mutex.h> #include <linux/init.h>
net/core/neighbour.c +1 -0
@@ -35,6 +35,7 @@#include <linux/random.h> #include <linux/string.h> #include <linux/log2.h> +#include <linux/percpu-alloc.h> #define NEIGH_DEBUG 1
net/ipv4/af_inet.c +1 -0
@@ -86,6 +86,7 @@#include <linux/poll.h> #include <linux/netfilter_ipv4.h> #include <linux/random.h> +#include <linux/percpu-alloc.h> #include <asm/uaccess.h> #include <asm/system.h>
Quoted 7 lines · David Howells
Quoted 2 lines
There's three too 'thick' headers:
linux/percpu.h,linux/prefetch.handasm/processor.h.Yes, I noticed.
linux/percpu.hneeds to be split three ways for instance:
definitions, access methods, and alocators.
yeah. Often a super-header has to be split into several basic headers or header pairs.
Quoted 2 lines
linux/prefetch.hisn't too bad: what it needs is the prefetch stuff splitting out ofasm/processor.hintoasm/prefetch.h.
yeah.
Quoted 10 lines
Quoted 6 lines
Please create
include/linux/percpu_types.hfor basic data types and simple, self-sufficient primitives. Also have aninclude/linux/percpu_api.horinclude/linux/percpu.hinclude file for convenience/speedup inlines. The latter will only be included in .c files, where 'combination' of type spaces is not a problem.Not so. The problem is that various header files make use of per-cpu variable accessors (
asm/current.handasm/thread_info.hto name a couple) to build inline asm.
Hm, what portion did you mark with 'not so'?
inline asm is used in inline functions there, and that is what 'instantiates' the types in a 'mixed' manner and way below their proper hierarchic level as well - creating both a mess and, as mess increases above a critical threshold an inevitable circular dependency as well.
Quoted 5 lines
Anyway, here are a pair of patches on top of the one I've already sent to Linus. The second breaks a number of header files into pieces and rearranges the percpu headers to put the DECLARE and DEFINE macros together.
Quoted 7 lines
The first patch could potentially be applied immediately. It adds #inclusions and forward refs that are required to iron out compile errors from the second patch.
Note that these only work for the configuration I routinely use on my
x86_64test machine. It will break all other arches and many other i386 andx86_64configurations.
I dont disagree, but i'd like to warn that such patches need _way_ more testing, these are never same-day obvious patches.
We have split up one big x86 header in this development cycle (asm/pgtable.h) and that alone was highly non-trivial and needed about a week to settle down, even with intense development and testing.
Ingo
Quoted 7 lines · Ingo Molnar
Quoted 7 lines
Quoted 6 lines
Please create
include/linux/percpu_types.hfor basic data types and simple, self-sufficient primitives. Also have aninclude/linux/percpu_api.horinclude/linux/percpu.hinclude file for convenience/speedup inlines. The latter will only be included in .c files, where 'combination' of type spaces is not a problem.
Quoted 5 lines
Quoted 3 lines
Not so. The problem is that various header files make use of per-cpu variable accessors (
asm/current.handasm/thread_info.hto name a couple) to build inline asm.Hm, what portion did you mark with 'not so'?
The statement that "The latter will only be included in .c files, where 'combination' of type spaces is not a problem".
Quoted 2 lines
I dont disagree, but i'd like to warn that such patches need _way_ more testing, these are never same-day obvious patches.
I can't argue with that.
I'd like Linus to pull my first patch, if he will. That'll at least allow FRV to build. Could you review it? That's the email that started this thread, ensubjected:
[PATCH] FRV: Fix the section attribute on UP DECLARE_PER_CPU()
David
Quoted 5 lines · David Howells
I'd like Linus to pull my first patch, if he will. That'll at least allow FRV to build. Could you review it? That's the email that started this thread, ensubjected:
[PATCH] FRV: Fix the section attribute on UP
DECLARE_PER_CPU()
hm, this moves the section defines from a generic header into platform headers in essence - not a good move IMO.
Why not start a new linux/percpu_types.h header with just those defines in place, include it both from linux/percpu.h and from all the asm*/percpu.h files you modify in that patch?
This would fix your build problem minimally - and it would also seed the new percpu_types.h file that could start the untangling of this dependency hell.
(it would also be much easier to verify for correctness - you just move bits and include it trivially in places that need it.)
Am i missing something?
Ingo
Any idea what this:
#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name)
is intended for?
David
Quoted 5 lines · David Howells
Any idea what this:
#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name)is intended for?
it is a mixed type of percpu variable: which is per CPU but which can (and will) also be accessed from other CPUs. This way we basically cache-line align it and make sure nearby percpu variables dont get caught up in any cacheline bounces. It was introduced a couple of years ago.
Ingo