2006-08-30 22:16:11

by Dave Hansen

[permalink] [raw]
Subject: [RFC][PATCH 0/9] generic PAGE_SIZE infrastructure (v4)

Changes from v3:
- fixed spurious delete of PTE_MASK in sh arch
- replaced ALIGN() macro with one which only evaluates the
address a single time. (Thanks Nikita)
- replaced ppc _ALIGN* definitions with include of align.h

Changes from v2:
- included get_order() code to make it safe to include
generic/page.h everywhere (using ARCH_HAS_GET_ORDER)
- updated mm/Kconfig text to make it more fitting for ia64
- added patch to consolidate _ALIGN with kernel.h's ALIGN()
The assembly one has been left alone, but I guess we could
put it here. However, the meaning of the two is quite different.

---

All architectures currently explicitly define their page size. In some
cases (ppc, parisc, ia64, sparc64, mips) this size is somewhat
configurable.

There several reimplementations of ways to make sure that PAGE_SIZE
is usable in assembly code, yet still somewhat type safe for use in
C code (as a UL type). These are all very similar. There are also a
number of macros based off of PAGE_SIZE/SHIFT which are duplicated
across architectures.

This patch unifies all of those definitions. It defines PAGE_SIZE in
a single header which gets its definitions from Kconfig. The new
Kconfig options mirror what used to be done with #ifdefs and
arch-specific Kconfig options. The new Kconfig menu eliminates
the need for parisc, ia64, and sparc64 to have their own "choice"
menus for selecting page size. The help text has been adapted from
these three architectures, but is now more generic.

Why am I doing this? The OpenVZ beancounter patch hooks into the
alloc_thread_info() path, but only in two architectures. It is silly
to patch each and every architecture when they all just do the same
thing. This is the first step to have a single place in which to
do alloc_thread_info(). Oh, and this series removes about 300 lines
of code.

59 files changed, 217 insertions(+), 502 deletions(-)


2006-08-30 22:16:42

by Dave Hansen

[permalink] [raw]
Subject: [RFC][PATCH 3/9] actual generic PAGE_SIZE infrastructure


* Add _ALIGN_UP() which we'll use now and _ALIGN_DOWN(), just for
parity.
* Define ASM_CONST() macro to help using constants in both assembly
and C code. Several architectures have some form of this, and
they will be consolidated around this one.
* Actually create PAGE_SHIFT and PAGE_SIZE macros
* For now, require that architectures enable GENERIC_PAGE_SIZE in
order to get this new code. This option will be removed by the
last patch in the series, and makes the series bisect-safe.
* Note that this moves the compiler.h define outside of the
#ifdef __KERNEL__, but that's OK because it has its own.

Signed-off-by: Dave Hansen <[email protected]>
---

threadalloc-dave/include/asm-generic/page.h | 31 ++++++++++++++++++--
threadalloc-dave/mm/Kconfig | 43 ++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 3 deletions(-)

diff -puN include/asm-generic/page.h~generic-PAGE_SIZE-infrastructure include/asm-generic/page.h
--- threadalloc/include/asm-generic/page.h~generic-PAGE_SIZE-infrastructure 2006-08-30 15:15:00.000000000 -0700
+++ threadalloc-dave/include/asm-generic/page.h 2006-08-30 15:15:01.000000000 -0700
@@ -1,11 +1,36 @@
#ifndef _ASM_GENERIC_PAGE_H
#define _ASM_GENERIC_PAGE_H

+#include <linux/compiler.h>
+#include <linux/align.h>
+
#ifdef __KERNEL__
-#ifndef __ASSEMBLY__

-#include <linux/compiler.h>
+#ifdef __ASSEMBLY__
+#define ASM_CONST(x) x
+#else
+#define __ASM_CONST(x) x##UL
+#define ASM_CONST(x) __ASM_CONST(x)
+#endif
+
+#ifdef CONFIG_ARCH_GENERIC_PAGE_SIZE
+
+#define PAGE_SHIFT CONFIG_PAGE_SHIFT
+#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)
+
+/*
+ * Subtle: (1 << PAGE_SHIFT) is an int, not an unsigned long. So if we
+ * assign PAGE_MASK to a larger type it gets extended the way we want
+ * (i.e. with 1s in the high bits)
+ */
+#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))

+/* to align the pointer to the (next) page boundary */
+#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
+
+#endif /* CONFIG_ARCH_GENERIC_PAGE_SIZE */
+
+#ifndef __ASSEMBLY__
#ifndef CONFIG_ARCH_HAVE_GET_ORDER
/* Pure 2^n version of get_order */
static __inline__ __attribute_const__ int get_order(unsigned long size)
@@ -22,7 +47,7 @@ static __inline__ __attribute_const__ in
}

#endif /* CONFIG_ARCH_HAVE_GET_ORDER */
-#endif /* __ASSEMBLY__ */
+#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */

#endif /* _ASM_GENERIC_PAGE_H */
diff -puN mm/Kconfig~generic-PAGE_SIZE-infrastructure mm/Kconfig
--- threadalloc/mm/Kconfig~generic-PAGE_SIZE-infrastructure 2006-08-30 15:15:00.000000000 -0700
+++ threadalloc-dave/mm/Kconfig 2006-08-30 15:15:01.000000000 -0700
@@ -2,6 +2,49 @@ config ARCH_HAVE_GET_ORDER
def_bool y
depends on IA64 || PPC32 || XTENSA

+choice
+ prompt "Kernel Page Size"
+ depends on ARCH_GENERIC_PAGE_SIZE
+config PAGE_SIZE_4KB
+ bool "4KB"
+ help
+ This lets you select the page size of the kernel. For best
+ 32-bit compatibility on 64-bit architectures, a page size of 4KB
+ should be selected (although most binaries work perfectly fine with
+ a larger page size). For best performance, a page size of larger
+ than 4KB is recommended. However, there are a number of
+ side-effects of larger page sizes, like small files fitting poorly
+ into the page cache.
+
+ 4KB For best 32-bit compatibility
+ 8KB-64KB Better performace
+ above 64KB For kernel hackers only
+
+ If you don't know what to do, choose 4KB, or simply leave this
+ option alone. A sane default has already been selected for your
+ architecture.
+config PAGE_SIZE_8KB
+ bool "8KB"
+config PAGE_SIZE_16KB
+ bool "16KB"
+config PAGE_SIZE_64KB
+ bool "64KB"
+config PAGE_SIZE_512KB
+ bool "512KB"
+config PAGE_SIZE_4MB
+ bool "4MB"
+endchoice
+
+config PAGE_SHIFT
+ int
+ depends on ARCH_GENERIC_PAGE_SIZE
+ default "13" if PAGE_SIZE_8KB
+ default "14" if PAGE_SIZE_16KB
+ default "16" if PAGE_SIZE_64KB
+ default "19" if PAGE_SIZE_512KB
+ default "22" if PAGE_SIZE_4MB
+ default "12"
+
config SELECT_MEMORY_MODEL
def_bool y
depends on EXPERIMENTAL || ARCH_SELECT_MEMORY_MODEL
_

2006-08-30 22:16:09

by Dave Hansen

[permalink] [raw]
Subject: [RFC][PATCH 1/9] put alignment macros in align.h


There are several definitions of alignment macros. We'll take some
of the definitions from the powerpc code (since they are the most
prolific users), and make the generic version not evaluate its
argument twice. (Thanks Nikita)

We need a new header instead of kernel.h because it has many other
definitions, and we'll get circular dependencies.

Signed-off-by: Dave Hansen <[email protected]>
---

threadalloc-dave/include/linux/kernel.h | 2 -
threadalloc-dave/include/linux/align.h | 20 ++++++++++
threadalloc-dave/include/asm-ppc/page.h | 10 +----
threadalloc-dave/include/asm-ppc/bootinfo.h | 2 -
threadalloc-dave/include/asm-powerpc/page.h | 10 +----
threadalloc-dave/arch/powerpc/kernel/prom.c | 20 +++++-----
threadalloc-dave/arch/powerpc/kernel/prom_init.c | 9 ++--
threadalloc-dave/arch/powerpc/mm/44x_mmu.c | 2 -
threadalloc-dave/arch/powerpc/platforms/iseries/setup.c | 2 -
threadalloc-dave/arch/powerpc/platforms/powermac/bootx_init.c | 4 +-
threadalloc-dave/arch/ppc/kernel/setup.c | 4 +-
threadalloc-dave/arch/ppc/mm/44x_mmu.c | 2 -
12 files changed, 48 insertions(+), 39 deletions(-)

diff -puN include/linux/kernel.h~align-h include/linux/kernel.h
--- threadalloc/include/linux/kernel.h~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/include/linux/kernel.h 2006-08-30 15:14:59.000000000 -0700
@@ -13,6 +13,7 @@
#include <linux/types.h>
#include <linux/compiler.h>
#include <linux/bitops.h>
+#include <linux/align.h>
#include <asm/byteorder.h>
#include <asm/bug.h>

@@ -31,7 +32,6 @@ extern const char linux_banner[];
#define STACK_MAGIC 0xdeadbeef

#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))

diff -puN /dev/null include/linux/align.h
--- /dev/null 2005-03-30 22:36:15.000000000 -0800
+++ threadalloc-dave/include/linux/align.h 2006-08-30 15:14:59.000000000 -0700
@@ -0,0 +1,20 @@
+#ifndef _LINUX_ALIGN_H
+#define _LINUX_ALIGN_H
+
+/*
+ * This file should only contain macros which have no outside
+ * dependencies, and can be used safely from any other header.
+ */
+
+#define _ALIGN_UP(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
+#define _ALIGN_DOWN(x,a) ((x)&(~((a)-1)))
+
+/*
+ * ALIGN is special. There's a linkage.h as well that
+ * has a quite different meaning.
+ */
+#ifndef __ASSEMBLY__
+#define ALIGN(addr,size) _ALIGN_UP(addr,size)
+#endif
+
+#endif /* _LINUX_ALIGN_H */
diff -puN include/asm-ppc/page.h~align-h include/asm-ppc/page.h
--- threadalloc/include/asm-ppc/page.h~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/include/asm-ppc/page.h 2006-08-30 15:14:59.000000000 -0700
@@ -1,6 +1,7 @@
#ifndef _PPC_PAGE_H
#define _PPC_PAGE_H

+#include <linux/align.h>
#include <asm/asm-compat.h>

/* PAGE_SHIFT determines the page size */
@@ -36,15 +37,8 @@ typedef unsigned long pte_basic_t;
#define PTE_FMT "%.8lx"
#endif

-/* align addr on a size boundary - adjust address up/down if needed */
-#define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1)))
-#define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1)))
-
-/* align addr on a size boundary - adjust address up if needed */
-#define _ALIGN(addr,size) _ALIGN_UP(addr,size)
-
/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE)
+#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)


#undef STRICT_MM_TYPECHECKS
diff -puN include/asm-ppc/bootinfo.h~align-h include/asm-ppc/bootinfo.h
--- threadalloc/include/asm-ppc/bootinfo.h~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/include/asm-ppc/bootinfo.h 2006-08-30 15:14:59.000000000 -0700
@@ -41,7 +41,7 @@ static inline struct bi_record *
bootinfo_addr(unsigned long offset)
{

- return (struct bi_record *)_ALIGN((offset) + (1 << 20) - 1,
+ return (struct bi_record *)ALIGN((offset) + (1 << 20) - 1,
(1 << 20));
}
#endif /* CONFIG_APUS */
diff -puN include/asm-powerpc/page.h~align-h include/asm-powerpc/page.h
--- threadalloc/include/asm-powerpc/page.h~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/include/asm-powerpc/page.h 2006-08-30 15:14:59.000000000 -0700
@@ -11,6 +11,7 @@
*/

#ifdef __KERNEL__
+#include <linux/align.h>
#include <asm/asm-compat.h>
#include <asm/kdump.h>

@@ -89,15 +90,8 @@
#include <asm/page_32.h>
#endif

-/* align addr on a size boundary - adjust address up/down if needed */
-#define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1)))
-#define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1)))
-
-/* align addr on a size boundary - adjust address up if needed */
-#define _ALIGN(addr,size) _ALIGN_UP(addr,size)
-
/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE)
+#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)

/*
* Don't compare things with KERNELBASE or PAGE_OFFSET to test for
diff -puN arch/powerpc/kernel/prom.c~align-h arch/powerpc/kernel/prom.c
--- threadalloc/arch/powerpc/kernel/prom.c~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/arch/powerpc/kernel/prom.c 2006-08-30 15:14:59.000000000 -0700
@@ -125,9 +125,9 @@ int __init of_scan_flat_dt(int (*it)(uns
u32 sz = *((u32 *)p);
p += 8;
if (initial_boot_params->version < 0x10)
- p = _ALIGN(p, sz >= 8 ? 8 : 4);
+ p = ALIGN(p, sz >= 8 ? 8 : 4);
p += sz;
- p = _ALIGN(p, 4);
+ p = ALIGN(p, 4);
continue;
}
if (tag != OF_DT_BEGIN_NODE) {
@@ -137,7 +137,7 @@ int __init of_scan_flat_dt(int (*it)(uns
}
depth++;
pathp = (char *)p;
- p = _ALIGN(p + strlen(pathp) + 1, 4);
+ p = ALIGN(p + strlen(pathp) + 1, 4);
if ((*pathp) == '/') {
char *lp, *np;
for (lp = NULL, np = pathp; *np; np++)
@@ -163,7 +163,7 @@ unsigned long __init of_get_flat_dt_root
p += 4;
BUG_ON (*((u32 *)p) != OF_DT_BEGIN_NODE);
p += 4;
- return _ALIGN(p + strlen((char *)p) + 1, 4);
+ return ALIGN(p + strlen((char *)p) + 1, 4);
}

/**
@@ -190,7 +190,7 @@ void* __init of_get_flat_dt_prop(unsigne
noff = *((u32 *)(p + 4));
p += 8;
if (initial_boot_params->version < 0x10)
- p = _ALIGN(p, sz >= 8 ? 8 : 4);
+ p = ALIGN(p, sz >= 8 ? 8 : 4);

nstr = find_flat_dt_string(noff);
if (nstr == NULL) {
@@ -204,7 +204,7 @@ void* __init of_get_flat_dt_prop(unsigne
return (void *)p;
}
p += sz;
- p = _ALIGN(p, 4);
+ p = ALIGN(p, 4);
} while(1);
}

@@ -232,7 +232,7 @@ static void *__init unflatten_dt_alloc(u
{
void *res;

- *mem = _ALIGN(*mem, align);
+ *mem = ALIGN(*mem, align);
res = (void *)*mem;
*mem += size;

@@ -261,7 +261,7 @@ static unsigned long __init unflatten_dt
*p += 4;
pathp = (char *)*p;
l = allocl = strlen(pathp) + 1;
- *p = _ALIGN(*p + l, 4);
+ *p = ALIGN(*p + l, 4);

/* version 0x10 has a more compact unit name here instead of the full
* path. we accumulate the full path size using "fpsize", we'll rebuild
@@ -340,7 +340,7 @@ static unsigned long __init unflatten_dt
noff = *((u32 *)((*p) + 4));
*p += 8;
if (initial_boot_params->version < 0x10)
- *p = _ALIGN(*p, sz >= 8 ? 8 : 4);
+ *p = ALIGN(*p, sz >= 8 ? 8 : 4);

pname = find_flat_dt_string(noff);
if (pname == NULL) {
@@ -366,7 +366,7 @@ static unsigned long __init unflatten_dt
*prev_pp = pp;
prev_pp = &pp->next;
}
- *p = _ALIGN((*p) + sz, 4);
+ *p = ALIGN((*p) + sz, 4);
}
/* with version 0x10 we may not have the name property, recreate
* it here from the unit name if absent
diff -puN arch/powerpc/kernel/prom_init.c~align-h arch/powerpc/kernel/prom_init.c
--- threadalloc/arch/powerpc/kernel/prom_init.c~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/arch/powerpc/kernel/prom_init.c 2006-08-30 15:14:59.000000000 -0700
@@ -16,6 +16,7 @@
#undef DEBUG_PROM

#include <stdarg.h>
+#include <linux/align.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/init.h>
@@ -1679,7 +1680,7 @@ static void __init *make_room(unsigned l
{
void *ret;

- *mem_start = _ALIGN(*mem_start, align);
+ *mem_start = ALIGN(*mem_start, align);
while ((*mem_start + needed) > *mem_end) {
unsigned long room, chunk;

@@ -1811,7 +1812,7 @@ static void __init scan_dt_build_struct(
*lp++ = *p;
}
*lp = 0;
- *mem_start = _ALIGN((unsigned long)lp + 1, 4);
+ *mem_start = ALIGN((unsigned long)lp + 1, 4);
}

/* get it again for debugging */
@@ -1864,7 +1865,7 @@ static void __init scan_dt_build_struct(
/* push property content */
valp = make_room(mem_start, mem_end, l, 4);
call_prom("getprop", 4, 1, node, RELOC(pname), valp, l);
- *mem_start = _ALIGN(*mem_start, 4);
+ *mem_start = ALIGN(*mem_start, 4);
}

/* Add a "linux,phandle" property. */
@@ -1920,7 +1921,7 @@ static void __init flatten_device_tree(v
prom_panic ("couldn't get device tree root\n");

/* Build header and make room for mem rsv map */
- mem_start = _ALIGN(mem_start, 4);
+ mem_start = ALIGN(mem_start, 4);
hdr = make_room(&mem_start, &mem_end,
sizeof(struct boot_param_header), 4);
RELOC(dt_header_start) = (unsigned long)hdr;
diff -puN arch/powerpc/mm/44x_mmu.c~align-h arch/powerpc/mm/44x_mmu.c
--- threadalloc/arch/powerpc/mm/44x_mmu.c~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/arch/powerpc/mm/44x_mmu.c 2006-08-30 15:14:59.000000000 -0700
@@ -103,7 +103,7 @@ unsigned long __init mmu_mapin_ram(void)

/* Determine number of entries necessary to cover lowmem */
pinned_tlbs = (unsigned int)
- (_ALIGN(total_lowmem, PPC44x_PIN_SIZE) >> PPC44x_PIN_SHIFT);
+ (ALIGN(total_lowmem, PPC44x_PIN_SIZE) >> PPC44x_PIN_SHIFT);

/* Write upper watermark to save location */
tlb_44x_hwater = PPC44x_LOW_SLOT - pinned_tlbs;
diff -puN arch/powerpc/platforms/iseries/setup.c~align-h arch/powerpc/platforms/iseries/setup.c
--- threadalloc/arch/powerpc/platforms/iseries/setup.c~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/arch/powerpc/platforms/iseries/setup.c 2006-08-30 15:14:59.000000000 -0700
@@ -354,7 +354,7 @@ EXPORT_SYMBOL(mschunks_map);

void mschunks_alloc(unsigned long num_chunks)
{
- klimit = _ALIGN(klimit, sizeof(u32));
+ klimit = ALIGN(klimit, sizeof(u32));
mschunks_map.mapping = (u32 *)klimit;
klimit += num_chunks * sizeof(u32);
mschunks_map.num_chunks = num_chunks;
diff -puN arch/powerpc/platforms/powermac/bootx_init.c~align-h arch/powerpc/platforms/powermac/bootx_init.c
--- threadalloc/arch/powerpc/platforms/powermac/bootx_init.c~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/arch/powerpc/platforms/powermac/bootx_init.c 2006-08-30 15:14:59.000000000 -0700
@@ -389,7 +389,7 @@ static unsigned long __init bootx_flatte
hdr->dt_strings_size = bootx_dt_strend - bootx_dt_strbase;

/* Build structure */
- mem_end = _ALIGN(mem_end, 16);
+ mem_end = ALIGN(mem_end, 16);
DBG("Building device tree structure at: %x\n", mem_end);
hdr->off_dt_struct = mem_end - mem_start;
bootx_scan_dt_build_struct(base, 4, &mem_end);
@@ -407,7 +407,7 @@ static unsigned long __init bootx_flatte
* also bump mem_reserve_cnt to cause further reservations to
* fail since it's too late.
*/
- mem_end = _ALIGN(mem_end, PAGE_SIZE);
+ mem_end = ALIGN(mem_end, PAGE_SIZE);
DBG("End of boot params: %x\n", mem_end);
rsvmap[0] = mem_start;
rsvmap[1] = mem_end;
diff -puN arch/ppc/kernel/setup.c~align-h arch/ppc/kernel/setup.c
--- threadalloc/arch/ppc/kernel/setup.c~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/arch/ppc/kernel/setup.c 2006-08-30 15:14:59.000000000 -0700
@@ -341,14 +341,14 @@ struct bi_record *find_bootinfo(void)
{
struct bi_record *rec;

- rec = (struct bi_record *)_ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20));
+ rec = (struct bi_record *)ALIGN((ulong)__bss_start+(1<<20)-1,(1<<20));
if ( rec->tag != BI_FIRST ) {
/*
* This 0x10000 offset is a terrible hack but it will go away when
* we have the bootloader handle all the relocation and
* prom calls -- Cort
*/
- rec = (struct bi_record *)_ALIGN((ulong)__bss_start+0x10000+(1<<20)-1,(1<<20));
+ rec = (struct bi_record *)ALIGN((ulong)__bss_start+0x10000+(1<<20)-1,(1<<20));
if ( rec->tag != BI_FIRST )
return NULL;
}
diff -puN arch/ppc/mm/44x_mmu.c~align-h arch/ppc/mm/44x_mmu.c
--- threadalloc/arch/ppc/mm/44x_mmu.c~align-h 2006-08-30 15:14:57.000000000 -0700
+++ threadalloc-dave/arch/ppc/mm/44x_mmu.c 2006-08-30 15:14:59.000000000 -0700
@@ -103,7 +103,7 @@ unsigned long __init mmu_mapin_ram(void)

/* Determine number of entries necessary to cover lowmem */
pinned_tlbs = (unsigned int)
- (_ALIGN(total_lowmem, PPC_PIN_SIZE) >> PPC44x_PIN_SHIFT);
+ (ALIGN(total_lowmem, PPC_PIN_SIZE) >> PPC44x_PIN_SHIFT);

/* Write upper watermark to save location */
tlb_44x_hwater = PPC44x_LOW_SLOT - pinned_tlbs;
_

2006-08-30 22:16:37

by Dave Hansen

[permalink] [raw]
Subject: [RFC][PATCH 4/9] ia64 generic PAGE_SIZE


This is the ia64 portion to convert it over to the generic PAGE_SIZE
framework.

* Change all references to CONFIG_IA64_PAGE_SIZE_*KB to
CONFIG_PAGE_SIZE_* and update the defconfigs.
* remove ia64-specific Kconfig menu
* add ia64 default of 16k pages to mm/Kconfig
* add support for 8k and 16k pages, plus 64k if !ITANIUM

Signed-off-by: Dave Hansen <[email protected]>
---

threadalloc-dave/include/asm-ia64/ptrace.h | 6 +--
threadalloc-dave/include/asm-ia64/page.h | 21 ----------
threadalloc-dave/arch/ia64/Kconfig | 34 +----------------
threadalloc-dave/arch/ia64/configs/bigsur_defconfig | 8 ++--
threadalloc-dave/arch/ia64/configs/gensparse_defconfig | 8 ++--
threadalloc-dave/arch/ia64/configs/sim_defconfig | 8 ++--
threadalloc-dave/arch/ia64/configs/sn2_defconfig | 8 ++--
threadalloc-dave/arch/ia64/configs/tiger_defconfig | 8 ++--
threadalloc-dave/arch/ia64/configs/zx1_defconfig | 8 ++--
threadalloc-dave/arch/ia64/defconfig | 8 ++--
threadalloc-dave/mm/Kconfig | 4 ++
11 files changed, 38 insertions(+), 83 deletions(-)

diff -puN include/asm-ia64/ptrace.h~ia64 include/asm-ia64/ptrace.h
--- threadalloc/include/asm-ia64/ptrace.h~ia64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/include/asm-ia64/ptrace.h 2006-08-30 15:15:02.000000000 -0700
@@ -64,11 +64,11 @@
* Base-2 logarithm of number of pages to allocate per task structure
* (including register backing store and memory stack):
*/
-#if defined(CONFIG_IA64_PAGE_SIZE_4KB)
+#if defined(CONFIG_PAGE_SIZE_4KB)
# define KERNEL_STACK_SIZE_ORDER 3
-#elif defined(CONFIG_IA64_PAGE_SIZE_8KB)
+#elif defined(CONFIG_PAGE_SIZE_8KB)
# define KERNEL_STACK_SIZE_ORDER 2
-#elif defined(CONFIG_IA64_PAGE_SIZE_16KB)
+#elif defined(CONFIG_PAGE_SIZE_16KB)
# define KERNEL_STACK_SIZE_ORDER 1
#else
# define KERNEL_STACK_SIZE_ORDER 0
diff -puN include/asm-ia64/page.h~ia64 include/asm-ia64/page.h
--- threadalloc/include/asm-ia64/page.h~ia64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/include/asm-ia64/page.h 2006-08-30 15:15:02.000000000 -0700
@@ -7,7 +7,7 @@
* David Mosberger-Tang <[email protected]>
*/

-
+#include <asm-generic/page.h>
#include <asm/intrinsics.h>
#include <asm/types.h>

@@ -24,25 +24,6 @@
#define RGN_GATE 5 /* Gate page, Kernel text, etc */
#define RGN_HPAGE 4 /* For Huge TLB pages */

-/*
- * PAGE_SHIFT determines the actual kernel page size.
- */
-#if defined(CONFIG_IA64_PAGE_SIZE_4KB)
-# define PAGE_SHIFT 12
-#elif defined(CONFIG_IA64_PAGE_SIZE_8KB)
-# define PAGE_SHIFT 13
-#elif defined(CONFIG_IA64_PAGE_SIZE_16KB)
-# define PAGE_SHIFT 14
-#elif defined(CONFIG_IA64_PAGE_SIZE_64KB)
-# define PAGE_SHIFT 16
-#else
-# error Unsupported page size!
-#endif
-
-#define PAGE_SIZE (__IA64_UL_CONST(1) << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE - 1))
-#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
#define PERCPU_PAGE_SHIFT 16 /* log2() of max. size of per-CPU area */
#define PERCPU_PAGE_SIZE (__IA64_UL_CONST(1) << PERCPU_PAGE_SHIFT)

diff -puN arch/ia64/Kconfig~ia64 arch/ia64/Kconfig
--- threadalloc/arch/ia64/Kconfig~ia64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/ia64/Kconfig 2006-08-30 15:15:02.000000000 -0700
@@ -149,38 +149,8 @@ config MCKINLEY

endchoice

-choice
- prompt "Kernel page size"
- default IA64_PAGE_SIZE_16KB
-
-config IA64_PAGE_SIZE_4KB
- bool "4KB"
- help
- This lets you select the page size of the kernel. For best IA-64
- performance, a page size of 8KB or 16KB is recommended. For best
- IA-32 compatibility, a page size of 4KB should be selected (the vast
- majority of IA-32 binaries work perfectly fine with a larger page
- size). For Itanium 2 or newer systems, a page size of 64KB can also
- be selected.
-
- 4KB For best IA-32 compatibility
- 8KB For best IA-64 performance
- 16KB For best IA-64 performance
- 64KB Requires Itanium 2 or newer processor.
-
- If you don't know what to do, choose 16KB.
-
-config IA64_PAGE_SIZE_8KB
- bool "8KB"
-
-config IA64_PAGE_SIZE_16KB
- bool "16KB"
-
-config IA64_PAGE_SIZE_64KB
- depends on !ITANIUM
- bool "64KB"
-
-endchoice
+config ARCH_GENERIC_PAGE_SIZE
+ def_bool y

choice
prompt "Page Table Levels"
diff -puN arch/ia64/configs/bigsur_defconfig~ia64 arch/ia64/configs/bigsur_defconfig
--- threadalloc/arch/ia64/configs/bigsur_defconfig~ia64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/ia64/configs/bigsur_defconfig 2006-08-30 15:15:02.000000000 -0700
@@ -98,10 +98,10 @@ CONFIG_IA64_DIG=y
# CONFIG_IA64_HP_SIM is not set
CONFIG_ITANIUM=y
# CONFIG_MCKINLEY is not set
-# CONFIG_IA64_PAGE_SIZE_4KB is not set
-# CONFIG_IA64_PAGE_SIZE_8KB is not set
-CONFIG_IA64_PAGE_SIZE_16KB=y
-# CONFIG_IA64_PAGE_SIZE_64KB is not set
+# CONFIG_PAGE_SIZE_4KB is not set
+# CONFIG_PAGE_SIZE_8KB is not set
+CONFIG_PAGE_SIZE_16KB=y
+# CONFIG_PAGE_SIZE_64KB is not set
CONFIG_PGTABLE_3=y
# CONFIG_PGTABLE_4 is not set
# CONFIG_HZ_100 is not set
diff -puN arch/ia64/configs/gensparse_defconfig~ia64 arch/ia64/configs/gensparse_defconfig
--- threadalloc/arch/ia64/configs/gensparse_defconfig~ia64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/ia64/configs/gensparse_defconfig 2006-08-30 15:15:02.000000000 -0700
@@ -99,10 +99,10 @@ CONFIG_IA64_GENERIC=y
# CONFIG_IA64_HP_SIM is not set
# CONFIG_ITANIUM is not set
CONFIG_MCKINLEY=y
-# CONFIG_IA64_PAGE_SIZE_4KB is not set
-# CONFIG_IA64_PAGE_SIZE_8KB is not set
-CONFIG_IA64_PAGE_SIZE_16KB=y
-# CONFIG_IA64_PAGE_SIZE_64KB is not set
+# CONFIG_PAGE_SIZE_4KB is not set
+# CONFIG_PAGE_SIZE_8KB is not set
+CONFIG_PAGE_SIZE_16KB=y
+# CONFIG_PAGE_SIZE_64KB is not set
CONFIG_PGTABLE_3=y
# CONFIG_PGTABLE_4 is not set
# CONFIG_HZ_100 is not set
diff -puN arch/ia64/configs/sim_defconfig~ia64 arch/ia64/configs/sim_defconfig
--- threadalloc/arch/ia64/configs/sim_defconfig~ia64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/ia64/configs/sim_defconfig 2006-08-30 15:15:02.000000000 -0700
@@ -99,10 +99,10 @@ CONFIG_DMA_IS_DMA32=y
CONFIG_IA64_HP_SIM=y
# CONFIG_ITANIUM is not set
CONFIG_MCKINLEY=y
-# CONFIG_IA64_PAGE_SIZE_4KB is not set
-# CONFIG_IA64_PAGE_SIZE_8KB is not set
-# CONFIG_IA64_PAGE_SIZE_16KB is not set
-CONFIG_IA64_PAGE_SIZE_64KB=y
+# CONFIG_PAGE_SIZE_4KB is not set
+# CONFIG_PAGE_SIZE_8KB is not set
+# CONFIG_PAGE_SIZE_16KB is not set
+CONFIG_PAGE_SIZE_64KB=y
CONFIG_PGTABLE_3=y
# CONFIG_PGTABLE_4 is not set
# CONFIG_HZ_100 is not set
diff -puN arch/ia64/configs/sn2_defconfig~ia64 arch/ia64/configs/sn2_defconfig
--- threadalloc/arch/ia64/configs/sn2_defconfig~ia64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/ia64/configs/sn2_defconfig 2006-08-30 15:15:02.000000000 -0700
@@ -98,10 +98,10 @@ CONFIG_IA64_SGI_SN2=y
# CONFIG_IA64_HP_SIM is not set
# CONFIG_ITANIUM is not set
CONFIG_MCKINLEY=y
-# CONFIG_IA64_PAGE_SIZE_4KB is not set
-# CONFIG_IA64_PAGE_SIZE_8KB is not set
-CONFIG_IA64_PAGE_SIZE_16KB=y
-# CONFIG_IA64_PAGE_SIZE_64KB is not set
+# CONFIG_PAGE_SIZE_4KB is not set
+# CONFIG_PAGE_SIZE_8KB is not set
+CONFIG_PAGE_SIZE_16KB=y
+# CONFIG_PAGE_SIZE_64KB is not set
# CONFIG_PGTABLE_3 is not set
CONFIG_PGTABLE_4=y
# CONFIG_HZ_100 is not set
diff -puN arch/ia64/configs/tiger_defconfig~ia64 arch/ia64/configs/tiger_defconfig
--- threadalloc/arch/ia64/configs/tiger_defconfig~ia64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/ia64/configs/tiger_defconfig 2006-08-30 15:15:02.000000000 -0700
@@ -99,10 +99,10 @@ CONFIG_IA64_DIG=y
# CONFIG_IA64_HP_SIM is not set
# CONFIG_ITANIUM is not set
CONFIG_MCKINLEY=y
-# CONFIG_IA64_PAGE_SIZE_4KB is not set
-# CONFIG_IA64_PAGE_SIZE_8KB is not set
-CONFIG_IA64_PAGE_SIZE_16KB=y
-# CONFIG_IA64_PAGE_SIZE_64KB is not set
+# CONFIG_PAGE_SIZE_4KB is not set
+# CONFIG_PAGE_SIZE_8KB is not set
+CONFIG_PAGE_SIZE_16KB=y
+# CONFIG_PAGE_SIZE_64KB is not set
CONFIG_PGTABLE_3=y
# CONFIG_PGTABLE_4 is not set
# CONFIG_HZ_100 is not set
diff -puN arch/ia64/configs/zx1_defconfig~ia64 arch/ia64/configs/zx1_defconfig
--- threadalloc/arch/ia64/configs/zx1_defconfig~ia64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/ia64/configs/zx1_defconfig 2006-08-30 15:15:02.000000000 -0700
@@ -97,10 +97,10 @@ CONFIG_IA64_HP_ZX1=y
# CONFIG_IA64_HP_SIM is not set
# CONFIG_ITANIUM is not set
CONFIG_MCKINLEY=y
-# CONFIG_IA64_PAGE_SIZE_4KB is not set
-# CONFIG_IA64_PAGE_SIZE_8KB is not set
-CONFIG_IA64_PAGE_SIZE_16KB=y
-# CONFIG_IA64_PAGE_SIZE_64KB is not set
+# CONFIG_PAGE_SIZE_4KB is not set
+# CONFIG_PAGE_SIZE_8KB is not set
+CONFIG_PAGE_SIZE_16KB=y
+# CONFIG_PAGE_SIZE_64KB is not set
CONFIG_PGTABLE_3=y
# CONFIG_PGTABLE_4 is not set
# CONFIG_HZ_100 is not set
diff -puN arch/ia64/defconfig~ia64 arch/ia64/defconfig
--- threadalloc/arch/ia64/defconfig~ia64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/ia64/defconfig 2006-08-30 15:15:02.000000000 -0700
@@ -99,10 +99,10 @@ CONFIG_IA64_GENERIC=y
# CONFIG_IA64_HP_SIM is not set
# CONFIG_ITANIUM is not set
CONFIG_MCKINLEY=y
-# CONFIG_IA64_PAGE_SIZE_4KB is not set
-# CONFIG_IA64_PAGE_SIZE_8KB is not set
-CONFIG_IA64_PAGE_SIZE_16KB=y
-# CONFIG_IA64_PAGE_SIZE_64KB is not set
+# CONFIG_PAGE_SIZE_4KB is not set
+# CONFIG_PAGE_SIZE_8KB is not set
+CONFIG_PAGE_SIZE_16KB=y
+# CONFIG_PAGE_SIZE_64KB is not set
CONFIG_PGTABLE_3=y
# CONFIG_PGTABLE_4 is not set
# CONFIG_HZ_100 is not set
diff -puN mm/Kconfig~ia64 mm/Kconfig
--- threadalloc/mm/Kconfig~ia64 2006-08-30 15:15:01.000000000 -0700
+++ threadalloc-dave/mm/Kconfig 2006-08-30 15:15:02.000000000 -0700
@@ -5,6 +5,7 @@ config ARCH_HAVE_GET_ORDER
choice
prompt "Kernel Page Size"
depends on ARCH_GENERIC_PAGE_SIZE
+ default PAGE_SIZE_16KB if IA64
config PAGE_SIZE_4KB
bool "4KB"
help
@@ -25,10 +26,13 @@ config PAGE_SIZE_4KB
architecture.
config PAGE_SIZE_8KB
bool "8KB"
+ depends on IA64
config PAGE_SIZE_16KB
bool "16KB"
+ depends on IA64
config PAGE_SIZE_64KB
bool "64KB"
+ depends on (IA64 && !ITANIUM)
config PAGE_SIZE_512KB
bool "512KB"
config PAGE_SIZE_4MB
_

2006-08-30 22:17:07

by Dave Hansen

[permalink] [raw]
Subject: [RFC][PATCH 7/9] parisc generic PAGE_SIZE


This is the parisc portion to convert it over to the generic PAGE_SIZE
framework.

* remove parisc-specific Kconfig menu
* add parisc default of 4k pages to mm/Kconfig
* replace parisc Kconfig menu with plain bool Kconfig option to
cover both 16KB and 64KB pages: PARISC_LARGER_PAGE_SIZES.
This preserves the dependencies on PA8X00.

Signed-off-by: Dave Hansen <[email protected]>
---

threadalloc-dave/include/asm-parisc/pgtable.h | 8 +++---
threadalloc-dave/include/asm-parisc/page.h | 25 ---------------------
threadalloc-dave/arch/parisc/Kconfig | 30 +++-----------------------
threadalloc-dave/arch/parisc/defconfig | 6 ++---
threadalloc-dave/arch/parisc/mm/init.c | 2 -
threadalloc-dave/mm/Kconfig | 7 +++---
6 files changed, 17 insertions(+), 61 deletions(-)

diff -puN include/asm-parisc/pgtable.h~parisc include/asm-parisc/pgtable.h
--- threadalloc/include/asm-parisc/pgtable.h~parisc 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/include/asm-parisc/pgtable.h 2006-08-30 15:15:04.000000000 -0700
@@ -66,7 +66,7 @@
#endif
#define KERNEL_INITIAL_SIZE (1 << KERNEL_INITIAL_ORDER)

-#if defined(CONFIG_64BIT) && defined(CONFIG_PARISC_PAGE_SIZE_4KB)
+#if defined(CONFIG_64BIT) && defined(CONFIG_PAGE_SIZE_4KB)
#define PT_NLEVELS 3
#define PGD_ORDER 1 /* Number of pages per pgd */
#define PMD_ORDER 1 /* Number of pages per pmd */
@@ -514,11 +514,11 @@ static inline void ptep_set_wrprotect(st
#define _PAGE_SIZE_ENCODING_16M 6
#define _PAGE_SIZE_ENCODING_64M 7

-#if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
+#if defined(CONFIG_PAGE_SIZE_4KB)
# define _PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_4K
-#elif defined(CONFIG_PARISC_PAGE_SIZE_16KB)
+#elif defined(CONFIG_PAGE_SIZE_16KB)
# define _PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_16K
-#elif defined(CONFIG_PARISC_PAGE_SIZE_64KB)
+#elif defined(CONFIG_PAGE_SIZE_64KB)
# define _PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_64K
#endif

diff -puN include/asm-parisc/page.h~parisc include/asm-parisc/page.h
--- threadalloc/include/asm-parisc/page.h~parisc 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/include/asm-parisc/page.h 2006-08-30 15:15:04.000000000 -0700
@@ -1,29 +1,10 @@
#ifndef _PARISC_PAGE_H
#define _PARISC_PAGE_H

-#if !defined(__KERNEL__)
-/* this is for userspace applications (4k page size) */
-# define PAGE_SHIFT 12 /* 4k */
-# define PAGE_SIZE (1UL << PAGE_SHIFT)
-# define PAGE_MASK (~(PAGE_SIZE-1))
-#endif
-
+#include <asm-generic/page.h>

#ifdef __KERNEL__

-#if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
-# define PAGE_SHIFT 12 /* 4k */
-#elif defined(CONFIG_PARISC_PAGE_SIZE_16KB)
-# define PAGE_SHIFT 14 /* 16k */
-#elif defined(CONFIG_PARISC_PAGE_SIZE_64KB)
-# define PAGE_SHIFT 16 /* 64k */
-#else
-# error "unknown default kernel page size"
-#endif
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
-
#ifndef __ASSEMBLY__

#include <asm/types.h>
@@ -140,10 +121,6 @@ extern int npmem_ranges;
#define PMD_ENTRY_SIZE (1UL << BITS_PER_PMD_ENTRY)
#define PTE_ENTRY_SIZE (1UL << BITS_PER_PTE_ENTRY)

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
-
#define LINUX_GATEWAY_SPACE 0

/* This governs the relationship between virtual and physical addresses.
diff -puN arch/parisc/Kconfig~parisc arch/parisc/Kconfig
--- threadalloc/arch/parisc/Kconfig~parisc 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/parisc/Kconfig 2006-08-30 15:15:04.000000000 -0700
@@ -142,34 +142,12 @@ config 64BIT
enable this option otherwise. The 64bit kernel is significantly bigger
and slower than the 32bit one.

-choice
- prompt "Kernel page size"
- default PARISC_PAGE_SIZE_4KB if !64BIT
- default PARISC_PAGE_SIZE_4KB if 64BIT
-# default PARISC_PAGE_SIZE_16KB if 64BIT
-
-config PARISC_PAGE_SIZE_4KB
- bool "4KB"
- help
- This lets you select the page size of the kernel. For best
- performance, a page size of 16KB is recommended. For best
- compatibility with 32bit applications, a page size of 4KB should be
- selected (the vast majority of 32bit binaries work perfectly fine
- with a larger page size).
-
- 4KB For best 32bit compatibility
- 16KB For best performance
- 64KB For best performance, might give more overhead.
-
- If you don't know what to do, choose 4KB.
-
-config PARISC_PAGE_SIZE_16KB
- bool "16KB (EXPERIMENTAL)"
+config PARISC_LARGER_PAGE_SIZES
+ def_bool y
depends on PA8X00 && EXPERIMENTAL

-config PARISC_PAGE_SIZE_64KB
- bool "64KB (EXPERIMENTAL)"
- depends on PA8X00 && EXPERIMENTAL
+config ARCH_GENERIC_PAGE_SIZE
+ def_bool y

endchoice

diff -puN arch/parisc/defconfig~parisc arch/parisc/defconfig
--- threadalloc/arch/parisc/defconfig~parisc 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/parisc/defconfig 2006-08-30 15:15:04.000000000 -0700
@@ -91,9 +91,9 @@ CONFIG_PA7100LC=y
# CONFIG_PA7300LC is not set
# CONFIG_PA8X00 is not set
CONFIG_PA11=y
-CONFIG_PARISC_PAGE_SIZE_4KB=y
-# CONFIG_PARISC_PAGE_SIZE_16KB is not set
-# CONFIG_PARISC_PAGE_SIZE_64KB is not set
+CONFIG_PAGE_SIZE_4KB=y
+# CONFIG_PAGE_SIZE_16KB is not set
+# CONFIG_PAGE_SIZE_64KB is not set
# CONFIG_SMP is not set
CONFIG_ARCH_FLATMEM_ENABLE=y
# CONFIG_PREEMPT_NONE is not set
diff -puN arch/parisc/mm/init.c~parisc arch/parisc/mm/init.c
--- threadalloc/arch/parisc/mm/init.c~parisc 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/parisc/mm/init.c 2006-08-30 15:15:04.000000000 -0700
@@ -642,7 +642,7 @@ static void __init map_pages(unsigned lo
* Map the fault vector writable so we can
* write the HPMC checksum.
*/
-#if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
+#if defined(CONFIG_PAGE_SIZE_4KB)
if (address >= ro_start && address < ro_end
&& address != fv_addr
&& address != gw_addr)
diff -puN mm/Kconfig~parisc mm/Kconfig
--- threadalloc/mm/Kconfig~parisc 2006-08-30 15:15:03.000000000 -0700
+++ threadalloc-dave/mm/Kconfig 2006-08-30 15:15:04.000000000 -0700
@@ -5,7 +5,7 @@ config ARCH_HAVE_GET_ORDER
choice
prompt "Kernel Page Size"
depends on ARCH_GENERIC_PAGE_SIZE
- default PAGE_SIZE_4KB if MIPS
+ default PAGE_SIZE_4KB if MIPS || PARISC
default PAGE_SIZE_8KB if SPARC64
default PAGE_SIZE_16KB if IA64
config PAGE_SIZE_4KB
@@ -32,10 +32,11 @@ config PAGE_SIZE_8KB
depends on IA64 || SPARC64 || MIPS_PAGE_SIZE_8KB
config PAGE_SIZE_16KB
bool "16KB"
- depends on IA64 || MIPS_PAGE_SIZE_16KB
+ depends on IA64 || MIPS_PAGE_SIZE_16KB || PARISC_LARGER_PAGE_SIZES
config PAGE_SIZE_64KB
bool "64KB"
- depends on (IA64 && !ITANIUM) || SPARC64 || MIPS_PAGE_SIZE_64KB
+ depends on (IA64 && !ITANIUM) || SPARC64 || MIPS_PAGE_SIZE_64KB || \
+ PARISC_LARGER_PAGE_SIZES
config PAGE_SIZE_512KB
bool "512KB"
depends on SPARC64
_

2006-08-30 22:17:11

by Dave Hansen

[permalink] [raw]
Subject: [RFC][PATCH 2/9] conditionally define generic get_order() (ARCH_HAS_GET_ORDER)


This patch makes asm-generic/page.h safe to include in lots of code. This
prepares it for the introduction shortly of the generic PAGE_SIZE code.

There was some discussion that ARCH_HAS_FOO is a disgusting mechanism and
should be wiped off the face of the earth. It was argued that these things
introduce unnecessary complexity, reduce greppability, and obscure the
conditions under which FOO was defined. I agree with *ALL* of this. I
think this patch is different. ;)

This is very greppable. If you grep and see foo() showing up in
asm-generic/foo.h, it is *obvious* that it is a generic version. If you
see another version in asm-i386/foo.h, it is also obvious that i386 has
(or can) override the generic one.

As for obscuring the conditions under which it is defined, you do this when
you are either missing a symbol, or have duplicate symbols. So, you want to
know:

1. *IS* the generic one being defined?
2. When is this generic defined (and how do I turn it off)?
3. How to I get the damn thing defined (if the symbol is missing)?

With Kconfig, this is all easy, especially for arch-specific stuff.

If you requiring that the non-generic symbol be defined first:

http://article.gmane.org/gmane.linux.kernel/422942/match=very+complex+xyzzy+don+t+want

it gets awfully messy because you end up having to fix up all of the
architectures' headers that define the thing to get rid of any circular
dependencies.

So, is _this_ patch disgusting?

Signed-off-by: Dave Hansen <[email protected]>
---

threadalloc-dave/include/asm-generic/page.h | 4 +++-
threadalloc-dave/mm/Kconfig | 4 ++++
2 files changed, 7 insertions(+), 1 deletion(-)

diff -puN include/asm-generic/page.h~generic-get_order include/asm-generic/page.h
--- threadalloc/include/asm-generic/page.h~generic-get_order 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/include/asm-generic/page.h 2006-08-30 15:15:00.000000000 -0700
@@ -6,6 +6,7 @@

#include <linux/compiler.h>

+#ifndef CONFIG_ARCH_HAVE_GET_ORDER
/* Pure 2^n version of get_order */
static __inline__ __attribute_const__ int get_order(unsigned long size)
{
@@ -20,7 +21,8 @@ static __inline__ __attribute_const__ in
return order;
}

-#endif /* __ASSEMBLY__ */
+#endif /* CONFIG_ARCH_HAVE_GET_ORDER */
+#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */

#endif /* _ASM_GENERIC_PAGE_H */
diff -puN mm/Kconfig~generic-get_order mm/Kconfig
--- threadalloc/mm/Kconfig~generic-get_order 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/mm/Kconfig 2006-08-30 15:15:00.000000000 -0700
@@ -1,3 +1,7 @@
+config ARCH_HAVE_GET_ORDER
+ def_bool y
+ depends on IA64 || PPC32 || XTENSA
+
config SELECT_MEMORY_MODEL
def_bool y
depends on EXPERIMENTAL || ARCH_SELECT_MEMORY_MODEL
_

2006-08-30 22:17:53

by Dave Hansen

[permalink] [raw]
Subject: [RFC][PATCH 8/9] powerpc generic PAGE_SIZE


This is the powerpc portion to convert it over to the generic PAGE_SIZE
framework.

* add powerpc default of 64k pages to mm/Kconfig, when the 64k
option is enabled. Defaults to 4k otherwise.

Signed-off-by: Dave Hansen <[email protected]>
---

threadalloc-dave/include/asm-ppc/page.h | 15 +--------------
threadalloc-dave/include/asm-powerpc/page.h | 24 +-----------------------
threadalloc-dave/arch/powerpc/Kconfig | 5 ++++-
threadalloc-dave/arch/powerpc/boot/page.h | 3 ---
threadalloc-dave/mm/Kconfig | 2 +-
5 files changed, 7 insertions(+), 42 deletions(-)

diff -puN include/asm-ppc/page.h~powerpc include/asm-ppc/page.h
--- threadalloc/include/asm-ppc/page.h~powerpc 2006-08-30 15:14:59.000000000 -0700
+++ threadalloc-dave/include/asm-ppc/page.h 2006-08-30 15:15:05.000000000 -0700
@@ -3,16 +3,7 @@

#include <linux/align.h>
#include <asm/asm-compat.h>
-
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT 12
-#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)
-
-/*
- * Subtle: this is an int (not an unsigned long) and so it
- * gets extended to 64 bits the way want (i.e. with 1s). -- paulus
- */
-#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
+#include <asm-generic/page.h>

#ifdef __KERNEL__

@@ -37,10 +28,6 @@ typedef unsigned long pte_basic_t;
#define PTE_FMT "%.8lx"
#endif

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
-
-
#undef STRICT_MM_TYPECHECKS

#ifdef STRICT_MM_TYPECHECKS
diff -puN include/asm-powerpc/page.h~powerpc include/asm-powerpc/page.h
--- threadalloc/include/asm-powerpc/page.h~powerpc 2006-08-30 15:14:59.000000000 -0700
+++ threadalloc-dave/include/asm-powerpc/page.h 2006-08-30 15:15:05.000000000 -0700
@@ -12,33 +12,14 @@

#ifdef __KERNEL__
#include <linux/align.h>
+#include <asm-generic/page.h>
#include <asm/asm-compat.h>
#include <asm/kdump.h>

-/*
- * On PPC32 page size is 4K. For PPC64 we support either 4K or 64K software
- * page size. When using 64K pages however, whether we are really supporting
- * 64K pages in HW or not is irrelevant to those definitions.
- */
-#ifdef CONFIG_PPC_64K_PAGES
-#define PAGE_SHIFT 16
-#else
-#define PAGE_SHIFT 12
-#endif
-
-#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)
-
/* We do define AT_SYSINFO_EHDR but don't use the gate mechanism */
#define __HAVE_ARCH_GATE_AREA 1

/*
- * Subtle: (1 << PAGE_SHIFT) is an int, not an unsigned long. So if we
- * assign PAGE_MASK to a larger type it gets extended the way we want
- * (i.e. with 1s in the high bits)
- */
-#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
-
-/*
* KERNELBASE is the virtual address of the start of the kernel, it's often
* the same as PAGE_OFFSET, but _might not be_.
*
@@ -90,9 +71,6 @@
#include <asm/page_32.h>
#endif

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
-
/*
* Don't compare things with KERNELBASE or PAGE_OFFSET to test for
* "kernelness", use is_kernel_addr() - it should do what you want.
diff -puN arch/powerpc/Kconfig~powerpc arch/powerpc/Kconfig
--- threadalloc/arch/powerpc/Kconfig~powerpc 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/arch/powerpc/Kconfig 2006-08-30 15:15:05.000000000 -0700
@@ -725,8 +725,11 @@ config ARCH_MEMORY_PROBE
def_bool y
depends on MEMORY_HOTPLUG

+config ARCH_GENERIC_PAGE_SIZE
+ def_bool y
+
config PPC_64K_PAGES
- bool "64k page size"
+ bool "enable 64k page size"
depends on PPC64
help
This option changes the kernel logical page size to 64k. On machines
diff -puN arch/powerpc/boot/page.h~powerpc arch/powerpc/boot/page.h
--- threadalloc/arch/powerpc/boot/page.h~powerpc 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/arch/powerpc/boot/page.h 2006-08-30 15:15:05.000000000 -0700
@@ -28,7 +28,4 @@
/* align addr on a size boundary - adjust address up if needed */
#define _ALIGN(addr,size) _ALIGN_UP(addr,size)

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE)
-
#endif /* _PPC_BOOT_PAGE_H */
diff -puN mm/Kconfig~powerpc mm/Kconfig
--- threadalloc/mm/Kconfig~powerpc 2006-08-30 15:15:04.000000000 -0700
+++ threadalloc-dave/mm/Kconfig 2006-08-30 15:15:05.000000000 -0700
@@ -50,7 +50,7 @@ config PAGE_SHIFT
depends on ARCH_GENERIC_PAGE_SIZE
default "13" if PAGE_SIZE_8KB
default "14" if PAGE_SIZE_16KB
- default "16" if PAGE_SIZE_64KB
+ default "16" if PAGE_SIZE_64KB || PPC_64K_PAGES
default "19" if PAGE_SIZE_512KB
default "22" if PAGE_SIZE_4MB
default "12"
_

2006-08-30 22:18:33

by Dave Hansen

[permalink] [raw]
Subject: [RFC][PATCH 5/9] sparc64 generic PAGE_SIZE


This is the sparc64 portion to convert it over to the generic PAGE_SIZE
framework.

* Change all references to CONFIG_SPARC64_PAGE_SIZE_*KB to
CONFIG_PAGE_SIZE_* and update the defconfig.
* remove sparc64-specific Kconfig menu
* add sparc64 default of 8k pages to mm/Kconfig
* remove generic support for 4k pages
* add support for 8k, 64k, 512k, and 4MB pages

Signed-off-by: Dave Hansen <[email protected]>
---

threadalloc-dave/include/asm-sparc64/pgtable.h | 1
threadalloc-dave/include/asm-sparc64/page.h | 19 --------------
threadalloc-dave/include/asm-sparc64/mmu.h | 8 +++---
threadalloc-dave/arch/sparc64/Kconfig | 32 +++----------------------
threadalloc-dave/arch/sparc64/defconfig | 8 +++---
threadalloc-dave/arch/sparc64/mm/tsb.c | 8 +++---
threadalloc-dave/mm/Kconfig | 8 ++++--
7 files changed, 24 insertions(+), 60 deletions(-)

diff -puN include/asm-sparc64/pgtable.h~sparc64 include/asm-sparc64/pgtable.h
--- threadalloc/include/asm-sparc64/pgtable.h~sparc64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/include/asm-sparc64/pgtable.h 2006-08-30 15:15:03.000000000 -0700
@@ -13,6 +13,7 @@
*/

#include <asm-generic/pgtable-nopud.h>
+#include <asm-generic/page.h>

#include <linux/compiler.h>
#include <asm/types.h>
diff -puN include/asm-sparc64/page.h~sparc64 include/asm-sparc64/page.h
--- threadalloc/include/asm-sparc64/page.h~sparc64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/include/asm-sparc64/page.h 2006-08-30 15:15:03.000000000 -0700
@@ -4,21 +4,7 @@
#define _SPARC64_PAGE_H

#include <asm/const.h>
-
-#if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
-#define PAGE_SHIFT 13
-#elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
-#define PAGE_SHIFT 16
-#elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB)
-#define PAGE_SHIFT 19
-#elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB)
-#define PAGE_SHIFT 22
-#else
-#error No page size specified in kernel configuration
-#endif
-
-#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
+#include <asm-generic/page.h>

/* Flushing for D-cache alias handling is only needed if
* the page size is smaller than 16K.
@@ -114,9 +100,6 @@ typedef unsigned long pgprot_t;

#endif /* !(__ASSEMBLY__) */

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
/* We used to stick this into a hard-coded global register (%g4)
* but that does not make sense anymore.
*/
diff -puN include/asm-sparc64/mmu.h~sparc64 include/asm-sparc64/mmu.h
--- threadalloc/include/asm-sparc64/mmu.h~sparc64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/include/asm-sparc64/mmu.h 2006-08-30 15:15:03.000000000 -0700
@@ -30,13 +30,13 @@
#define CTX_PGSZ_MASK ((CTX_PGSZ_BITS << CTX_PGSZ0_SHIFT) | \
(CTX_PGSZ_BITS << CTX_PGSZ1_SHIFT))

-#if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
+#if defined(CONFIG_PAGE_SIZE_8KB)
#define CTX_PGSZ_BASE CTX_PGSZ_8KB
-#elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
+#elif defined(CONFIG_PAGE_SIZE_64KB)
#define CTX_PGSZ_BASE CTX_PGSZ_64KB
-#elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB)
+#elif defined(CONFIG_PAGE_SIZE_512KB)
#define CTX_PGSZ_BASE CTX_PGSZ_512KB
-#elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB)
+#elif defined(CONFIG_PAGE_SIZE_4MB)
#define CTX_PGSZ_BASE CTX_PGSZ_4MB
#else
#error No page size specified in kernel configuration
diff -puN arch/sparc64/Kconfig~sparc64 arch/sparc64/Kconfig
--- threadalloc/arch/sparc64/Kconfig~sparc64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/sparc64/Kconfig 2006-08-30 15:15:03.000000000 -0700
@@ -34,32 +34,8 @@ config ARCH_MAY_HAVE_PC_FDC
bool
default y

-choice
- prompt "Kernel page size"
- default SPARC64_PAGE_SIZE_8KB
-
-config SPARC64_PAGE_SIZE_8KB
- bool "8KB"
- help
- This lets you select the page size of the kernel.
-
- 8KB and 64KB work quite well, since Sparc ELF sections
- provide for up to 64KB alignment.
-
- Therefore, 512KB and 4MB are for expert hackers only.
-
- If you don't know what to do, choose 8KB.
-
-config SPARC64_PAGE_SIZE_64KB
- bool "64KB"
-
-config SPARC64_PAGE_SIZE_512KB
- bool "512KB"
-
-config SPARC64_PAGE_SIZE_4MB
- bool "4MB"
-
-endchoice
+config ARCH_GENERIC_PAGE_SIZE
+ def_bool y

config SECCOMP
bool "Enable seccomp to safely compute untrusted bytecode"
@@ -187,11 +163,11 @@ config HUGETLB_PAGE_SIZE_4MB
bool "4MB"

config HUGETLB_PAGE_SIZE_512K
- depends on !SPARC64_PAGE_SIZE_4MB && !SPARC64_PAGE_SIZE_512KB
+ depends on !PAGE_SIZE_4MB && !PAGE_SIZE_512KB
bool "512K"

config HUGETLB_PAGE_SIZE_64K
- depends on !SPARC64_PAGE_SIZE_4MB && !SPARC64_PAGE_SIZE_512KB && !SPARC64_PAGE_SIZE_64KB
+ depends on !PAGE_SIZE_4MB && !PAGE_SIZE_512KB && !PAGE_SIZE_64KB
bool "64K"

endchoice
diff -puN arch/sparc64/defconfig~sparc64 arch/sparc64/defconfig
--- threadalloc/arch/sparc64/defconfig~sparc64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/sparc64/defconfig 2006-08-30 15:15:03.000000000 -0700
@@ -9,10 +9,10 @@ CONFIG_64BIT=y
CONFIG_MMU=y
CONFIG_TIME_INTERPOLATION=y
CONFIG_ARCH_MAY_HAVE_PC_FDC=y
-CONFIG_SPARC64_PAGE_SIZE_8KB=y
-# CONFIG_SPARC64_PAGE_SIZE_64KB is not set
-# CONFIG_SPARC64_PAGE_SIZE_512KB is not set
-# CONFIG_SPARC64_PAGE_SIZE_4MB is not set
+CONFIG_PAGE_SIZE_8KB=y
+# CONFIG_PAGE_SIZE_64KB is not set
+# CONFIG_PAGE_SIZE_512KB is not set
+# CONFIG_PAGE_SIZE_4MB is not set
CONFIG_SECCOMP=y
# CONFIG_HZ_100 is not set
CONFIG_HZ_250=y
diff -puN arch/sparc64/mm/tsb.c~sparc64 arch/sparc64/mm/tsb.c
--- threadalloc/arch/sparc64/mm/tsb.c~sparc64 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/sparc64/mm/tsb.c 2006-08-30 15:15:03.000000000 -0700
@@ -90,16 +90,16 @@ void flush_tsb_user(struct mmu_gather *m
spin_unlock_irqrestore(&mm->context.lock, flags);
}

-#if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
+#if defined(CONFIG_PAGE_SIZE_8KB)
#define HV_PGSZ_IDX_BASE HV_PGSZ_IDX_8K
#define HV_PGSZ_MASK_BASE HV_PGSZ_MASK_8K
-#elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
+#elif defined(CONFIG_PAGE_SIZE_64KB)
#define HV_PGSZ_IDX_BASE HV_PGSZ_IDX_64K
#define HV_PGSZ_MASK_BASE HV_PGSZ_MASK_64K
-#elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB)
+#elif defined(CONFIG_PAGE_SIZE_512KB)
#define HV_PGSZ_IDX_BASE HV_PGSZ_IDX_512K
#define HV_PGSZ_MASK_BASE HV_PGSZ_MASK_512K
-#elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB)
+#elif defined(CONFIG_PAGE_SIZE_4MB)
#define HV_PGSZ_IDX_BASE HV_PGSZ_IDX_4MB
#define HV_PGSZ_MASK_BASE HV_PGSZ_MASK_4MB
#else
diff -puN mm/Kconfig~sparc64 mm/Kconfig
--- threadalloc/mm/Kconfig~sparc64 2006-08-30 15:15:02.000000000 -0700
+++ threadalloc-dave/mm/Kconfig 2006-08-30 15:15:03.000000000 -0700
@@ -5,9 +5,11 @@ config ARCH_HAVE_GET_ORDER
choice
prompt "Kernel Page Size"
depends on ARCH_GENERIC_PAGE_SIZE
+ default PAGE_SIZE_8KB if SPARC64
default PAGE_SIZE_16KB if IA64
config PAGE_SIZE_4KB
bool "4KB"
+ depends on !SPARC64
help
This lets you select the page size of the kernel. For best
32-bit compatibility on 64-bit architectures, a page size of 4KB
@@ -26,17 +28,19 @@ config PAGE_SIZE_4KB
architecture.
config PAGE_SIZE_8KB
bool "8KB"
- depends on IA64
+ depends on IA64 || SPARC64
config PAGE_SIZE_16KB
bool "16KB"
depends on IA64
config PAGE_SIZE_64KB
bool "64KB"
- depends on (IA64 && !ITANIUM)
+ depends on (IA64 && !ITANIUM) || SPARC64
config PAGE_SIZE_512KB
bool "512KB"
+ depends on SPARC64
config PAGE_SIZE_4MB
bool "4MB"
+ depends on SPARC64
endchoice

config PAGE_SHIFT
_

2006-08-30 22:17:46

by Dave Hansen

[permalink] [raw]
Subject: [RFC][PATCH 9/9] convert the "easy" architectures to generic PAGE_SIZE

---

threadalloc-dave/include/asm-xtensa/page.h | 11 +----------
threadalloc-dave/include/asm-x86_64/page.h | 12 +-----------
threadalloc-dave/include/asm-v850/page.h | 12 +-----------
threadalloc-dave/include/asm-um/page.h | 9 +--------
threadalloc-dave/include/asm-sparc/page.h | 16 +---------------
threadalloc-dave/include/asm-sh64/page.h | 12 +-----------
threadalloc-dave/include/asm-sh/page.h | 8 +-------
threadalloc-dave/include/asm-s390/page.h | 8 +-------
threadalloc-dave/include/asm-m68knommu/page.h | 10 +---------
threadalloc-dave/include/asm-m68k/page.h | 20 +-------------------
threadalloc-dave/include/asm-m32r/page.h | 3 ---
threadalloc-dave/include/asm-i386/page.h | 8 +-------
threadalloc-dave/include/asm-h8300/page.h | 11 +----------
threadalloc-dave/include/asm-generic/page.h | 6 ++----
threadalloc-dave/include/asm-frv/page.h | 4 +---
threadalloc-dave/include/asm-frv/mem-layout.h | 15 ++-------------
threadalloc-dave/include/asm-cris/page.h | 13 +------------
threadalloc-dave/include/asm-arm26/page.h | 7 +------
threadalloc-dave/include/asm-arm/page.h | 9 +--------
threadalloc-dave/include/asm-arm/page-nommu.h | 3 ---
threadalloc-dave/include/asm-alpha/page.h | 9 +--------
threadalloc-dave/arch/ia64/Kconfig | 3 ---
threadalloc-dave/arch/mips/Kconfig | 3 ---
threadalloc-dave/arch/parisc/Kconfig | 3 ---
threadalloc-dave/arch/powerpc/Kconfig | 3 ---
threadalloc-dave/arch/sparc64/Kconfig | 3 ---
threadalloc-dave/mm/Kconfig | 11 ++++++-----
27 files changed, 27 insertions(+), 205 deletions(-)

diff -puN include/asm-xtensa/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-xtensa/page.h
--- threadalloc/include/asm-xtensa/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-xtensa/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -14,16 +14,7 @@
#ifdef __KERNEL__

#include <asm/processor.h>
-
-/*
- * PAGE_SHIFT determines the page size
- * PAGE_ALIGN(x) aligns the pointer to the (next) page boundary
- */
-
-#define PAGE_SHIFT XCHAL_MMU_MIN_PTE_PAGE_SIZE
-#define PAGE_SIZE (1 << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE - 1) & PAGE_MASK)
+#include <asm-generic/page.h>

#define DCACHE_WAY_SIZE (XCHAL_DCACHE_SIZE / XCHAL_DCACHE_WAYS)
#define PAGE_OFFSET XCHAL_KSEG_CACHED_VADDR
diff -puN include/asm-x86_64/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-x86_64/page.h
--- threadalloc/include/asm-x86_64/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-x86_64/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -1,15 +1,8 @@
#ifndef _X86_64_PAGE_H
#define _X86_64_PAGE_H

+#include <asm-generic/page.h>

-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT 12
-#ifdef __ASSEMBLY__
-#define PAGE_SIZE (0x1 << PAGE_SHIFT)
-#else
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#endif
-#define PAGE_MASK (~(PAGE_SIZE-1))
#define PHYSICAL_PAGE_MASK (~(PAGE_SIZE-1) & __PHYSICAL_MASK)

#define THREAD_ORDER 1
@@ -88,9 +81,6 @@ typedef struct { unsigned long pgprot; }
#define __PAGE_OFFSET 0xffff810000000000
#endif /* !__ASSEMBLY__ */

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
/* See Documentation/x86_64/mm.txt for a description of the memory map. */
#define __PHYSICAL_MASK_SHIFT 46
#define __PHYSICAL_MASK ((1UL << __PHYSICAL_MASK_SHIFT) - 1)
diff -puN include/asm-v850/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-v850/page.h
--- threadalloc/include/asm-v850/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-v850/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -15,12 +15,7 @@
#define __V850_PAGE_H__

#include <asm/machdep.h>
-
-
-#define PAGE_SHIFT 12
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
+#include <asm-generic/page.h>

/*
* PAGE_OFFSET -- the first address of the first page of memory. For archs with
@@ -93,11 +88,6 @@ typedef unsigned long pgprot_t;

#endif /* !__ASSEMBLY__ */

-
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
-
/* No current v850 processor has virtual memory. */
#define __virt_to_phys(addr) (addr)
#define __phys_to_virt(addr) (addr)
diff -puN include/asm-um/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-um/page.h
--- threadalloc/include/asm-um/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-um/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -10,11 +10,7 @@
struct page;

#include <asm/vm-flags.h>
-
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT 12
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
+#include <asm-generic/page.h>

/*
* These are used to make use of C type-checking..
@@ -85,9 +81,6 @@ typedef struct { unsigned long pgprot; }
#define __pgd(x) ((pgd_t) { (x) } )
#define __pgprot(x) ((pgprot_t) { (x) } )

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
extern unsigned long uml_physmem;

#define PAGE_OFFSET (uml_physmem)
diff -puN include/asm-sparc/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-sparc/page.h
--- threadalloc/include/asm-sparc/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-sparc/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -8,18 +8,7 @@
#ifndef _SPARC_PAGE_H
#define _SPARC_PAGE_H

-#ifdef CONFIG_SUN4
-#define PAGE_SHIFT 13
-#else
-#define PAGE_SHIFT 12
-#endif
-#ifndef __ASSEMBLY__
-/* I have my suspicions... -DaveM */
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#else
-#define PAGE_SIZE (1 << PAGE_SHIFT)
-#endif
-#define PAGE_MASK (~(PAGE_SIZE-1))
+#include <asm-generic/page.h>

#ifdef __KERNEL__

@@ -137,9 +126,6 @@ BTFIXUPDEF_SETHI(sparc_unmapped_base)

#endif /* !(__ASSEMBLY__) */

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
#define PAGE_OFFSET 0xf0000000
#ifndef __ASSEMBLY__
extern unsigned long phys_base;
diff -puN include/asm-sh64/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-sh64/page.h
--- threadalloc/include/asm-sh64/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-sh64/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -17,15 +17,8 @@
*
*/

+#include <asm-generic/page.h>

-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT 12
-#ifdef __ASSEMBLY__
-#define PAGE_SIZE 4096
-#else
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#endif
-#define PAGE_MASK (~(PAGE_SIZE-1))
#define PTE_MASK PAGE_MASK

#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
@@ -85,9 +78,6 @@ typedef struct { unsigned long pgprot; }

#endif /* !__ASSEMBLY__ */

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
/*
* Kconfig defined.
*/
diff -puN include/asm-sh/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-sh/page.h
--- threadalloc/include/asm-sh/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-sh/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -13,11 +13,8 @@
[ P4 control ] 0xE0000000
*/

+#include <asm-generic/page.h>

-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT 12
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
#define PTE_MASK PAGE_MASK

#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
@@ -79,9 +76,6 @@ typedef struct { unsigned long pgprot; }

#endif /* !__ASSEMBLY__ */

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
/*
* IF YOU CHANGE THIS, PLEASE ALSO CHANGE
*
diff -puN include/asm-s390/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-s390/page.h
--- threadalloc/include/asm-s390/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-s390/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -10,11 +10,8 @@
#define _S390_PAGE_H

#include <asm/types.h>
+#include <asm-generic/page.h>

-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT 12
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
#define PAGE_DEFAULT_ACC 0
#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)

@@ -174,9 +171,6 @@ page_get_storage_key(unsigned long addr)

#endif /* !__ASSEMBLY__ */

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
#define __PAGE_OFFSET 0x0UL
#define PAGE_OFFSET 0x0UL
#define __pa(x) (unsigned long)(x)
diff -puN include/asm-m68knommu/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-m68knommu/page.h
--- threadalloc/include/asm-m68knommu/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-m68knommu/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -1,12 +1,7 @@
#ifndef _M68KNOMMU_PAGE_H
#define _M68KNOMMU_PAGE_H

-
-/* PAGE_SHIFT determines the page size */
-
-#define PAGE_SHIFT (12)
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
+#include <asm-generic/page.h>

#ifdef __KERNEL__

@@ -44,9 +39,6 @@ typedef struct { unsigned long pgprot; }
#define __pgd(x) ((pgd_t) { (x) } )
#define __pgprot(x) ((pgprot_t) { (x) } )

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
extern unsigned long memory_start;
extern unsigned long memory_end;

diff -puN include/asm-m68k/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-m68k/page.h
--- threadalloc/include/asm-m68k/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-m68k/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -1,22 +1,7 @@
#ifndef _M68K_PAGE_H
#define _M68K_PAGE_H

-
-/* PAGE_SHIFT determines the page size */
-#ifndef CONFIG_SUN3
-#define PAGE_SHIFT (12)
-#else
-#define PAGE_SHIFT (13)
-#endif
-#ifdef __ASSEMBLY__
-#define PAGE_SIZE (1 << PAGE_SHIFT)
-#else
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#endif
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
-#ifdef __KERNEL__
-
+#include <asm-generic/page.h>
#include <asm/setup.h>

#if PAGE_SHIFT < 13
@@ -103,9 +88,6 @@ typedef struct { unsigned long pgprot; }
#define __pgd(x) ((pgd_t) { (x) } )
#define __pgprot(x) ((pgprot_t) { (x) } )

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
#endif /* !__ASSEMBLY__ */

#include <asm/page_offset.h>
diff -puN include/asm-m32r/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-m32r/page.h
--- threadalloc/include/asm-m32r/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-m32r/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -41,9 +41,6 @@ typedef struct { unsigned long pgprot; }

#endif /* !__ASSEMBLY__ */

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
/*
* This handles the memory map.. We could make this a config
* option, but too many people screw it up, and too few need
diff -puN include/asm-i386/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-i386/page.h
--- threadalloc/include/asm-i386/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-i386/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -1,10 +1,7 @@
#ifndef _I386_PAGE_H
#define _I386_PAGE_H

-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT 12
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
+#include <asm-generic/page.h>

#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
@@ -78,9 +75,6 @@ typedef struct { unsigned long pgprot; }

#endif /* !__ASSEMBLY__ */

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
/*
* This handles the memory map.. We could make this a config
* option, but too many people screw it up, and too few need
diff -puN include/asm-h8300/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-h8300/page.h
--- threadalloc/include/asm-h8300/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-h8300/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -1,16 +1,10 @@
#ifndef _H8300_PAGE_H
#define _H8300_PAGE_H

-
-/* PAGE_SHIFT determines the page size */
-
-#define PAGE_SHIFT (12)
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
#ifdef __KERNEL__

#include <asm/setup.h>
+#include <asm-generic/page.h>

#ifndef __ASSEMBLY__

@@ -44,9 +38,6 @@ typedef struct { unsigned long pgprot; }
#define __pgd(x) ((pgd_t) { (x) } )
#define __pgprot(x) ((pgprot_t) { (x) } )

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
extern unsigned long memory_start;
extern unsigned long memory_end;

diff -puN include/asm-generic/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-generic/page.h
--- threadalloc/include/asm-generic/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:15:01.000000000 -0700
+++ threadalloc-dave/include/asm-generic/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -13,8 +13,6 @@
#define ASM_CONST(x) __ASM_CONST(x)
#endif

-#ifdef CONFIG_ARCH_GENERIC_PAGE_SIZE
-
#define PAGE_SHIFT CONFIG_PAGE_SHIFT
#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)

@@ -28,8 +26,7 @@
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)

-#endif /* CONFIG_ARCH_GENERIC_PAGE_SIZE */
-
+#ifndef __ASSEMBLY__
#ifndef __ASSEMBLY__
#ifndef CONFIG_ARCH_HAVE_GET_ORDER
/* Pure 2^n version of get_order */
@@ -45,6 +42,7 @@ static __inline__ __attribute_const__ in
} while (size);
return order;
}
+#endif /* __ASSEMBLY__ */

#endif /* CONFIG_ARCH_HAVE_GET_ORDER */
#endif /* __ASSEMBLY__ */
diff -puN include/asm-frv/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-frv/page.h
--- threadalloc/include/asm-frv/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-frv/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -3,6 +3,7 @@

#ifdef __KERNEL__

+#include <asm-generic/page.h>
#include <asm/virtconvert.h>
#include <asm/mem-layout.h>
#include <asm/sections.h>
@@ -41,9 +42,6 @@ typedef struct { unsigned long pgprot; }
#define __pgprot(x) ((pgprot_t) { (x) } )
#define PTE_MASK PAGE_MASK

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
#define devmem_is_allowed(pfn) 1

#define __pa(vaddr) virt_to_phys((void *) (unsigned long) (vaddr))
diff -puN include/asm-frv/mem-layout.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-frv/mem-layout.h
--- threadalloc/include/asm-frv/mem-layout.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-frv/mem-layout.h 2006-08-30 15:15:06.000000000 -0700
@@ -12,25 +12,14 @@
#ifndef _ASM_MEM_LAYOUT_H
#define _ASM_MEM_LAYOUT_H

+#include <asm-generic/page.h>
+
#ifndef __ASSEMBLY__
#define __UL(X) ((unsigned long) (X))
#else
#define __UL(X) (X)
#endif

-/*
- * PAGE_SHIFT determines the page size
- */
-#define PAGE_SHIFT 14
-
-#ifndef __ASSEMBLY__
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#else
-#define PAGE_SIZE (1 << PAGE_SHIFT)
-#endif
-
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
/*****************************************************************************/
/*
* virtual memory layout from kernel's point of view
diff -puN include/asm-cris/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-cris/page.h
--- threadalloc/include/asm-cris/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-cris/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -1,17 +1,9 @@
#ifndef _CRIS_PAGE_H
#define _CRIS_PAGE_H

+#include <asm-generic/page.h>
#include <asm/arch/page.h>

-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT 13
-#ifndef __ASSEMBLY__
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#else
-#define PAGE_SIZE (1 << PAGE_SHIFT)
-#endif
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
#ifdef __KERNEL__

#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
@@ -63,9 +55,6 @@ typedef struct { unsigned long pgprot; }

#define page_to_phys(page) __pa((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
#ifndef __ASSEMBLY__

#endif /* __ASSEMBLY__ */
diff -puN include/asm-arm26/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-arm26/page.h
--- threadalloc/include/asm-arm26/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-arm26/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -1,6 +1,7 @@
#ifndef _ASMARM_PAGE_H
#define _ASMARM_PAGE_H

+#include <asm-generic/page.h>

#ifdef __KERNEL__
#ifndef __ASSEMBLY__
@@ -79,12 +80,6 @@ typedef unsigned long pgprot_t;

#define EXEC_PAGESIZE 32768

-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
#ifdef __KERNEL__
#ifndef __ASSEMBLY__

diff -puN include/asm-arm/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-arm/page.h
--- threadalloc/include/asm-arm/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-arm/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -10,17 +10,10 @@
#ifndef _ASMARM_PAGE_H
#define _ASMARM_PAGE_H

-
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT 12
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
+#include <asm-generic/page.h>

#ifdef __KERNEL__

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
#ifndef __ASSEMBLY__

#ifndef CONFIG_MMU
diff -puN include/asm-arm/page-nommu.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-arm/page-nommu.h
--- threadalloc/include/asm-arm/page-nommu.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-arm/page-nommu.h 2006-08-30 15:15:06.000000000 -0700
@@ -42,9 +42,6 @@ typedef unsigned long pgprot_t;
#define __pmd(x) (x)
#define __pgprot(x) (x)

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
extern unsigned long memory_start;
extern unsigned long memory_end;

diff -puN include/asm-alpha/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT include/asm-alpha/page.h
--- threadalloc/include/asm-alpha/page.h~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:14:55.000000000 -0700
+++ threadalloc-dave/include/asm-alpha/page.h 2006-08-30 15:15:06.000000000 -0700
@@ -2,11 +2,7 @@
#define _ALPHA_PAGE_H

#include <asm/pal.h>
-
-/* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT 13
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
+#include <asm-generic/page.h>

#ifdef __KERNEL__

@@ -78,9 +74,6 @@ typedef unsigned long pgprot_t;

#endif /* !__ASSEMBLY__ */

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
#ifndef CONFIG_DISCONTIGMEM
diff -puN arch/ia64/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT arch/ia64/Kconfig
--- threadalloc/arch/ia64/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:15:02.000000000 -0700
+++ threadalloc-dave/arch/ia64/Kconfig 2006-08-30 15:15:06.000000000 -0700
@@ -149,9 +149,6 @@ config MCKINLEY

endchoice

-config ARCH_GENERIC_PAGE_SIZE
- def_bool y
-
choice
prompt "Page Table Levels"
default PGTABLE_3
diff -puN arch/mips/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT arch/mips/Kconfig
--- threadalloc/arch/mips/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:15:03.000000000 -0700
+++ threadalloc-dave/arch/mips/Kconfig 2006-08-30 15:15:06.000000000 -0700
@@ -1444,9 +1444,6 @@ config MIPS_PAGE_SIZE_64KB
def_bool y
depends on EXPERIMENTAL && !CPU_R3000 && !CPU_TX39XX

-config ARCH_GENERIC_PAGE_SIZE
- def_bool y
-
config BOARD_SCACHE
bool

diff -puN arch/parisc/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT arch/parisc/Kconfig
--- threadalloc/arch/parisc/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:15:04.000000000 -0700
+++ threadalloc-dave/arch/parisc/Kconfig 2006-08-30 15:15:06.000000000 -0700
@@ -146,9 +146,6 @@ config PARISC_LARGER_PAGE_SIZES
def_bool y
depends on PA8X00 && EXPERIMENTAL

-config ARCH_GENERIC_PAGE_SIZE
- def_bool y
-
endchoice

config SMP
diff -puN arch/powerpc/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT arch/powerpc/Kconfig
--- threadalloc/arch/powerpc/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:15:05.000000000 -0700
+++ threadalloc-dave/arch/powerpc/Kconfig 2006-08-30 15:15:06.000000000 -0700
@@ -725,9 +725,6 @@ config ARCH_MEMORY_PROBE
def_bool y
depends on MEMORY_HOTPLUG

-config ARCH_GENERIC_PAGE_SIZE
- def_bool y
-
config PPC_64K_PAGES
bool "enable 64k page size"
depends on PPC64
diff -puN arch/sparc64/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT arch/sparc64/Kconfig
--- threadalloc/arch/sparc64/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:15:03.000000000 -0700
+++ threadalloc-dave/arch/sparc64/Kconfig 2006-08-30 15:15:06.000000000 -0700
@@ -34,9 +34,6 @@ config ARCH_MAY_HAVE_PC_FDC
bool
default y

-config ARCH_GENERIC_PAGE_SIZE
- def_bool y
-
config SECCOMP
bool "Enable seccomp to safely compute untrusted bytecode"
depends on PROC_FS
diff -puN mm/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT mm/Kconfig
--- threadalloc/mm/Kconfig~arch-generic-PAGE_SIZE-give-every-arch-PAGE_SHIFT 2006-08-30 15:15:05.000000000 -0700
+++ threadalloc-dave/mm/Kconfig 2006-08-30 15:15:06.000000000 -0700
@@ -4,7 +4,6 @@ config ARCH_HAVE_GET_ORDER

choice
prompt "Kernel Page Size"
- depends on ARCH_GENERIC_PAGE_SIZE
default PAGE_SIZE_4KB if MIPS || PARISC
default PAGE_SIZE_8KB if SPARC64
default PAGE_SIZE_16KB if IA64
@@ -45,15 +44,17 @@ config PAGE_SIZE_4MB
depends on SPARC64
endchoice

+# Note that sparc and m68k vary their page sizes based
+# on the SUN3/4 options, so they are not explicitly listed
config PAGE_SHIFT
int
- depends on ARCH_GENERIC_PAGE_SIZE
- default "13" if PAGE_SIZE_8KB
- default "14" if PAGE_SIZE_16KB
+ default "13" if PAGE_SIZE_8KB || ALPHA || CRIS || SUN3 || SUN4
+ default "14" if PAGE_SIZE_16KB || FRV
default "16" if PAGE_SIZE_64KB || PPC_64K_PAGES
default "19" if PAGE_SIZE_512KB
default "22" if PAGE_SIZE_4MB
- default "12"
+ default "12" # arm(26) || h8300 || i386 || m68knommu || m32r || ppc(32)
+ # s390 || sh/64 || um || v850 || xtensa || x86_64

config SELECT_MEMORY_MODEL
def_bool y
_

2006-08-30 22:18:28

by Dave Hansen

[permalink] [raw]
Subject: [RFC][PATCH 6/9] mips generic PAGE_SIZE


This is the mips portion to convert it over to the generic PAGE_SIZE
framework.

* remove mips-specific Kconfig menu
* add mips default of 4k pages to mm/Kconfig
* replace mips Kconfig menu with plain bool variables to preserve
dependencies on specific CPUs. Add to mm/Kconfig


Signed-off-by: Dave Hansen <[email protected]>
---

threadalloc-dave/include/asm-mips/page.h | 23 ----------------
threadalloc-dave/arch/mips/Kconfig | 43 +++++--------------------------
threadalloc-dave/mm/Kconfig | 7 ++---
3 files changed, 13 insertions(+), 60 deletions(-)

diff -puN include/asm-mips/page.h~mips include/asm-mips/page.h
--- threadalloc/include/asm-mips/page.h~mips 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/include/asm-mips/page.h 2006-08-30 15:15:03.000000000 -0700
@@ -9,6 +9,7 @@
#ifndef _ASM_PAGE_H
#define _ASM_PAGE_H

+#include <asm-generic/page.h>

#ifdef __KERNEL__

@@ -16,25 +17,6 @@

#endif

-/*
- * PAGE_SHIFT determines the page size
- */
-#ifdef CONFIG_PAGE_SIZE_4KB
-#define PAGE_SHIFT 12
-#endif
-#ifdef CONFIG_PAGE_SIZE_8KB
-#define PAGE_SHIFT 13
-#endif
-#ifdef CONFIG_PAGE_SIZE_16KB
-#define PAGE_SHIFT 14
-#endif
-#ifdef CONFIG_PAGE_SIZE_64KB
-#define PAGE_SHIFT 16
-#endif
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
-
-
#ifdef __KERNEL__
#ifndef __ASSEMBLY__

@@ -130,9 +112,6 @@ typedef struct { unsigned long pgprot; }

#endif /* !__ASSEMBLY__ */

-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
-
#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))

diff -puN arch/mips/Kconfig~mips arch/mips/Kconfig
--- threadalloc/arch/mips/Kconfig~mips 2006-08-30 15:14:56.000000000 -0700
+++ threadalloc-dave/arch/mips/Kconfig 2006-08-30 15:15:03.000000000 -0700
@@ -1432,47 +1432,20 @@ config 64BIT

endchoice

-choice
- prompt "Kernel page size"
- default PAGE_SIZE_4KB
-
-config PAGE_SIZE_4KB
- bool "4kB"
- help
- This option select the standard 4kB Linux page size. On some
- R3000-family processors this is the only available page size. Using
- 4kB page size will minimize memory consumption and is therefore
- recommended for low memory systems.
-
-config PAGE_SIZE_8KB
- bool "8kB"
+config MIPS_PAGE_SIZE_8KB
+ def_bool y
depends on EXPERIMENTAL && CPU_R8000
- help
- Using 8kB page size will result in higher performance kernel at
- the price of higher memory consumption. This option is available
- only on the R8000 processor. Not that at the time of this writing
- this option is still high experimental; there are also issues with
- compatibility of user applications.

-config PAGE_SIZE_16KB
- bool "16kB"
+config MIPS_PAGE_SIZE_16KB
+ def_bool y
depends on !CPU_R3000 && !CPU_TX39XX
- help
- Using 16kB page size will result in higher performance kernel at
- the price of higher memory consumption. This option is available on
- all non-R3000 family processors. Note that you will need a suitable
- Linux distribution to support this.

-config PAGE_SIZE_64KB
- bool "64kB"
+config MIPS_PAGE_SIZE_64KB
+ def_bool y
depends on EXPERIMENTAL && !CPU_R3000 && !CPU_TX39XX
- help
- Using 64kB page size will result in higher performance kernel at
- the price of higher memory consumption. This option is available on
- all non-R3000 family processor. Not that at the time of this
- writing this option is still high experimental.

-endchoice
+config ARCH_GENERIC_PAGE_SIZE
+ def_bool y

config BOARD_SCACHE
bool
diff -puN mm/Kconfig~mips mm/Kconfig
--- threadalloc/mm/Kconfig~mips 2006-08-30 15:15:03.000000000 -0700
+++ threadalloc-dave/mm/Kconfig 2006-08-30 15:15:03.000000000 -0700
@@ -5,6 +5,7 @@ config ARCH_HAVE_GET_ORDER
choice
prompt "Kernel Page Size"
depends on ARCH_GENERIC_PAGE_SIZE
+ default PAGE_SIZE_4KB if MIPS
default PAGE_SIZE_8KB if SPARC64
default PAGE_SIZE_16KB if IA64
config PAGE_SIZE_4KB
@@ -28,13 +29,13 @@ config PAGE_SIZE_4KB
architecture.
config PAGE_SIZE_8KB
bool "8KB"
- depends on IA64 || SPARC64
+ depends on IA64 || SPARC64 || MIPS_PAGE_SIZE_8KB
config PAGE_SIZE_16KB
bool "16KB"
- depends on IA64
+ depends on IA64 || MIPS_PAGE_SIZE_16KB
config PAGE_SIZE_64KB
bool "64KB"
- depends on (IA64 && !ITANIUM) || SPARC64
+ depends on (IA64 && !ITANIUM) || SPARC64 || MIPS_PAGE_SIZE_64KB
config PAGE_SIZE_512KB
bool "512KB"
depends on SPARC64
_

2006-08-30 22:27:07

by David Miller

[permalink] [raw]
Subject: Re: [RFC][PATCH 5/9] sparc64 generic PAGE_SIZE

From: Dave Hansen <[email protected]>
Date: Wed, 30 Aug 2006 15:16:08 -0700

>
> This is the sparc64 portion to convert it over to the generic PAGE_SIZE
> framework.
>
> * Change all references to CONFIG_SPARC64_PAGE_SIZE_*KB to
> CONFIG_PAGE_SIZE_* and update the defconfig.
> * remove sparc64-specific Kconfig menu
> * add sparc64 default of 8k pages to mm/Kconfig
> * remove generic support for 4k pages
> * add support for 8k, 64k, 512k, and 4MB pages
>
> Signed-off-by: Dave Hansen <[email protected]>

Signed-off-by: David S. Miller <[email protected]>

2006-08-30 22:42:12

by Kyle McMartin

[permalink] [raw]
Subject: Re: [RFC][PATCH 7/9] parisc generic PAGE_SIZE

On Wed, Aug 30, 2006 at 03:16:09PM -0700, Dave Hansen wrote:
> This is the parisc portion to convert it over to the generic PAGE_SIZE
> framework.
>
<snip>
> Signed-off-by: Dave Hansen <[email protected]>

This looks pretty ok by me. I'll give it a test-build tonight.

Signed-off-by: Kyle McMartin <[email protected]>

> +config PARISC_LARGER_PAGE_SIZES
> + def_bool y
> depends on PA8X00 && EXPERIMENTAL
>

This should default to 'n' as I do not believe we yet have working >4K
pages yet.

Cheers! (Nice to see diffs with more '-' than '+' :)
Kyle M.

2006-08-30 22:48:17

by Dave Hansen

[permalink] [raw]
Subject: Re: [RFC][PATCH 7/9] parisc generic PAGE_SIZE

On Wed, 2006-08-30 at 18:40 -0400, Kyle McMartin wrote:
> On Wed, Aug 30, 2006 at 03:16:09PM -0700, Dave Hansen wrote:
> > This is the parisc portion to convert it over to the generic PAGE_SIZE
> > framework.
> >
> <snip>
> > Signed-off-by: Dave Hansen <[email protected]>
>
> This looks pretty ok by me. I'll give it a test-build tonight.

That'd be great. Thanks!

> > +config PARISC_LARGER_PAGE_SIZES
> > + def_bool y
> > depends on PA8X00 && EXPERIMENTAL
> >
>
> This should default to 'n' as I do not believe we yet have working >4K
> pages yet.

This actually just defaults to enables the option to _appear_ in the
top-level Kconfig file. The default from the top-level Kconfig file
should still be 4k for parisc.

-- Dave

2006-08-30 23:57:23

by Christoph Lameter

[permalink] [raw]
Subject: Re: [RFC][PATCH 4/9] ia64 generic PAGE_SIZE

On Wed, 30 Aug 2006, Dave Hansen wrote:

> @@ -64,11 +64,11 @@
> * Base-2 logarithm of number of pages to allocate per task structure
> * (including register backing store and memory stack):
> */
> -#if defined(CONFIG_IA64_PAGE_SIZE_4KB)
> +#if defined(CONFIG_PAGE_SIZE_4KB)
> # define KERNEL_STACK_SIZE_ORDER 3
> -#elif defined(CONFIG_IA64_PAGE_SIZE_8KB)
> +#elif defined(CONFIG_PAGE_SIZE_8KB)
> # define KERNEL_STACK_SIZE_ORDER 2
> -#elif defined(CONFIG_IA64_PAGE_SIZE_16KB)
> +#elif defined(CONFIG_PAGE_SIZE_16KB)
> # define KERNEL_STACK_SIZE_ORDER 1
> #else
> # define KERNEL_STACK_SIZE_ORDER 0

Could we replace these lines with

#define KERNEL_STACK_SIZE_ORDER (max(0, 15 - PAGE_SHIFT))

?

2006-08-31 00:08:11

by Christoph Lameter

[permalink] [raw]
Subject: Re: [RFC][PATCH 3/9] actual generic PAGE_SIZE infrastructure

On Wed, 30 Aug 2006, Dave Hansen wrote:

> #endif /* CONFIG_ARCH_HAVE_GET_ORDER */
> -#endif /* __ASSEMBLY__ */
> +#endif /* __ASSEMBLY__ */
^^^ Extra blank.

> + prompt "Kernel Page Size"
page size?

> + This lets you select the page size of the kernel. For best
> + 32-bit compatibility on 64-bit architectures, a page size of 4KB
> + should be selected (although most binaries work perfectly fine with
> + a larger page size). For best performance, a page size of larger
> + than 4KB is recommended. However, there are a number of
> + side-effects of larger page sizes, like small files fitting poorly
> + into the page cache.

Could we change this somewhat? Avoid the direct address and maybe say:

The kernel page size determines the basic chunk of memory handled
by the Linux VM. The bigger the page size the less page objects
have to be managed by the kernel which reduces the VM overhead in
handling large amounts of data. However, larger pages also lead
to memory being wasted by the kernel since small files will
at mininum require one page of memory. A 4K pagesize is fairly standard
and may be required for 32 bit compatibility on many platforms.

It is usually not wise to select another page size than the default
unless one knows what one is doing or has some time to spend on
getting to know the kernel.


Note that the default pagesize on IA64 is 16K and some important things
would change if a lesser size is selected. I have never run a 4K kernel.
I do not think we can just say that 4KB is okay. There may be other
platforms that have other default page sizes.

2006-08-31 00:34:01

by Paul Mackerras

[permalink] [raw]
Subject: Re: [RFC][PATCH 0/9] generic PAGE_SIZE infrastructure (v4)

Dave Hansen writes:

> Why am I doing this? The OpenVZ beancounter patch hooks into the
> alloc_thread_info() path, but only in two architectures. It is silly
> to patch each and every architecture when they all just do the same
> thing. This is the first step to have a single place in which to
> do alloc_thread_info(). Oh, and this series removes about 300 lines
> of code.

... at the price of making the Kconfig help text more generic and
therefore possibly confusing on some platforms.

I really don't see much value in doing all this.

Paul.

2006-08-31 17:38:50

by Dave Hansen

[permalink] [raw]
Subject: Re: [RFC][PATCH 4/9] ia64 generic PAGE_SIZE

On Wed, 2006-08-30 at 16:57 -0700, Christoph Lameter wrote:
> On Wed, 30 Aug 2006, Dave Hansen wrote:
>
> > @@ -64,11 +64,11 @@
> > * Base-2 logarithm of number of pages to allocate per task structure
> > * (including register backing store and memory stack):
> > */
> > -#if defined(CONFIG_IA64_PAGE_SIZE_4KB)
> > +#if defined(CONFIG_PAGE_SIZE_4KB)
> > # define KERNEL_STACK_SIZE_ORDER 3
> > -#elif defined(CONFIG_IA64_PAGE_SIZE_8KB)
> > +#elif defined(CONFIG_PAGE_SIZE_8KB)
> > # define KERNEL_STACK_SIZE_ORDER 2
> > -#elif defined(CONFIG_IA64_PAGE_SIZE_16KB)
> > +#elif defined(CONFIG_PAGE_SIZE_16KB)
> > # define KERNEL_STACK_SIZE_ORDER 1
> > #else
> > # define KERNEL_STACK_SIZE_ORDER 0
>
> Could we replace these lines with
>
> #define KERNEL_STACK_SIZE_ORDER (max(0, 15 - PAGE_SHIFT))

My next series will be to clean up stack size handling. Do you mind if
it waits until then?

-- Dave

2006-08-31 17:40:06

by Christoph Lameter

[permalink] [raw]
Subject: Re: [RFC][PATCH 4/9] ia64 generic PAGE_SIZE

On Thu, 31 Aug 2006, Dave Hansen wrote:

> > #define KERNEL_STACK_SIZE_ORDER (max(0, 15 - PAGE_SHIFT))
>
> My next series will be to clean up stack size handling. Do you mind if
> it waits until then?

I am not in a hurry on this one.


2006-08-31 17:57:53

by Dave Hansen

[permalink] [raw]
Subject: Re: [RFC][PATCH 3/9] actual generic PAGE_SIZE infrastructure

On Wed, 2006-08-30 at 17:08 -0700, Christoph Lameter wrote:
> On Wed, 30 Aug 2006, Dave Hansen wrote:
>
> > #endif /* CONFIG_ARCH_HAVE_GET_ORDER */
> > -#endif /* __ASSEMBLY__ */
> > +#endif /* __ASSEMBLY__ */
> ^^^ Extra blank.

OK. I'll fix that.

> > + prompt "Kernel Page Size"
> page size?

Sure.

> > + This lets you select the page size of the kernel. For best
> > + 32-bit compatibility on 64-bit architectures, a page size of 4KB
> > + should be selected (although most binaries work perfectly fine with
> > + a larger page size). For best performance, a page size of larger
> > + than 4KB is recommended. However, there are a number of
> > + side-effects of larger page sizes, like small files fitting poorly
> > + into the page cache.
>
> Could we change this somewhat? Avoid the direct address and maybe say:
>
> The kernel page size determines the basic chunk of memory handled
> by the Linux VM. The bigger the page size the less page objects
> have to be managed by the kernel which reduces the VM overhead in
> handling large amounts of data. However, larger pages also lead
> to memory being wasted by the kernel since small files will
> at mininum require one page of memory. A 4K pagesize is fairly standard
> and may be required for 32 bit compatibility on many platforms.
>
> It is usually not wise to select another page size than the default
> unless one knows what one is doing or has some time to spend on
> getting to know the kernel.

This is very nice. I'll incorporate it.

> Note that the default pagesize on IA64 is 16K and some important things
> would change if a lesser size is selected. I have never run a 4K kernel.
> I do not think we can just say that 4KB is okay. There may be other
> platforms that have other default page sizes.

If we can't just say that it is OK, then we should probably disable it
in Kconfig. Should we do that?

-- Dave

2006-08-31 18:06:39

by Christoph Lameter

[permalink] [raw]
Subject: Re: [RFC][PATCH 3/9] actual generic PAGE_SIZE infrastructure

On Thu, 31 Aug 2006, Dave Hansen wrote:

> > Note that the default pagesize on IA64 is 16K and some important things
> > would change if a lesser size is selected. I have never run a 4K kernel.
> > I do not think we can just say that 4KB is okay. There may be other
> > platforms that have other default page sizes.
>
> If we can't just say that it is OK, then we should probably disable it
> in Kconfig. Should we do that?

Well, we cannot disable 4K support for all platforms, so I guess this
refers only to IA64.

IA64 can certainly be build with 4K support. I am not sure how well user
space tools play with it. Better leave it selectable unless others on
linux-ia64 have something to say on the issue.

2006-08-31 18:41:09

by Håvard Skinnemoen

[permalink] [raw]
Subject: Re: [RFC][PATCH 2/9] conditionally define generic get_order() (ARCH_HAS_GET_ORDER)

On 8/31/06, Dave Hansen <[email protected]> wrote:
> diff -puN mm/Kconfig~generic-get_order mm/Kconfig
> --- threadalloc/mm/Kconfig~generic-get_order 2006-08-30 15:14:56.000000000 -0700
> +++ threadalloc-dave/mm/Kconfig 2006-08-30 15:15:00.000000000 -0700
> @@ -1,3 +1,7 @@
> +config ARCH_HAVE_GET_ORDER
> + def_bool y
> + depends on IA64 || PPC32 || XTENSA
> +

I have a feeling this has been discussed before, but wouldn't it be
better to let each architecture define this in its own Kconfig?

At some point, I have to add AVR32 to that list, and if one or more
other architectures need to do the same, there will be rejects.

Haavard

2006-08-31 19:51:38

by Dave Hansen

[permalink] [raw]
Subject: Re: [RFC][PATCH 2/9] conditionally define generic get_order() (ARCH_HAS_GET_ORDER)

On Thu, 2006-08-31 at 20:41 +0200, Haavard Skinnemoen wrote:
> On 8/31/06, Dave Hansen <[email protected]> wrote:
> > diff -puN mm/Kconfig~generic-get_order mm/Kconfig
> > --- threadalloc/mm/Kconfig~generic-get_order 2006-08-30 15:14:56.000000000 -0700
> > +++ threadalloc-dave/mm/Kconfig 2006-08-30 15:15:00.000000000 -0700
> > @@ -1,3 +1,7 @@
> > +config ARCH_HAVE_GET_ORDER
> > + def_bool y
> > + depends on IA64 || PPC32 || XTENSA
> > +
>
> I have a feeling this has been discussed before, but wouldn't it be
> better to let each architecture define this in its own Kconfig?

As long as the conditions are simple, I think it would be nice to keep
it this way. It makes it pretty obvious to tell what is going on from
_one_ place.

> At some point, I have to add AVR32 to that list, and if one or more
> other architectures need to do the same, there will be rejects.

True, there will be rejects. But, do you think they will actually take
more than a moment to merge?

-- Dave

2006-08-31 20:50:54

by Dave Hansen

[permalink] [raw]
Subject: Re: [RFC][PATCH 3/9] actual generic PAGE_SIZE infrastructure

Here's the latest version I have, with much improved help text, thanks
to Christoph Lameter.

-----

* Add _ALIGN_UP() which we'll use now and _ALIGN_DOWN(), just for
parity.
* Define ASM_CONST() macro to help using constants in both assembly
and C code. Several architectures have some form of this, and
they will be consolidated around this one.
* Actually create PAGE_SHIFT and PAGE_SIZE macros
* For now, require that architectures enable GENERIC_PAGE_SIZE in
order to get this new code. This option will be removed by the
last patch in the series, and makes the series bisect-safe.
* Note that this moves the compiler.h define outside of the
#ifdef __KERNEL__, but that's OK because it has its own.

Signed-off-by: Dave Hansen <[email protected]>
---

threadalloc-dave/include/asm-generic/page.h | 29 +++++++++++++++++-
threadalloc-dave/mm/Kconfig | 44 ++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 2 deletions(-)

diff -puN include/asm-generic/page.h~generic-PAGE_SIZE-infrastructure include/asm-generic/page.h
--- threadalloc/include/asm-generic/page.h~generic-PAGE_SIZE-infrastructure 2006-08-31 13:48:45.000000000 -0700
+++ threadalloc-dave/include/asm-generic/page.h 2006-08-31 13:49:04.000000000 -0700
@@ -1,11 +1,36 @@
#ifndef _ASM_GENERIC_PAGE_H
#define _ASM_GENERIC_PAGE_H

+#include <linux/compiler.h>
+#include <linux/align.h>
+
#ifdef __KERNEL__
-#ifndef __ASSEMBLY__

-#include <linux/compiler.h>
+#ifdef __ASSEMBLY__
+#define ASM_CONST(x) x
+#else
+#define __ASM_CONST(x) x##UL
+#define ASM_CONST(x) __ASM_CONST(x)
+#endif
+
+#ifdef CONFIG_ARCH_GENERIC_PAGE_SIZE
+
+#define PAGE_SHIFT CONFIG_PAGE_SHIFT
+#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)
+
+/*
+ * Subtle: (1 << PAGE_SHIFT) is an int, not an unsigned long. So if we
+ * assign PAGE_MASK to a larger type it gets extended the way we want
+ * (i.e. with 1s in the high bits)
+ */
+#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))

+/* to align the pointer to the (next) page boundary */
+#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
+
+#endif /* CONFIG_ARCH_GENERIC_PAGE_SIZE */
+
+#ifndef __ASSEMBLY__
#ifndef CONFIG_ARCH_HAVE_GET_ORDER
/* Pure 2^n version of get_order */
static __inline__ __attribute_const__ int get_order(unsigned long size)
diff -puN mm/Kconfig~generic-PAGE_SIZE-infrastructure mm/Kconfig
--- threadalloc/mm/Kconfig~generic-PAGE_SIZE-infrastructure 2006-08-31 13:48:45.000000000 -0700
+++ threadalloc-dave/mm/Kconfig 2006-08-31 13:49:04.000000000 -0700
@@ -2,6 +2,50 @@ config ARCH_HAVE_GET_ORDER
def_bool y
depends on IA64 || PPC32 || XTENSA

+choice
+ prompt "Kernel page size"
+ depends on ARCH_GENERIC_PAGE_SIZE
+config PAGE_SIZE_4KB
+ bool "4KB"
+ help
+ The kernel page size determines the basic chunk of memory handled
+ by the Linux VM. If these pages are larger, the kernel can
+ use the same amount of physical memory with fewer data structures.
+ This reduces the VM overhead in handling large amounts of data.
+ Larger pages can also lead to better TLB coverage for large memory
+ applications.
+
+ However, larger pages also lead to memory being wasted by the
+ kernel since all files require a minimum of one page of memory.
+ With a 64KB page size, a 1 byte file will consume 64KB of memory.
+
+ A 4KB pagesize is fairly standard and may be required for 32-bit
+ compatibility on many platforms.
+
+ It is usually not wise to select another page size than the default.
+
+config PAGE_SIZE_8KB
+ bool "8KB"
+config PAGE_SIZE_16KB
+ bool "16KB"
+config PAGE_SIZE_64KB
+ bool "64KB"
+config PAGE_SIZE_512KB
+ bool "512KB"
+config PAGE_SIZE_4MB
+ bool "4MB"
+endchoice
+
+config PAGE_SHIFT
+ int
+ depends on ARCH_GENERIC_PAGE_SIZE
+ default "13" if PAGE_SIZE_8KB
+ default "14" if PAGE_SIZE_16KB
+ default "16" if PAGE_SIZE_64KB
+ default "19" if PAGE_SIZE_512KB
+ default "22" if PAGE_SIZE_4MB
+ default "12"
+
config SELECT_MEMORY_MODEL
def_bool y
depends on EXPERIMENTAL || ARCH_SELECT_MEMORY_MODEL
_


2006-08-31 21:03:24

by Dave Hansen

[permalink] [raw]
Subject: Re: [RFC][PATCH 0/9] generic PAGE_SIZE infrastructure (v4)

On Thu, 2006-08-31 at 10:33 +1000, Paul Mackerras wrote:
> Dave Hansen writes:
> > Why am I doing this? The OpenVZ beancounter patch hooks into the
> > alloc_thread_info() path, but only in two architectures. It is silly
> > to patch each and every architecture when they all just do the same
> > thing. This is the first step to have a single place in which to
> > do alloc_thread_info(). Oh, and this series removes about 300 lines
> > of code.
>
> ... at the price of making the Kconfig help text more generic and
> therefore possibly confusing on some platforms.
>
> I really don't see much value in doing all this.

The value for me is that this makes it much easier to add generic kernel
features. There have been way too many times that I've made some
arch-independent change which required going and fixing up the *same*
code in every single architecture.

-- Dave

2006-09-05 11:21:11

by Martin Waitz

[permalink] [raw]
Subject: Re: [RFC][PATCH 3/9] actual generic PAGE_SIZE infrastructure

hoi :)

On Wed, Aug 30, 2006 at 03:16:06PM -0700, Dave Hansen wrote:
> * Define ASM_CONST() macro to help using constants in both assembly
> and C code. Several architectures have some form of this, and
> they will be consolidated around this one.

arm uses UL() for this and I think this is much more readable than
ASM_CONST(). Can we please change the name of this macro?

--
Martin Waitz


Attachments:
(No filename) (398.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments

2006-09-05 16:48:11

by Dave Hansen

[permalink] [raw]
Subject: Re: [RFC][PATCH 3/9] actual generic PAGE_SIZE infrastructure

On Tue, 2006-09-05 at 13:20 +0200, Martin Waitz wrote:
> On Wed, Aug 30, 2006 at 03:16:06PM -0700, Dave Hansen wrote:
> > * Define ASM_CONST() macro to help using constants in both assembly
> > and C code. Several architectures have some form of this, and
> > they will be consolidated around this one.
>
> arm uses UL() for this and I think this is much more readable than
> ASM_CONST(). Can we please change the name of this macro?

I don't have any real problem with changing it, but I fear that the ppc
guys will want it the _other_ way. ;)

Do you really mind if we just keep it as it is? If there is some
further disagreement on it, I'll change it.

-- Dave

2006-10-17 07:12:36

by Qi Yong

[permalink] [raw]
Subject: Re: [RFC][PATCH 3/9] actual generic PAGE_SIZE infrastructure

Dave Hansen wrote:

>* Add _ALIGN_UP() which we'll use now and _ALIGN_DOWN(), just for
> parity.
>* Define ASM_CONST() macro to help using constants in both assembly
> and C code. Several architectures have some form of this, and
> they will be consolidated around this one.
>* Actually create PAGE_SHIFT and PAGE_SIZE macros
>* For now, require that architectures enable GENERIC_PAGE_SIZE in
> order to get this new code. This option will be removed by the
> last patch in the series, and makes the series bisect-safe.
>* Note that this moves the compiler.h define outside of the
> #ifdef __KERNEL__, but that's OK because it has its own.
>
>Signed-off-by: Dave Hansen <[email protected]>
>---
>
> threadalloc-dave/include/asm-generic/page.h | 31 ++++++++++++++++++--
> threadalloc-dave/mm/Kconfig | 43 ++++++++++++++++++++++++++++
> 2 files changed, 71 insertions(+), 3 deletions(-)
>
>diff -puN include/asm-generic/page.h~generic-PAGE_SIZE-infrastructure include/asm-generic/page.h
>--- threadalloc/include/asm-generic/page.h~generic-PAGE_SIZE-infrastructure 2006-08-30 15:15:00.000000000 -0700
>+++ threadalloc-dave/include/asm-generic/page.h 2006-08-30 15:15:01.000000000 -0700
>@@ -1,11 +1,36 @@
> #ifndef _ASM_GENERIC_PAGE_H
> #define _ASM_GENERIC_PAGE_H
>
>+#include <linux/compiler.h>
>+#include <linux/align.h>
>+
> #ifdef __KERNEL__
>-#ifndef __ASSEMBLY__
>
>-#include <linux/compiler.h>
>+#ifdef __ASSEMBLY__
>+#define ASM_CONST(x) x
>+#else
>+#define __ASM_CONST(x) x##UL
>+#define ASM_CONST(x) __ASM_CONST(x)
>+#endif
>+
>+#ifdef CONFIG_ARCH_GENERIC_PAGE_SIZE
>+
>+#define PAGE_SHIFT CONFIG_PAGE_SHIFT
>+#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)
>
>

Your generic page.h hides PAGE_SIZE under "#ifdef __KERNEL__".
That would cause severe userland compile failures.

Most archs have PAGE_SIZE visible to userland.
Please keep PAGE_SIZE and its friends outside "#ifdef __KERNEL__".


-- qiyong

>+
>+/*
>+ * Subtle: (1 << PAGE_SHIFT) is an int, not an unsigned long. So if we
>+ * assign PAGE_MASK to a larger type it gets extended the way we want
>+ * (i.e. with 1s in the high bits)
>+ */
>+#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
>
>+/* to align the pointer to the (next) page boundary */
>+#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
>+
>+#endif /* CONFIG_ARCH_GENERIC_PAGE_SIZE */
>+
>+#ifndef __ASSEMBLY__
> #ifndef CONFIG_ARCH_HAVE_GET_ORDER
> /* Pure 2^n version of get_order */
> static __inline__ __attribute_const__ int get_order(unsigned long size)
>@@ -22,7 +47,7 @@ static __inline__ __attribute_const__ in
> }
>
> #endif /* CONFIG_ARCH_HAVE_GET_ORDER */
>-#endif /* __ASSEMBLY__ */
>+#endif /* __ASSEMBLY__ */
> #endif /* __KERNEL__ */
>
> #endif /* _ASM_GENERIC_PAGE_H */
>
>
--
Qi Yong