lkml.org 
[lkml]   [2014]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/4] hugetlb: add parse_pagesize_str()
Date
From: Luiz capitulino <lcapitulino@redhat.com>

This commit moves current setup_hugepagez() logic to function called
parse_pagesize_str(), so that it can be used by the next commit.

There should be no functional changes, except for the following:

- When calling memparse(), setup_hugepagesz() was passing the retptr
argument, but the result was unused. So parse_pagesize_str() pass NULL
instead

- Change printk(KERN_ERR) to pr_err() and make the error message a little
bit nicer for bad command-lines like "hugepagesz=1X"

Signed-off-by: Luiz capitulino <lcapitulino@redhat.com>
---
arch/x86/mm/hugetlbpage.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
index 8c9f647..968db71 100644
--- a/arch/x86/mm/hugetlbpage.c
+++ b/arch/x86/mm/hugetlbpage.c
@@ -173,18 +173,31 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
#endif /* CONFIG_HUGETLB_PAGE */

#ifdef CONFIG_X86_64
-static __init int setup_hugepagesz(char *opt)
+static __init int parse_pagesize_str(char *str, unsigned *order)
{
- unsigned long ps = memparse(opt, &opt);
+ unsigned long ps = memparse(str, NULL);
if (ps == PMD_SIZE) {
- hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT);
+ *order = PMD_SHIFT - PAGE_SHIFT;
} else if (ps == PUD_SIZE && cpu_has_gbpages) {
- hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
+ *order = PUD_SHIFT - PAGE_SHIFT;
} else {
- printk(KERN_ERR "hugepagesz: Unsupported page size %lu M\n",
- ps >> 20);
+ /* invalid page size */
+ return -1;
+ }
+
+ return 0;
+}
+
+static __init int setup_hugepagesz(char *opt)
+{
+ unsigned order;
+
+ if (parse_pagesize_str(opt, &order)) {
+ pr_err("hugepagesz: Unsupported page size %s\n", opt);
return 0;
}
+
+ hugetlb_add_hstate(order);
return 1;
}
__setup("hugepagesz=", setup_hugepagesz);
--
1.8.1.4


\
 
 \ /
  Last update: 2014-02-14 03:41    [W:0.179 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site