This fixes the below crash that arises due to not handling page table allocation
failures while allocating hugetlb page table.
Fixes: e2b3d202d1db ("powerpc: Switch 16GB and 16MB explicit hugepages to a different page table format")
Signed-off-by: Aneesh Kumar K.V <redacted>
---
arch/powerpc/mm/hugetlbpage.c | 8 ++++++++
1 file changed, 8 insertions(+)
We only check for hugetlb allocations, because with hugetlb we do conditional
registration. For PGD/PUD/PMD levels we register them always in
pgtable_cache_init.
Signed-off-by: Aneesh Kumar K.V <redacted>
---
arch/powerpc/mm/hugetlbpage.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
This makes sure we don't enable HugeTLB if the cache is not configured.
I am still not sure about this. IMHO hugetlb support should be a hardware
support derivative and any cache allocation failure should be handled as I did
in the earlier patch. But then if we were not able to create hugetlb page table
cache, we can as well declare hugetlb support disabled thereby avoiding calling
into allocation routines.
Signed-off-by: Aneesh Kumar K.V <redacted>
---
arch/powerpc/mm/hugetlbpage.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
@@ -602,6 +602,7 @@ __setup("hugepagesz=", hugepage_setup_sz);staticint__inithugetlbpage_init(void){intpsize;+boolconfigured=false;if(hugetlb_disabled){pr_info("HugeTLB support is disabled!\n");
@@ -651,10 +652,16 @@ static int __init hugetlbpage_init(void)pgtable_cache_add(pdshift-shift);elseif(IS_ENABLED(CONFIG_PPC_FSL_BOOK3E)||IS_ENABLED(CONFIG_PPC_8xx))pgtable_cache_add(PTE_T_ORDER);++if(!configured)+configured=true;}-if(IS_ENABLED(CONFIG_HUGETLB_PAGE_SIZE_VARIABLE))-hugetlbpage_init_default();+if(configured){+if(IS_ENABLED(CONFIG_HUGETLB_PAGE_SIZE_VARIABLE))+hugetlbpage_init_default();+}else+pr_info("Disabling HugeTLB");return0;}
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-05-16 14:48:31
"Aneesh Kumar K.V" [off-list ref] writes:
quoted hunk
This makes sure we don't enable HugeTLB if the cache is not configured.
I am still not sure about this. IMHO hugetlb support should be a hardware
support derivative and any cache allocation failure should be handled as I did
in the earlier patch. But then if we were not able to create hugetlb page table
cache, we can as well declare hugetlb support disabled thereby avoiding calling
into allocation routines.
Signed-off-by: Aneesh Kumar K.V <redacted>
---
arch/powerpc/mm/hugetlbpage.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
if (hugetlb_disabled) {
pr_info("HugeTLB support is disabled!\n");
@@ -651,10 +652,16 @@ static int __init hugetlbpage_init(void) pgtable_cache_add(pdshift - shift); else if (IS_ENABLED(CONFIG_PPC_FSL_BOOK3E) || IS_ENABLED(CONFIG_PPC_8xx)) pgtable_cache_add(PTE_T_ORDER);++ if (!configured)+ configured = true;
I'd just not worry about the if.
}
- if (IS_ENABLED(CONFIG_HUGETLB_PAGE_SIZE_VARIABLE))
- hugetlbpage_init_default();
+ if (configured) {
+ if (IS_ENABLED(CONFIG_HUGETLB_PAGE_SIZE_VARIABLE))
+ hugetlbpage_init_default();
+ } else
+ pr_info("Disabling HugeTLB");
We're not actually doing anything to disable it in the
CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=n case, but I guess the print is still
correct because we didn't enable a size in the for loop above?
Can we make it a bit more explicit? Maybe like:
"Disabling HugeTLB, no usable page sizes found."
??
cheers
This makes sure we don't enable HugeTLB if the cache is not configured.
I am still not sure about this. IMHO hugetlb support should be a hardware
support derivative and any cache allocation failure should be handled as I did
in the earlier patch. But then if we were not able to create hugetlb page table
cache, we can as well declare hugetlb support disabled thereby avoiding calling
into allocation routines.
Signed-off-by: Aneesh Kumar K.V <redacted>
---
arch/powerpc/mm/hugetlbpage.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
if (hugetlb_disabled) {
pr_info("HugeTLB support is disabled!\n");
@@ -651,10 +652,16 @@ static int __init hugetlbpage_init(void) pgtable_cache_add(pdshift - shift); else if (IS_ENABLED(CONFIG_PPC_FSL_BOOK3E) || IS_ENABLED(CONFIG_PPC_8xx)) pgtable_cache_add(PTE_T_ORDER);++ if (!configured)+ configured = true;
I'd just not worry about the if.
quoted
}
- if (IS_ENABLED(CONFIG_HUGETLB_PAGE_SIZE_VARIABLE))
- hugetlbpage_init_default();
+ if (configured) {
+ if (IS_ENABLED(CONFIG_HUGETLB_PAGE_SIZE_VARIABLE))
+ hugetlbpage_init_default();
+ } else
+ pr_info("Disabling HugeTLB");
We're not actually doing anything to disable it in the
CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=n case, but I guess the print is still
correct because we didn't enable a size in the for loop above?
Can we make it a bit more explicit? Maybe like:
"Disabling HugeTLB, no usable page sizes found."
This makes sure we don't enable HugeTLB if the cache is not configured.
I am still not sure about this. IMHO hugetlb support should be a
hardware
support derivative and any cache allocation failure should be handled
as I did
in the earlier patch. But then if we were not able to create hugetlb
page table
cache, we can as well declare hugetlb support disabled thereby
avoiding calling
into allocation routines.
Signed-off-by: Aneesh Kumar K.V <redacted>
---
arch/powerpc/mm/hugetlbpage.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/mm/hugetlbpage.c
b/arch/powerpc/mm/hugetlbpage.c
index ee16a3fb788a..4bf8bc659cc7 100644
static int __init hugetlbpage_init(void)
{
int psize;
+ bool configured = false;
Where's my reverse Christmas tree! :)
Will fix that :)
quoted
quoted
if (hugetlb_disabled) {
pr_info("HugeTLB support is disabled!\n");
@@ -651,10 +652,16 @@ static int __init hugetlbpage_init(void)
pgtable_cache_add(pdshift - shift);
else if (IS_ENABLED(CONFIG_PPC_FSL_BOOK3E) ||
IS_ENABLED(CONFIG_PPC_8xx))
pgtable_cache_add(PTE_T_ORDER);
+
+ if (!configured)
+ configured = true;
I'd just not worry about the if.
quoted
}
- if (IS_ENABLED(CONFIG_HUGETLB_PAGE_SIZE_VARIABLE))
- hugetlbpage_init_default();
+ if (configured) {
+ if (IS_ENABLED(CONFIG_HUGETLB_PAGE_SIZE_VARIABLE))
+ hugetlbpage_init_default();
+ } else
+ pr_info("Disabling HugeTLB");
We're not actually doing anything to disable it in the
CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=n case, but I guess the print is still
correct because we didn't enable a size in the for loop above?
Can we make it a bit more explicit? Maybe like:
"Disabling HugeTLB, no usable page sizes found."
There is another failure condition which i am not sure how to handle
with the pagetable cache creation failures. With above, if we had kernel
command line hugepagesz=x hugepages=y, and if that x is a gigantic
hugepage, we will allocate those pages early even if we don't support
hugetlb because we failed to create page table cache.
I am not sure whether we should handle that error gracefully?
-aneesh
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-05-17 11:13:44
"Aneesh Kumar K.V" [off-list ref] writes:
On 5/16/19 8:17 PM, Michael Ellerman wrote:
quoted
"Aneesh Kumar K.V" [off-list ref] writes:
quoted
This makes sure we don't enable HugeTLB if the cache is not configured.
I am still not sure about this. IMHO hugetlb support should be a hardware
support derivative and any cache allocation failure should be handled as I did
in the earlier patch. But then if we were not able to create hugetlb page table
cache, we can as well declare hugetlb support disabled thereby avoiding calling
into allocation routines.
Signed-off-by: Aneesh Kumar K.V <redacted>
---
arch/powerpc/mm/hugetlbpage.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
@@ -651,10 +652,16 @@ static int __init hugetlbpage_init(void)- if (IS_ENABLED(CONFIG_HUGETLB_PAGE_SIZE_VARIABLE))- hugetlbpage_init_default();+ if (configured) {+ if (IS_ENABLED(CONFIG_HUGETLB_PAGE_SIZE_VARIABLE))+ hugetlbpage_init_default();+ } else+ pr_info("Disabling HugeTLB");
We're not actually doing anything to disable it in the
CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=n case, but I guess the print is still
correct because we didn't enable a size in the for loop above?
Can we make it a bit more explicit? Maybe like:
"Disabling HugeTLB, no usable page sizes found."