All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <haveblue@us.ibm.com>
To: linux-mm@kvack.org
Cc: linux-ia64@vger.kernel.org, rdunlap@xenotime.net,
	lethal@linux-sh.org, Dave Hansen <haveblue@us.ibm.com>
Subject: [RFC][PATCH 03/10] actual generic PAGE_SIZE infrastructure
Date: Tue, 29 Aug 2006 20:19:36 +0000	[thread overview]
Message-ID: <20060829201936.2C7D5100@localhost.localdomain> (raw)
In-Reply-To: <20060829201934.47E63D1F@localhost.localdomain>


* 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 <haveblue@us.ibm.com>
---

 threadalloc-dave/include/linux/align.h      |    7 ++++
 threadalloc-dave/include/asm-generic/page.h |   31 +++++++++++++++++++--
 threadalloc-dave/mm/Kconfig                 |   41 ++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 4 deletions(-)

diff -puN include/linux/align.h~generic-PAGE_SIZE-infrastructure include/linux/align.h
--- threadalloc/include/linux/align.h~generic-PAGE_SIZE-infrastructure	2006-08-29 13:14:50.000000000 -0700
+++ threadalloc-dave/include/linux/align.h	2006-08-29 13:14:51.000000000 -0700
@@ -6,12 +6,17 @@
  * dependencies, and can be used safely from any other header.
  */
 
+/* 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 is special.  There's a linkage.h as well that
  * has a quite different meaning.
  */
 #ifndef __ASSEMBLY__
-#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
+/* align addr on a size boundary - adjust address up if needed */
+#define ALIGN(addr,size)     _ALIGN_UP(addr,size)
 #endif
 
 #endif /* _LINUX_ALIGN_H */
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-29 13:14:50.000000000 -0700
+++ threadalloc-dave/include/asm-generic/page.h	2006-08-29 13:14:51.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-29 13:14:50.000000000 -0700
+++ threadalloc-dave/mm/Kconfig	2006-08-29 13:14:51.000000000 -0700
@@ -2,6 +2,47 @@ 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
+	  performance, a page size of larger than 4k is recommended.  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).
+
+	  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
_

WARNING: multiple messages have this Message-ID (diff)
From: Dave Hansen <haveblue@us.ibm.com>
To: linux-mm@kvack.org
Cc: linux-ia64@vger.kernel.org, rdunlap@xenotime.net,
	lethal@linux-sh.org, Dave Hansen <haveblue@us.ibm.com>
Subject: [RFC][PATCH 03/10] actual generic PAGE_SIZE infrastructure
Date: Tue, 29 Aug 2006 13:19:36 -0700	[thread overview]
Message-ID: <20060829201936.2C7D5100@localhost.localdomain> (raw)
In-Reply-To: <20060829201934.47E63D1F@localhost.localdomain>

* 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 <haveblue@us.ibm.com>
---

 threadalloc-dave/include/linux/align.h      |    7 ++++
 threadalloc-dave/include/asm-generic/page.h |   31 +++++++++++++++++++--
 threadalloc-dave/mm/Kconfig                 |   41 ++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 4 deletions(-)

diff -puN include/linux/align.h~generic-PAGE_SIZE-infrastructure include/linux/align.h
--- threadalloc/include/linux/align.h~generic-PAGE_SIZE-infrastructure	2006-08-29 13:14:50.000000000 -0700
+++ threadalloc-dave/include/linux/align.h	2006-08-29 13:14:51.000000000 -0700
@@ -6,12 +6,17 @@
  * dependencies, and can be used safely from any other header.
  */
 
+/* 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 is special.  There's a linkage.h as well that
  * has a quite different meaning.
  */
 #ifndef __ASSEMBLY__
-#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
+/* align addr on a size boundary - adjust address up if needed */
+#define ALIGN(addr,size)     _ALIGN_UP(addr,size)
 #endif
 
 #endif /* _LINUX_ALIGN_H */
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-29 13:14:50.000000000 -0700
+++ threadalloc-dave/include/asm-generic/page.h	2006-08-29 13:14:51.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-29 13:14:50.000000000 -0700
+++ threadalloc-dave/mm/Kconfig	2006-08-29 13:14:51.000000000 -0700
@@ -2,6 +2,47 @@ 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
+	  performance, a page size of larger than 4k is recommended.  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).
+
+	  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
_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2006-08-29 20:19 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-29 20:19 [RFC][PATCH 00/10] generic PAGE_SIZE infrastructure (v3) Dave Hansen
2006-08-29 20:19 ` Dave Hansen
2006-08-29 20:19 ` [RFC][PATCH 01/10] put alignment macros in align.h Dave Hansen
2006-08-29 20:19   ` Dave Hansen
2006-08-30 16:11   ` Nikita Danilov
2006-08-30 16:48   ` Dave Hansen
2006-08-29 20:19 ` [RFC][PATCH 02/10] conditionally define generic get_order() (ARCH_HAS_GET_ORDER) Dave Hansen
2006-08-29 20:19   ` Dave Hansen
2006-08-30 10:20   ` Paul Mundt
2006-08-30 10:20     ` Paul Mundt
2006-08-29 20:19 ` Dave Hansen [this message]
2006-08-29 20:19   ` [RFC][PATCH 03/10] actual generic PAGE_SIZE infrastructure Dave Hansen
2006-08-29 20:19 ` [RFC][PATCH 05/10] ia64 generic PAGE_SIZE Dave Hansen
2006-08-29 20:19   ` Dave Hansen
2006-08-29 20:19 ` [RFC][PATCH 04/10] replace _ALIGN() Dave Hansen
2006-08-29 20:19   ` Dave Hansen
2006-08-29 20:19 ` [RFC][PATCH 06/10] sparc64 generic PAGE_SIZE Dave Hansen
2006-08-29 20:19   ` Dave Hansen
2006-08-29 21:33   ` Dave Hansen
2006-08-29 21:33     ` Dave Hansen
2006-08-29 20:19 ` [RFC][PATCH 07/10] mips " Dave Hansen
2006-08-29 20:19   ` Dave Hansen
2006-08-29 20:19 ` [RFC][PATCH 08/10] parisc " Dave Hansen
2006-08-29 20:19   ` Dave Hansen
2006-08-29 20:19 ` [RFC][PATCH 09/10] powerpc " Dave Hansen
2006-08-29 20:19   ` Dave Hansen
2006-08-29 20:19 ` [RFC][PATCH 10/10] convert the "easy" architectures to " Dave Hansen
2006-08-29 20:19   ` Dave Hansen
2006-08-29 21:06   ` Luck, Tony
2006-08-29 21:06     ` Luck, Tony
2006-08-29 21:13     ` [RFC][PATCH 10/10] convert the "easy" architectures to generic Dave Hansen
2006-08-29 21:13       ` [RFC][PATCH 10/10] convert the "easy" architectures to generic PAGE_SIZE Dave Hansen
2006-08-30 10:05   ` Paul Mundt
2006-08-30 10:05     ` Paul Mundt
2006-08-30 14:56     ` [RFC][PATCH 10/10] convert the "easy" architectures to generic Dave Hansen
2006-08-30 14:56       ` [RFC][PATCH 10/10] convert the "easy" architectures to generic PAGE_SIZE Dave Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060829201936.2C7D5100@localhost.localdomain \
    --to=haveblue@us.ibm.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rdunlap@xenotime.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.