powerpc/mm: Implemented default_hugepagesz verification for powerpc
PATCH 1/1 powerpc/mm: Implemented default_hugepagesz verification for powerpc
Implemented default hugepage size verification (default_hugepagesz=) in order to allow allocation of defined number of pages (hugepages=) only for supported hugepage sizes.
--- arch/powerpc/mm/hugetlbpage.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/powerpc/mm/hugetlbpage.c +15 -0
@@ -797,6 +797,21 @@ static int __init hugepage_setup_sz(char *str) }__setup ("hugepagesz=" , hugepage_setup_sz); +static int __init default_hugepage_setup_sz (char *str) +{ +unsigned long long size; + + size =memparse (str, &str); + +if (add_huge_page_size (size) !=0 ) { +hugetlb_bad_size (); +pr_err ("Invalid default huge page size specified(%llu)\n" , size); + } + +return 1 ; +} +__setup ("default_hugepagesz=" , default_hugepage_setup_sz); +struct kmem_cache *hugepte_cache;static int __init hugetlbpage_init (void ) {
Signature · 1 line
1.8.3.1
Quoted 21 lines · Victor Aoqui
Implemented default hugepage size verification (default_hugepagesz=) in order to allow allocation of defined number of pages (hugepages=) only for supported hugepage sizes.
Signed-off-by Victor Aoqui <[email protected]>--- arch/powerpc/mm/hugetlbpage.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)arch/powerpc/mm/hugetlbpage.c +4
-0@@ -797,6 +797,21 @@ static int __init hugepage_setup_sz(char *str) }__setup ("hugepagesz=" , hugepage_setup_sz); +static int __init default_hugepage_setup_sz (char *str) +{ +unsigned long long size; +
arch/powerpc/mm/hugetlbpage.c static int __init hugepage_setup_sz(char *str) · line 813
Quoted 10 lines
arch/powerpc/mm/hugetlbpage.c +10
-0+ size =memparse (str, &str); + +if (add_huge_page_size (size) !=0 ) { +hugetlb_bad_size (); +pr_err ("Invalid default huge page size specified(%llu)\n" , size); + } + +return 1 ; +} +__setup ("default_hugepagesz=" , default_hugepage_setup_sz);
isn't that a behavior change in what we have now ? . Right now if size specified is not supported, we fallback to HPAGE_SIZE.
mm/hugetlb.c
if (!size_to_hstate(default_hstate_size)) {
default_hstate_size = HPAGE_SIZE;
if (!size_to_hstate(default_hstate_size))
hugetlb_add_hstate(HUGETLB_PAGE_ORDER);
}arch/powerpc/mm/hugetlbpage.c static int __init hugepage_setup_sz(char *str) · line 817
Quoted 5 lines
arch/powerpc/mm/hugetlbpage.c +1
-0+struct kmem_cache *hugepte_cache;static int __init hugetlbpage_init (void ) {
Even if we want to do this, this should be done in generic code and should not be powerpc specific
-aneesh
Em 2017-07-05 01:26, Aneesh Kumar K.V escreveu:
Quoted 28 lines · Victor Aoqui
Quoted 27 lines
Implemented default hugepage size verification (default_hugepagesz=) in order to allow allocation of defined number of pages (hugepages=) only for supported hugepage sizes.
Signed-off-by Victor Aoqui <[email protected]>--- arch/powerpc/mm/hugetlbpage.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)arch/powerpc/mm/hugetlbpage.c +9
-0@@ -797,6 +797,21 @@ static int __init hugepage_setup_sz(char *str) }__setup ("hugepagesz=" , hugepage_setup_sz); +static int __init default_hugepage_setup_sz(char *str) +{ + unsigned long long size; + + size = memparse(str, &str); + + if (add_huge_page_size(size) != 0) { + hugetlb_bad_size(); + pr_err("Invalid default huge page size specified(%llu)\n", size);
Quoted 8 lines
arch/powerpc/mm/hugetlbpage.c static int __init hugepage_setup_sz(char *str) · line 813
Quoted 5 lines
arch/powerpc/mm/hugetlbpage.c +5
-0+ } + +return 1 ; +} +__setup ("default_hugepagesz=" , default_hugepage_setup_sz);isn't that a behavior change in what we have now ? . Right now if size specified is not supported, we fallback to
HPAGE_SIZE.
Yes, it is. However, is this a correct behavior? If we specify an unsupported value, for example default_hugepagesz=1M and hugepages=1000, 1M will be ignored and 1000 pages of 16M (arch default) will be allocated. This could lead to non-expected out of of memory/performance issue.
Quoted 10 lines
mm/hugetlb.cif (!size_to_hstate(default_hstate_size)) { default_hstate_size = HPAGE_SIZE; if (!size_to_hstate(default_hstate_size)) hugetlb_add_hstate(HUGETLB_PAGE_ORDER); }
Quoted 9 lines
Quoted 5 lines
arch/powerpc/mm/hugetlbpage.c +1
-0+struct kmem_cache *hugepte_cache;static int __init hugetlbpage_init (void ){Even if we want to do this, this should be done in generic code and should not be powerpc specific
The verification of supported powerpc hugepage size (hugepagesz=) is being performed on add_huge_page_size(), which is currently defined in arch/powerpc/mm/hugetlbpage.c. I think it makes more sense to implement default_hugepagesz= verification on arch/powerpc, don't you think?
Quoted 1 line
-aneesh
Em 2017-07-05 13:03, victora escreveu:
Quoted 64 lines
Em 2017-07-05 01:26, Aneesh Kumar K.V escreveu:
Quoted 28 lines · Victor Aoqui
Quoted 27 lines
Implemented default hugepage size verification (default_hugepagesz=) in order to allow allocation of defined number of pages (hugepages=) only for supported hugepage sizes.
Signed-off-by Victor Aoqui <[email protected]>--- arch/powerpc/mm/hugetlbpage.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)arch/powerpc/mm/hugetlbpage.c +9
-0@@ -797,6 +797,21 @@ static int __init hugepage_setup_sz(char *str) }__setup ("hugepagesz=" , hugepage_setup_sz); +static int __init default_hugepage_setup_sz(char *str) +{ + unsigned long long size; + + size = memparse(str, &str); + + if (add_huge_page_size(size) != 0) { + hugetlb_bad_size(); + pr_err("Invalid default huge page size specified(%llu)\n", size);Quoted 8 lines
arch/powerpc/mm/hugetlbpage.c static int __init hugepage_setup_sz(char *str) · line 813
Quoted 5 lines
arch/powerpc/mm/hugetlbpage.c +5
-0+ } + +return 1 ; +} +__setup ("default_hugepagesz=" , default_hugepage_setup_sz);isn't that a behavior change in what we have now ? . Right now if size specified is not supported, we fallback to
HPAGE_SIZE.Yes, it is. However, is this a correct behavior? If we specify an unsupported value, for example default_hugepagesz=1M and hugepages=1000, 1M will be ignored and 1000 pages of 16M (arch default) will be allocated. This could lead to non-expected out of of memory/performance issue.
Quoted 10 lines
mm/hugetlb.cif (!size_to_hstate(default_hstate_size)) { default_hstate_size = HPAGE_SIZE; if (!size_to_hstate(default_hstate_size)) hugetlb_add_hstate(HUGETLB_PAGE_ORDER); }Quoted 9 lines
Quoted 5 lines
arch/powerpc/mm/hugetlbpage.c +1
-0+struct kmem_cache *hugepte_cache;static int __init hugetlbpage_init (void ){Even if we want to do this, this should be done in generic code and should not be powerpc specific
Quoted 7 lines
The verification of supported powerpc hugepage size (hugepagesz=) is being performed on
add_huge_page_size(), which is currently defined inarch/powerpc/mm/hugetlbpage.c. I think it makes more sense to implement default_hugepagesz= verification onarch/powerpc, don't you think?Quoted 1 line
-aneesh
Hi Aneesh,
Did you have time to review the comments above?
Thanks
Victor
Quoted 14 lines · Victor Aoqui
Implemented default hugepage size verification (default_hugepagesz=) in order to allow allocation of defined number of pages (hugepages=) only for supported hugepage sizes.
Signed-off-by Victor Aoqui <[email protected]>--- arch/powerpc/mm/hugetlbpage.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)arch/powerpc/mm/hugetlbpage.c +0
-0
arch/powerpc/mm/hugetlbpage.c static int __init hugepage_setup_sz(char *str) · line 800
Quoted 4 lines
arch/powerpc/mm/hugetlbpage.c +1
-0@@ -797,6 +797,21 @@ static int __init hugepage_setup_sz(char *str) }__setup ("hugepagesz=" , hugepage_setup_sz); +static int __init default_hugepage_setup_sz (char *str)
The function name should be hugetlb_default_size_setup in sync with the generic function hugetlb_default_setup for the same parameter default_hugepagesz.
arch/powerpc/mm/hugetlbpage.c static int __init hugepage_setup_sz(char *str) · line 806
Quoted 6 lines
arch/powerpc/mm/hugetlbpage.c +6
-0+{ +unsigned long long size; + + size =memparse (str, &str); + +if (add_huge_page_size (size) !=0 ) {
I am little bit confused here. Do we always follow another 'hugepages=' element after 'default_hugepagesz' ? If not, then we dont have to do 'add_huge_page_size'. But then that function checks for valid huge page sizes and skips adding hstate if its already added. So I guess it okay.
arch/powerpc/mm/hugetlbpage.c static int __init hugepage_setup_sz(char *str) · line 808
Quoted 2 lines
arch/powerpc/mm/hugetlbpage.c +2
-0+hugetlb_bad_size (); +pr_err ("Invalid default huge page size specified(%llu)\n" , size);
Error message should have 'ppc' some where to indicate that the arch rejected the size not core MM.
Em 2017-07-05 01:31, Anshuman Khandual escreveu:
Quoted 18 lines · Victor Aoqui
Quoted 17 lines
Implemented default hugepage size verification (default_hugepagesz=) in order to allow allocation of defined number of pages (hugepages=) only for supported hugepage sizes.
Signed-off-by Victor Aoqui <[email protected]>--- arch/powerpc/mm/hugetlbpage.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)arch/powerpc/mm/hugetlbpage.c +0
-0@@ -797,6 +797,21 @@ static int __init hugepage_setup_sz(char *str) }__setup ("hugepagesz=" , hugepage_setup_sz);
Quoted 6 lines
arch/powerpc/mm/hugetlbpage.c static int __init hugepage_setup_sz(char *str) · line 800
Quoted 1 line
arch/powerpc/mm/hugetlbpage.c +1
-0+static int __init default_hugepage_setup_sz (char *str)The function name should be
hugetlb_default_size_setupin sync with the generic functionhugetlb_default_setupfor the same parameterdefault_hugepagesz.
Yes, makes sense to me.
Quoted 4 lines
Quoted 4 lines
arch/powerpc/mm/hugetlbpage.c +4
-0+{ +unsigned long long size; + + size =memparse (str, &str);
Quoted 9 lines
arch/powerpc/mm/hugetlbpage.c static int __init hugepage_setup_sz(char *str) · line 806
Quoted 2 lines
arch/powerpc/mm/hugetlbpage.c +2
-0+ +if (add_huge_page_size (size) !=0 ) {I am little bit confused here. Do we always follow another 'hugepages=' element after '
default_hugepagesz' ? If not, then we dont have to do 'add_huge_page_size'. But then that function checks for valid huge page sizes and skips adding hstate if its already added. So I guess it okay.
'default_hugepagesz=' is not always followed by 'hugepages=', but if we specify 'hugepages=' along with 'default_hugepagesz=' it will try to allocate the hugepage size specified. If the size is not supported by hardware, it will try to allocate the number of pages specified with the default hugepage size of the arch, which is not the desired behavior. So calling add_huge_page_size would verify if the hugepage size is supported and in case it's not, hugepages will not be allocated.
Quoted 6 lines
arch/powerpc/mm/hugetlbpage.c static int __init hugepage_setup_sz(char *str) · line 809
Quoted 3 lines
arch/powerpc/mm/hugetlbpage.c +2
-0+hugetlb_bad_size (); + pr_err("Invalid default huge page size specified(%llu)\n", size);Error message should have 'ppc' some where to indicate that the arch rejected the size not core MM.