[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1392339728-13487-4-git-send-email-lcapitulino@redhat.com>
Date: Thu, 13 Feb 2014 20:02:07 -0500
From: Luiz Capitulino <lcapitulino@...hat.com>
To: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
mtosatti@...hat.com, mgorman@...e.de, aarcange@...hat.com,
andi@...stfloor.org, riel@...hat.com, davidlohr@...com,
isimatu.yasuaki@...fujitsu.com, yinghai@...nel.org,
rientjes@...gle.com
Subject: [PATCH 3/4] hugetlb: add parse_pagesize_str()
From: Luiz capitulino <lcapitulino@...hat.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@...hat.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists