[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>
This commit is contained in:
parent
28ae55c98e
commit
fd4fd5aac1
22 changed files with 69 additions and 312 deletions
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
26
include/asm-generic/page.h
Normal file
26
include/asm-generic/page.h
Normal file
|
@ -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 */
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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) */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue