[PATCH] [5/6] HUGETLB memory commitment

From: Andy Whitcroft <apw_at_shadowen.org>
Date: 2004-03-26 04:02:49
[075-mem_acctdom_hugetlb_arch]

Convert hugetlb to accounting domains (arch)

---
 i386/mm/hugetlbpage.c    |   16 +++++++++++++---
 ia64/mm/hugetlbpage.c    |   16 +++++++++++++---
 ppc64/mm/hugetlbpage.c   |   16 +++++++++++++---
 sparc64/mm/hugetlbpage.c |   16 +++++++++++++---
 4 files changed, 52 insertions(+), 12 deletions(-)

diff -upN reference/arch/i386/mm/hugetlbpage.c current/arch/i386/mm/hugetlbpage.c
--- reference/arch/i386/mm/hugetlbpage.c	2004-01-09 07:00:02.000000000 +0000
+++ current/arch/i386/mm/hugetlbpage.c	2004-03-25 15:03:27.000000000 +0000
@@ -15,7 +15,7 @@
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/sysctl.h>
-#include <asm/mman.h>
+#include <linux/mman.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
@@ -513,13 +513,17 @@ module_init(hugetlb_init);
 
 int hugetlb_report_meminfo(char *buf)
 {
+	int committed = atomic_read(&vm_committed_space[VM_AD_HUGETLB]);
+#define K(x) ((x) << (PAGE_SHIFT - 10))
 	return sprintf(buf,
 			"HugePages_Total: %5lu\n"
 			"HugePages_Free:  %5lu\n"
-			"Hugepagesize:    %5lu kB\n",
+			"Hugepagesize:    %5lu kB\n"
+			"HugeCommited_AS: %8u kB\n",
 			htlbzone_pages,
 			htlbpagemem,
-			HPAGE_SIZE/1024);
+			HPAGE_SIZE/1024,
+			K(committed));
 }
 
 int is_hugepage_mem_enough(size_t size)
@@ -527,6 +531,12 @@ int is_hugepage_mem_enough(size_t size)
 	return (size + ~HPAGE_MASK)/HPAGE_SIZE <= htlbpagemem;
 }
 
+/* Return the number pages of memory we physically have, in PAGE_SIZE units. */
+unsigned long hugetlb_total_pages(void)
+{
+	return htlbzone_pages * (HPAGE_SIZE / PAGE_SIZE);
+}
+
 /*
  * We cannot handle pagefaults against hugetlb pages at all.  They cause
  * handle_mm_fault() to try to instantiate regular-sized pages in the
diff -upN reference/arch/ia64/mm/hugetlbpage.c current/arch/ia64/mm/hugetlbpage.c
--- reference/arch/ia64/mm/hugetlbpage.c	2004-03-11 20:47:12.000000000 +0000
+++ current/arch/ia64/mm/hugetlbpage.c	2004-03-25 15:03:27.000000000 +0000
@@ -17,7 +17,7 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/sysctl.h>
-#include <asm/mman.h>
+#include <linux/mman.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
@@ -576,13 +576,17 @@ __initcall(hugetlb_init);
 
 int hugetlb_report_meminfo(char *buf)
 {
+	int committed = atomic_read(&vm_committed_space[VM_AD_HUGETLB]);
+#define K(x) ((x) << (PAGE_SHIFT - 10))
 	return sprintf(buf,
 			"HugePages_Total: %5lu\n"
 			"HugePages_Free:  %5lu\n"
-			"Hugepagesize:    %5lu kB\n",
+			"Hugepagesize:    %5lu kB\n"
+			"HugeCommited_AS: %8u kB\n",
 			htlbzone_pages,
 			htlbpagemem,
-			HPAGE_SIZE/1024);
+			HPAGE_SIZE/1024,
+			K(committed));
 }
 
 int is_hugepage_mem_enough(size_t size)
@@ -592,6 +596,12 @@ int is_hugepage_mem_enough(size_t size)
 	return 1;
 }
 
+/* Return the number pages of memory we physically have, in PAGE_SIZE units. */
+unsigned long hugetlb_total_pages(void)
+{
+	return htlbzone_pages * (HPAGE_SIZE / PAGE_SIZE);
+}
+
 static struct page *hugetlb_nopage(struct vm_area_struct * area, unsigned long address, int *unused)
 {
 	BUG();
diff -upN reference/arch/ppc64/mm/hugetlbpage.c current/arch/ppc64/mm/hugetlbpage.c
--- reference/arch/ppc64/mm/hugetlbpage.c	2004-03-11 20:47:14.000000000 +0000
+++ current/arch/ppc64/mm/hugetlbpage.c	2004-03-25 15:03:27.000000000 +0000
@@ -17,7 +17,7 @@
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/sysctl.h>
-#include <asm/mman.h>
+#include <linux/mman.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
@@ -896,13 +896,17 @@ module_init(hugetlb_init);
 
 int hugetlb_report_meminfo(char *buf)
 {
+	int committed = atomic_read(&vm_committed_space[VM_AD_HUGETLB]);
+#define K(x) ((x) << (PAGE_SHIFT - 10))
 	return sprintf(buf,
 			"HugePages_Total: %5d\n"
 			"HugePages_Free:  %5d\n"
-			"Hugepagesize:    %5lu kB\n",
+			"Hugepagesize:    %5lu kB\n"
+			"HugeCommited_AS: %8u kB",
 			htlbpage_total,
 			htlbpage_free,
-			HPAGE_SIZE/1024);
+			HPAGE_SIZE/1024,
+			K(commited));
 }
 
 /* This is advisory only, so we can get away with accesing
@@ -912,6 +916,12 @@ int is_hugepage_mem_enough(size_t size)
 	return (size + ~HPAGE_MASK)/HPAGE_SIZE <= htlbpage_free;
 }
 
+/* Return the number pages of memory we physically have, in PAGE_SIZE units. */
+int hugetlb_total_pages(void)
+{
+	return htlbpage_total * (HPAGE_SIZE / PAGE_SIZE);
+}
+
 /*
  * We cannot handle pagefaults against hugetlb pages at all.  They cause
  * handle_mm_fault() to try to instantiate regular-sized pages in the
diff -upN reference/arch/sparc64/mm/hugetlbpage.c current/arch/sparc64/mm/hugetlbpage.c
--- reference/arch/sparc64/mm/hugetlbpage.c	2004-01-09 06:59:45.000000000 +0000
+++ current/arch/sparc64/mm/hugetlbpage.c	2004-03-25 15:03:27.000000000 +0000
@@ -13,8 +13,8 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/sysctl.h>
+#include <linux/mman.h>
 
-#include <asm/mman.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
@@ -483,13 +483,17 @@ module_init(hugetlb_init);
 
 int hugetlb_report_meminfo(char *buf)
 {
+	int committed = atomic_read(&vm_committed_space[VM_AD_HUGETLB]);
+#define K(x) ((x) << (PAGE_SHIFT - 10))
 	return sprintf(buf,
 			"HugePages_Total: %5lu\n"
 			"HugePages_Free:  %5lu\n"
-			"Hugepagesize:    %5lu kB\n",
+			"Hugepagesize:    %5lu kB\n"
+			"HugeCommited_AS: %8u kB\n",
 			htlbzone_pages,
 			htlbpagemem,
-			HPAGE_SIZE/1024);
+			HPAGE_SIZE/1024,
+			K(committed));
 }
 
 int is_hugepage_mem_enough(size_t size)
@@ -497,6 +501,12 @@ int is_hugepage_mem_enough(size_t size)
 	return (size + ~HPAGE_MASK)/HPAGE_SIZE <= htlbpagemem;
 }
 
+/* Return the number pages of memory we physically have, in PAGE_SIZE units. */
+int hugetlb_total_pages(void)
+{
+	return htlbzone_pages * (HPAGE_SIZE / PAGE_SIZE);
+}
+
 /*
  * We cannot handle pagefaults against hugetlb pages at all.  They cause
  * handle_mm_fault() to try to instantiate regular-sized pages in the

-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Thu Mar 25 12:31:02 2004

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:24 EST