Commit e11bfbfcb08ef4223b863799897c19cdf7c5bc00
Committed by
Linus Torvalds
1 parent
b4718e628d
Exists in
master
and in
7 other branches
hugetlb: override default huge page size
Allow configurations with the default huge page size which is different to the traditional HPAGE_SIZE size. The default huge page size is the one represented in the legacy /proc ABIs, SHM, and which is defaulted to when mounting hugetlbfs filesystems. This is implemented with a new kernel option default_hugepagesz=, which defaults to HPAGE_SIZE if not specified. Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 24 additions and 6 deletions Side-by-side Diff
Documentation/kernel-parameters.txt
... | ... | @@ -783,6 +783,13 @@ |
783 | 783 | CPU supports the "pdpe1gb" cpuinfo flag) |
784 | 784 | Note that 1GB pages can only be allocated at boot time |
785 | 785 | using hugepages= and not freed afterwards. |
786 | + default_hugepagesz= | |
787 | + [same as hugepagesz=] The size of the default | |
788 | + HugeTLB page size. This is the size represented by | |
789 | + the legacy /proc/ hugepages APIs, used for SHM, and | |
790 | + default size when mounting hugetlbfs filesystems. | |
791 | + Defaults to the default architecture's huge page size | |
792 | + if not specified. | |
786 | 793 | |
787 | 794 | i8042.direct [HW] Put keyboard port into non-translated mode |
788 | 795 | i8042.dumbkbd [HW] Pretend that controller can only read data from |
mm/hugetlb.c
... | ... | @@ -34,6 +34,7 @@ |
34 | 34 | /* for command line parsing */ |
35 | 35 | static struct hstate * __initdata parsed_hstate; |
36 | 36 | static unsigned long __initdata default_hstate_max_huge_pages; |
37 | +static unsigned long __initdata default_hstate_size; | |
37 | 38 | |
38 | 39 | #define for_each_hstate(h) \ |
39 | 40 | for ((h) = hstates; (h) < &hstates[max_hstate]; (h)++) |
40 | 41 | |
... | ... | @@ -1288,11 +1289,14 @@ |
1288 | 1289 | { |
1289 | 1290 | BUILD_BUG_ON(HPAGE_SHIFT == 0); |
1290 | 1291 | |
1291 | - if (!size_to_hstate(HPAGE_SIZE)) { | |
1292 | - hugetlb_add_hstate(HUGETLB_PAGE_ORDER); | |
1293 | - parsed_hstate->max_huge_pages = default_hstate_max_huge_pages; | |
1292 | + if (!size_to_hstate(default_hstate_size)) { | |
1293 | + default_hstate_size = HPAGE_SIZE; | |
1294 | + if (!size_to_hstate(default_hstate_size)) | |
1295 | + hugetlb_add_hstate(HUGETLB_PAGE_ORDER); | |
1294 | 1296 | } |
1295 | - default_hstate_idx = size_to_hstate(HPAGE_SIZE) - hstates; | |
1297 | + default_hstate_idx = size_to_hstate(default_hstate_size) - hstates; | |
1298 | + if (default_hstate_max_huge_pages) | |
1299 | + default_hstate.max_huge_pages = default_hstate_max_huge_pages; | |
1296 | 1300 | |
1297 | 1301 | hugetlb_init_hstates(); |
1298 | 1302 | |
... | ... | @@ -1332,7 +1336,7 @@ |
1332 | 1336 | parsed_hstate = h; |
1333 | 1337 | } |
1334 | 1338 | |
1335 | -static int __init hugetlb_setup(char *s) | |
1339 | +static int __init hugetlb_nrpages_setup(char *s) | |
1336 | 1340 | { |
1337 | 1341 | unsigned long *mhp; |
1338 | 1342 | static unsigned long *last_mhp; |
... | ... | @@ -1367,7 +1371,14 @@ |
1367 | 1371 | |
1368 | 1372 | return 1; |
1369 | 1373 | } |
1370 | -__setup("hugepages=", hugetlb_setup); | |
1374 | +__setup("hugepages=", hugetlb_nrpages_setup); | |
1375 | + | |
1376 | +static int __init hugetlb_default_setup(char *s) | |
1377 | +{ | |
1378 | + default_hstate_size = memparse(s, &s); | |
1379 | + return 1; | |
1380 | +} | |
1381 | +__setup("default_hugepagesz=", hugetlb_default_setup); | |
1371 | 1382 | |
1372 | 1383 | static unsigned int cpuset_mems_nr(unsigned int *array) |
1373 | 1384 | { |