diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2005-09-03 15:54:30 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-05 00:05:39 -0700 |
commit | fd4fd5aac1282825195c6816ed40a2a6d42db5bf (patch) | |
tree | 5908cf4c88a7c9d69ea7bdc1c354d51b6ff47f86 /include | |
parent | 28ae55c98e4d16eac9a05a8a259d7763ef3aeb18 (diff) | |
download | op-kernel-dev-fd4fd5aac1282825195c6816ed40a2a6d42db5bf.zip op-kernel-dev-fd4fd5aac1282825195c6816ed40a2a6d42db5bf.tar.gz |
[PATCH] mm: consolidate get_order
Someone mentioned that almost all the architectures used basically the same
implementation of get_order. This patch consolidates them into
asm-generic/page.h and includes that in the appropriate places. The
exceptions are ia64 and ppc which have their own (presumably optimised)
versions.
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-alpha/page.h | 16 | ||||
-rw-r--r-- | include/asm-arm/page.h | 16 | ||||
-rw-r--r-- | include/asm-arm26/page.h | 16 | ||||
-rw-r--r-- | include/asm-cris/page.h | 15 | ||||
-rw-r--r-- | include/asm-frv/page.h | 17 | ||||
-rw-r--r-- | include/asm-generic/page.h | 26 | ||||
-rw-r--r-- | include/asm-h8300/page.h | 16 | ||||
-rw-r--r-- | include/asm-i386/page.h | 16 | ||||
-rw-r--r-- | include/asm-m32r/page.h | 21 | ||||
-rw-r--r-- | include/asm-m68k/page.h | 16 | ||||
-rw-r--r-- | include/asm-m68knommu/page.h | 16 | ||||
-rw-r--r-- | include/asm-mips/page.h | 16 | ||||
-rw-r--r-- | include/asm-parisc/page.h | 16 | ||||
-rw-r--r-- | include/asm-ppc64/page.h | 17 | ||||
-rw-r--r-- | include/asm-s390/page.h | 16 | ||||
-rw-r--r-- | include/asm-sh/page.h | 20 | ||||
-rw-r--r-- | include/asm-sh64/page.h | 20 | ||||
-rw-r--r-- | include/asm-sparc/page.h | 16 | ||||
-rw-r--r-- | include/asm-sparc64/page.h | 16 | ||||
-rw-r--r-- | include/asm-um/page.h | 16 | ||||
-rw-r--r-- | include/asm-v850/page.h | 21 | ||||
-rw-r--r-- | include/asm-x86_64/page.h | 16 |
22 files changed, 69 insertions, 312 deletions
diff --git a/include/asm-alpha/page.h b/include/asm-alpha/page.h index 0577daf..fa0b41b 100644 --- a/include/asm-alpha/page.h +++ b/include/asm-alpha/page.h @@ -63,20 +63,6 @@ typedef unsigned long pgprot_t; #endif /* STRICT_MM_TYPECHECKS */ -/* Pure 2^n version of get_order */ -extern __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - #ifdef USE_48_BIT_KSEG #define PAGE_OFFSET 0xffff800000000000UL #else @@ -112,4 +98,6 @@ extern __inline__ int get_order(unsigned long size) #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _ALPHA_PAGE_H */ diff --git a/include/asm-arm/page.h b/include/asm-arm/page.h index 019c45d..4da1d53 100644 --- a/include/asm-arm/page.h +++ b/include/asm-arm/page.h @@ -163,20 +163,6 @@ typedef unsigned long pgprot_t; /* the upper-most page table pointer */ extern pmd_t *top_pmd; -/* Pure 2^n version of get_order */ -static inline int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - #include <asm/memory.h> #endif /* !__ASSEMBLY__ */ @@ -186,4 +172,6 @@ static inline int get_order(unsigned long size) #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif diff --git a/include/asm-arm26/page.h b/include/asm-arm26/page.h index c334079..d3f23ac 100644 --- a/include/asm-arm26/page.h +++ b/include/asm-arm26/page.h @@ -89,20 +89,6 @@ typedef unsigned long pgprot_t; #ifdef __KERNEL__ #ifndef __ASSEMBLY__ -/* Pure 2^n version of get_order */ -static inline int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - #include <asm/memory.h> #endif /* !__ASSEMBLY__ */ @@ -112,4 +98,6 @@ static inline int get_order(unsigned long size) #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif diff --git a/include/asm-cris/page.h b/include/asm-cris/page.h index bbf17bd..c99c478 100644 --- a/include/asm-cris/page.h +++ b/include/asm-cris/page.h @@ -70,19 +70,6 @@ typedef struct { unsigned long pgprot; } pgprot_t; #ifndef __ASSEMBLY__ -/* Pure 2^n version of get_order */ -static inline int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} #endif /* __ASSEMBLY__ */ #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ @@ -90,5 +77,7 @@ static inline int get_order(unsigned long size) #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _CRIS_PAGE_H */ diff --git a/include/asm-frv/page.h b/include/asm-frv/page.h index f7914f1..4feba56 100644 --- a/include/asm-frv/page.h +++ b/include/asm-frv/page.h @@ -45,21 +45,6 @@ typedef struct { unsigned long pgprot; } pgprot_t; /* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) -/* Pure 2^n version of get_order */ -static inline int get_order(unsigned long size) __attribute_const__; -static inline int get_order(unsigned long size) -{ - int order; - - size = (size - 1) >> (PAGE_SHIFT - 1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - #define devmem_is_allowed(pfn) 1 #define __pa(vaddr) virt_to_phys((void *) vaddr) @@ -102,4 +87,6 @@ extern unsigned long max_pfn; #define WANT_PAGE_VIRTUAL 1 #endif +#include <asm-generic/page.h> + #endif /* _ASM_PAGE_H */ diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h new file mode 100644 index 0000000..a96b5d9 --- /dev/null +++ b/include/asm-generic/page.h @@ -0,0 +1,26 @@ +#ifndef _ASM_GENERIC_PAGE_H +#define _ASM_GENERIC_PAGE_H + +#ifdef __KERNEL__ +#ifndef __ASSEMBLY__ + +#include <linux/compiler.h> + +/* Pure 2^n version of get_order */ +static __inline__ __attribute_const__ int get_order(unsigned long size) +{ + int order; + + size = (size - 1) >> (PAGE_SHIFT - 1); + order = -1; + do { + size >>= 1; + order++; + } while (size); + return order; +} + +#endif /* __ASSEMBLY__ */ +#endif /* __KERNEL__ */ + +#endif /* _ASM_GENERIC_PAGE_H */ diff --git a/include/asm-h8300/page.h b/include/asm-h8300/page.h index e3b7960..e8c02b8 100644 --- a/include/asm-h8300/page.h +++ b/include/asm-h8300/page.h @@ -54,20 +54,6 @@ typedef struct { unsigned long pgprot; } pgprot_t; /* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) -/* Pure 2^n version of get_order */ -extern __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - extern unsigned long memory_start; extern unsigned long memory_end; @@ -101,4 +87,6 @@ extern unsigned long memory_end; #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _H8300_PAGE_H */ diff --git a/include/asm-i386/page.h b/include/asm-i386/page.h index 8d93f73..10045fd 100644 --- a/include/asm-i386/page.h +++ b/include/asm-i386/page.h @@ -104,20 +104,6 @@ typedef struct { unsigned long pgprot; } pgprot_t; */ extern unsigned int __VMALLOC_RESERVE; -/* Pure 2^n version of get_order */ -static __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - extern int sysctl_legacy_va_layout; extern int page_is_ram(unsigned long pagenr); @@ -156,4 +142,6 @@ extern int page_is_ram(unsigned long pagenr); #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _I386_PAGE_H */ diff --git a/include/asm-m32r/page.h b/include/asm-m32r/page.h index 1c6abb9..4ab5788 100644 --- a/include/asm-m32r/page.h +++ b/include/asm-m32r/page.h @@ -61,25 +61,6 @@ typedef struct { unsigned long pgprot; } pgprot_t; /* This handles the memory map.. */ -#ifndef __ASSEMBLY__ - -/* Pure 2^n version of get_order */ -static __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size - 1) >> (PAGE_SHIFT - 1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - - return order; -} - -#endif /* __ASSEMBLY__ */ - #define __MEMORY_START CONFIG_MEMORY_START #define __MEMORY_SIZE CONFIG_MEMORY_SIZE @@ -111,5 +92,7 @@ static __inline__ int get_order(unsigned long size) #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _ASM_M32R_PAGE_H */ diff --git a/include/asm-m68k/page.h b/include/asm-m68k/page.h index 206313e..f206dfb 100644 --- a/include/asm-m68k/page.h +++ b/include/asm-m68k/page.h @@ -107,20 +107,6 @@ typedef struct { unsigned long pgprot; } pgprot_t; /* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) -/* Pure 2^n version of get_order */ -static inline int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - #endif /* !__ASSEMBLY__ */ #include <asm/page_offset.h> @@ -192,4 +178,6 @@ static inline void *__va(unsigned long x) #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _M68K_PAGE_H */ diff --git a/include/asm-m68knommu/page.h b/include/asm-m68knommu/page.h index ff6a926..942dfbe 100644 --- a/include/asm-m68knommu/page.h +++ b/include/asm-m68knommu/page.h @@ -48,20 +48,6 @@ typedef struct { unsigned long pgprot; } pgprot_t; /* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) -/* Pure 2^n version of get_order */ -extern __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - extern unsigned long memory_start; extern unsigned long memory_end; @@ -93,4 +79,6 @@ extern unsigned long memory_end; #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _M68KNOMMU_PAGE_H */ diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h index 5cae35c..652b6d6 100644 --- a/include/asm-mips/page.h +++ b/include/asm-mips/page.h @@ -103,20 +103,6 @@ typedef struct { unsigned long pgprot; } pgprot_t; #define __pgd(x) ((pgd_t) { (x) } ) #define __pgprot(x) ((pgprot_t) { (x) } ) -/* Pure 2^n version of get_order */ -static __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - #endif /* !__ASSEMBLY__ */ /* to align the pointer to the (next) page boundary */ @@ -148,4 +134,6 @@ static __inline__ int get_order(unsigned long size) #define WANT_PAGE_VIRTUAL #endif +#include <asm-generic/page.h> + #endif /* _ASM_PAGE_H */ diff --git a/include/asm-parisc/page.h b/include/asm-parisc/page.h index 4a12692..44eae9f 100644 --- a/include/asm-parisc/page.h +++ b/include/asm-parisc/page.h @@ -74,20 +74,6 @@ typedef struct { unsigned long pgprot; } pgprot_t; #define __pgd(x) ((pgd_t) { (x) } ) #define __pgprot(x) ((pgprot_t) { (x) } ) -/* Pure 2^n version of get_order */ -extern __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - typedef struct __physmem_range { unsigned long start_pfn; unsigned long pages; /* PAGE_SIZE pages */ @@ -159,4 +145,6 @@ extern int npmem_ranges; #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _PARISC_PAGE_H */ diff --git a/include/asm-ppc64/page.h b/include/asm-ppc64/page.h index a79a08d..a15422b 100644 --- a/include/asm-ppc64/page.h +++ b/include/asm-ppc64/page.h @@ -172,20 +172,6 @@ typedef unsigned long pgprot_t; #endif -/* Pure 2^n version of get_order */ -static inline int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) extern int page_is_ram(unsigned long pfn); @@ -270,4 +256,7 @@ extern u64 ppc64_pft_size; /* Log 2 of page table size */ VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64) #endif /* __KERNEL__ */ + +#include <asm-generic/page.h> + #endif /* _PPC64_PAGE_H */ diff --git a/include/asm-s390/page.h b/include/asm-s390/page.h index 2be287b..2430c56 100644 --- a/include/asm-s390/page.h +++ b/include/asm-s390/page.h @@ -111,20 +111,6 @@ static inline void copy_page(void *to, void *from) #define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr) #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE -/* Pure 2^n version of get_order */ -extern __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - /* * These are used to make use of C type-checking.. */ @@ -207,4 +193,6 @@ page_get_storage_key(unsigned long addr) #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _S390_PAGE_H */ diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h index 180467b..324e6cc 100644 --- a/include/asm-sh/page.h +++ b/include/asm-sh/page.h @@ -122,24 +122,8 @@ typedef struct { unsigned long pgprot; } pgprot_t; #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -#ifndef __ASSEMBLY__ - -/* Pure 2^n version of get_order */ -static __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - -#endif - #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* __ASM_SH_PAGE_H */ diff --git a/include/asm-sh64/page.h b/include/asm-sh64/page.h index d6167f1..c86df90 100644 --- a/include/asm-sh64/page.h +++ b/include/asm-sh64/page.h @@ -115,24 +115,8 @@ typedef struct { unsigned long pgprot; } pgprot_t; #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -#ifndef __ASSEMBLY__ - -/* Pure 2^n version of get_order */ -extern __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - -#endif - #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* __ASM_SH64_PAGE_H */ diff --git a/include/asm-sparc/page.h b/include/asm-sparc/page.h index 383060e..9122684 100644 --- a/include/asm-sparc/page.h +++ b/include/asm-sparc/page.h @@ -132,20 +132,6 @@ BTFIXUPDEF_SETHI(sparc_unmapped_base) #define TASK_UNMAPPED_BASE BTFIXUP_SETHI(sparc_unmapped_base) -/* Pure 2^n version of get_order */ -extern __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - #else /* !(__ASSEMBLY__) */ #define __pgprot(x) (x) @@ -178,4 +164,6 @@ extern unsigned long pfn_base; #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _SPARC_PAGE_H */ diff --git a/include/asm-sparc64/page.h b/include/asm-sparc64/page.h index b87dbbd..c9f8ef2 100644 --- a/include/asm-sparc64/page.h +++ b/include/asm-sparc64/page.h @@ -150,20 +150,6 @@ struct sparc_phys_banks { extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS]; -/* Pure 2^n version of get_order */ -static __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - #endif /* !(__ASSEMBLY__) */ #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ @@ -171,4 +157,6 @@ static __inline__ int get_order(unsigned long size) #endif /* !(__KERNEL__) */ +#include <asm-generic/page.h> + #endif /* !(_SPARC64_PAGE_H) */ diff --git a/include/asm-um/page.h b/include/asm-um/page.h index f58aeda..bd850a2 100644 --- a/include/asm-um/page.h +++ b/include/asm-um/page.h @@ -116,24 +116,12 @@ extern void *to_virt(unsigned long phys); #define pfn_valid(pfn) ((pfn) < max_mapnr) #define virt_addr_valid(v) pfn_valid(phys_to_pfn(__pa(v))) -/* Pure 2^n version of get_order */ -static __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - extern struct page *arch_validate(struct page *page, int mask, int order); #define HAVE_ARCH_VALIDATE extern void arch_free_page(struct page *page, int order); #define HAVE_ARCH_FREE_PAGE +#include <asm-generic/page.h> + #endif diff --git a/include/asm-v850/page.h b/include/asm-v850/page.h index d609162..b4bc85e 100644 --- a/include/asm-v850/page.h +++ b/include/asm-v850/page.h @@ -98,25 +98,6 @@ typedef unsigned long pgprot_t; #define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) -#ifndef __ASSEMBLY__ - -/* Pure 2^n version of get_order */ -extern __inline__ int get_order (unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - -#endif /* !__ASSEMBLY__ */ - - /* No current v850 processor has virtual memory. */ #define __virt_to_phys(addr) (addr) #define __phys_to_virt(addr) (addr) @@ -144,4 +125,6 @@ extern __inline__ int get_order (unsigned long size) #endif /* KERNEL */ +#include <asm-generic/page.h> + #endif /* __V850_PAGE_H__ */ diff --git a/include/asm-x86_64/page.h b/include/asm-x86_64/page.h index 4313187..fcf890a 100644 --- a/include/asm-x86_64/page.h +++ b/include/asm-x86_64/page.h @@ -92,20 +92,6 @@ typedef struct { unsigned long pgprot; } pgprot_t; #include <asm/bug.h> -/* Pure 2^n version of get_order */ -extern __inline__ int get_order(unsigned long size) -{ - int order; - - size = (size-1) >> (PAGE_SHIFT-1); - order = -1; - do { - size >>= 1; - order++; - } while (size); - return order; -} - #endif /* __ASSEMBLY__ */ #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) @@ -141,4 +127,6 @@ extern __inline__ int get_order(unsigned long size) #endif /* __KERNEL__ */ +#include <asm-generic/page.h> + #endif /* _X86_64_PAGE_H */ |