The 16G huge pages have to be reserved in the HMC prior to boot. The location of
the pages are placed in the device tree. During very early boot these locations are
saved for use by hugetlbfs.
Signed-off-by: Jon Tollefson <kniht@linux.vnet.ibm.com>
---
arch/powerpc/mm/hash_utils_64.c | 41 ++++++++++++++++++++++++++++++++++++++-
arch/powerpc/mm/hugetlbpage.c | 17 ++++++++++++++++
include/asm-powerpc/mmu-hash64.h | 2 +
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index a83dfa3..d3f7d92 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -67,6 +67,7 @@
#define KB (1024)
#define MB (1024*KB)
+#define GB (1024L*MB)
/*
* Note: pte --> Linux PTE
@@ -302,6 +303,41 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
return 0;
}
+/* Scan for 16G memory blocks that have been set aside for huge pages
+ * and reserve those blocks for 16G huge pages.
+ */
+static int __init htab_dt_scan_hugepage_blocks(unsigned long node,
+ const char *uname, int depth,
+ void *data) {
+ char *type = of_get_flat_dt_prop(node, "device_type", NULL);
+ unsigned long *lprop;
+ u32 *prop;
+
+ /* We are scanning "memory" nodes only */
+ if (type == NULL || strcmp(type, "memory") != 0)
+ return 0;
+
+ /* This property is the log base 2 of the number of virtual pages that
+ * will represent this memory block. */
+ prop = of_get_flat_dt_prop(node, "ibm,expected#pages", NULL);
+ if (prop == NULL)
+ return 0;
+ unsigned int expected_pages = (1 << prop[0]);
+ lprop = of_get_flat_dt_prop(node, "reg", NULL);
+ if (lprop == NULL)
+ return 0;
+ long unsigned int phys_addr = lprop[0];
+ long unsigned int block_size = lprop[1];
+ if (block_size != (16 * GB))
+ return 0;
+ printk(KERN_INFO "Reserving huge page memory "
+ "addr = 0x%lX size = 0x%lX pages = %d\n",
+ phys_addr, block_size, expected_pages);
+ lmb_reserve(phys_addr, block_size * expected_pages);
+ add_gpage(phys_addr, block_size, expected_pages);
+ return 0;
+}
+
static void __init htab_init_page_sizes(void)
{
int rc;
@@ -370,7 +406,10 @@ static void __init htab_init_page_sizes(void)
mmu_psize_defs[mmu_io_psize].shift);
#ifdef CONFIG_HUGETLB_PAGE
- /* Init large page size. Currently, we pick 16M or 1M depending
+ /* Reserve 16G huge page memory sections for huge pages */
+ of_scan_flat_dt(htab_dt_scan_hugepage_blocks, NULL);
+
+/* Init large page size. Currently, we pick 16M or 1M depending
* on what is available
*/
if (mmu_psize_defs[MMU_PAGE_16M].shift)
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 31d977b..44d3d55 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -108,6 +108,23 @@ pmd_t *hpmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long addr)
}
#endif
+/* Build list of addresses of gigantic pages. This function is used in early
+ * boot before the buddy allocator is setup.
+ */
+void add_gpage(unsigned long addr, unsigned long page_size,
+ unsigned long number_of_pages)
+{
+ if (addr) {
+ while (number_of_pages > 0) {
+ gpage_freearray[nr_gpages] = __va(addr);
+ nr_gpages++;
+ number_of_pages--;
+ addr += page_size;
+ }
+ }
+}
+
+
/* Put 16G page address into temporary huge page list because the mem_map
* is not up yet.
*/
diff --git a/include/asm-powerpc/mmu-hash64.h b/include/asm-powerpc/mmu-hash64.h
index 2864fa3..db1276a 100644
--- a/include/asm-powerpc/mmu-hash64.h
+++ b/include/asm-powerpc/mmu-hash64.h
@@ -279,6 +279,8 @@ extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
unsigned long pstart, unsigned long mode,
int psize, int ssize);
extern void set_huge_psize(int psize);
+extern void add_gpage(unsigned long addr, unsigned long page_size,
+ unsigned long number_of_pages);
extern void demote_segment_4k(struct mm_struct *mm, unsigned long addr);
extern void htab_initialize(void);
--
| Bron Gondwana | BUG: mmapfile/writev spurious zero bytes (x86_64/not i386, bisected, reproducable) |
| Gabriel C | Re: [Announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS] |
| David Miller | [GIT]: Networking |
| Dave Young | Re: 2.6.24-rc3-mm1 |
git: | |
| Matthieu Moy | git push to a non-bare repository |
| Josh Boyer | git-unpack-objects |
| Linus Torvalds | Re: Problem with a push |
| Johannes Schindelin | Re: Git-windows and git-svn? |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| James | Re: OBSD on MacBook |
| Alexey Suslikov | OT: OpenBSD on Asus eeePC |
| Daniel Ouellet | Re: Show your appreciation and get your 4.2 DVD |
| David Pottage | Re: My experience with the Freerunner |
| "Marco Trevisan (Treviño)" | Re: Car charger to GTA02 |
| Neng-Yu Tu (Tony Tu) | GTA02 GPS rework for SD card interference issue |
| Christ van Willegen | Public build host (proposal) |
| Linux Bootup hangs after adding RealTime Premption and HR-Timer | 2 minutes ago | Linux kernel |
| SATA 2 size problems | 1 hour ago | Windows |
| problem with 2.6 kernel driver for a USB MAG Stripe Reader as HID device. | 13 hours ago | Linux kernel |
| get_user_pages failure | 15 hours ago | Linux kernel |
| Reading linux kernel | 16 hours ago | Linux kernel |
| High level of Seagate 2.5" SATA drives failing | 22 hours ago | Hardware |
| Resetting the bios password for Toshiba Laptop | 1 day ago | Hardware |
| Linux 2.6.22 slowly RUNS OUT OF LOWMEM | 1 day ago | Linux kernel |
| Questions about modules | 1 day ago | Linux kernel |
| KDB | 2 days ago | Linux kernel |
