mm/hugetlb: Make __NR_USED_SUBPAGE check conditional
Subsystems (2)
PATCH v2 1/1 mm/hugetlb: Make __NR_USED_SUBPAGE check conditional
The HugeTLB order check against __NR_USED_SUBPAGE is required only when HUGETLB_PAGE_OPTIMIZE_VMEMMAP is enabled. Hence BUG_ON() trigger should happen only when applicable.
---
This patch applies on v6.13-rc1
Changes in V2:
- Fixed #ifdef with CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP per Oscar
Changes in V1:
https://lore.kernel.org/all/[email protected]/
mm/hugetlb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/hugetlb.c +4 -2
@@ -4513,11 +4513,13 @@ void __init hugetlb_add_hstate(unsigned int order)struct hstate *h;unsigned long i; -if (size_to_hstate (PAGE_SIZE << order)) { +if (size_to_hstate (PAGE_SIZE << order))return ; - } +BUG_ON (hugetlb_max_hstate >=HUGE_MAX_HSTATE ); +#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP BUG_ON (order <order_base_2 (__NR_USED_SUBPAGE)); +#endif h = &hstates[hugetlb_max_hstate++];__mutex_init (&h->resize_lock,"resize mutex" , &h->resize_key); h->order = order;
Signature · 1 line
2.30.2
Muchun Song
maintainerQuoted 34 lines · Anshuman Khandual
The HugeTLB order check against
__NR_USED_SUBPAGEis required only whenHUGETLB_PAGE_OPTIMIZE_VMEMMAPis enabled. HenceBUG_ON()trigger should happen only when applicable.Cc Muchun Song <[email protected]>Cc Andrew Morton <[email protected]>Cc Oscar Salvador <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
This patch applies on v6.13-rc1Changes in V2:
- Fixed #ifdef with
CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAPper OscarChanges in V1:
https://lore.kernel.org/all/[email protected]/
mm/hugetlb.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)mm/hugetlb.c +0
-0@@ -4513,11 +4513,13 @@ void __init hugetlb_add_hstate(unsigned int order)struct hstate *h;
mm/hugetlb.c void __init hugetlb_add_hstate(unsigned int order) · line 4521
Quoted 10 lines
mm/hugetlb.c +3
-2unsigned long i; -if (size_to_hstate (PAGE_SIZE << order)) { +if (size_to_hstate (PAGE_SIZE << order))return ; - } +BUG_ON (hugetlb_max_hstate >=HUGE_MAX_HSTATE ); +#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP BUG_ON (order <order_base_2 (__NR_USED_SUBPAGE));
Hi Anshuman,
__NR_USED_SUBPAGE indicates how many struct pages are used to store extra metadata for a HugeTLB page. So we need to make sure the order of a HugeTLB page should be bigger than or equal to order_base_2(__NR_USED_SUBPAGE). So It is not related to HVO. I don't think the changes make sense.
Thanks.
Quoted 7 lines
mm/hugetlb.c +1
-0+#endif h = &hstates[hugetlb_max_hstate++];__mutex_init (&h->resize_lock,"resize mutex" , &h->resize_key); h->order = order;Signature · 1 line
2.30.2
Quoted 47 lines · Muchun Song
Quoted 34 lines · Anshuman Khandual
The HugeTLB order check against
__NR_USED_SUBPAGEis required only whenHUGETLB_PAGE_OPTIMIZE_VMEMMAPis enabled. HenceBUG_ON()trigger should happen only when applicable.Cc Muchun Song <[email protected]>Cc Andrew Morton <[email protected]>Cc Oscar Salvador <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
This patch applies on v6.13-rc1Changes in V2:
- Fixed #ifdef with
CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAPper OscarChanges in V1:
https://lore.kernel.org/all/[email protected]/
mm/hugetlb.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)mm/hugetlb.c +0
-0@@ -4513,11 +4513,13 @@ void __init hugetlb_add_hstate(unsigned int order)struct hstate *h;mm/hugetlb.c void __init hugetlb_add_hstate(unsigned int order) · line 4521
Quoted 10 lines
mm/hugetlb.c +3
-2unsigned long i; -if (size_to_hstate (PAGE_SIZE << order)) { +if (size_to_hstate (PAGE_SIZE << order))return ; - } +BUG_ON (hugetlb_max_hstate >=HUGE_MAX_HSTATE ); +#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP BUG_ON (order <order_base_2 (__NR_USED_SUBPAGE));Hi Anshuman,
Quoted 4 lines
__NR_USED_SUBPAGEindicates how many struct pages are used to store extra metadata for a HugeTLB page. So we need to make sure the order of a HugeTLB page should be bigger than or equal toorder_base_2(__NR_USED_SUBPAGE). So It is not related to HVO. I don't think the changes make sense.
I did think about that but order_base_2(__NR_USED_SUBPAGE) actually turns out to be just 2 as __NR_USED_SUBPAGE is 3. Would not HugeTLB size be always greater than four base pages in reality, thus making this BUG_ON() check just redundant ?
Quoted 11 lines
Thanks.
Quoted 7 lines
mm/hugetlb.c +1
-0+#endif h = &hstates[hugetlb_max_hstate++];__mutex_init (&h->resize_lock,"resize mutex" , &h->resize_key); h->order = order;Signature · 1 line
2.30.2
Muchun Song
maintainerQuoted 58 lines · Anshuman Khandual
Quoted 47 lines · Muchun Song
Quoted 34 lines · Anshuman Khandual
The HugeTLB order check against
__NR_USED_SUBPAGEis required only whenHUGETLB_PAGE_OPTIMIZE_VMEMMAPis enabled. HenceBUG_ON()trigger should happen only when applicable.Cc Muchun Song <[email protected]>Cc Andrew Morton <[email protected]>Cc Oscar Salvador <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
This patch applies on v6.13-rc1Changes in V2:
- Fixed #ifdef with
CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAPper OscarChanges in V1:
https://lore.kernel.org/all/[email protected]/
mm/hugetlb.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)mm/hugetlb.c +0
-0@@ -4513,11 +4513,13 @@ void __init hugetlb_add_hstate(unsigned int order)struct hstate *h;mm/hugetlb.c void __init hugetlb_add_hstate(unsigned int order) · line 4521
Quoted 10 lines
mm/hugetlb.c +3
-2unsigned long i; -if (size_to_hstate (PAGE_SIZE << order)) { +if (size_to_hstate (PAGE_SIZE << order))return ; - } +BUG_ON (hugetlb_max_hstate >=HUGE_MAX_HSTATE ); +#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP BUG_ON (order <order_base_2 (__NR_USED_SUBPAGE));Hi Anshuman,
Quoted 4 lines
__NR_USED_SUBPAGEindicates how many struct pages are used to store extra metadata for a HugeTLB page. So we need to make sure the order of a HugeTLB page should be bigger than or equal toorder_base_2(__NR_USED_SUBPAGE). So It is not related to HVO. I don't think the changes make sense.
Quoted 4 lines
I did think about that but
order_base_2(__NR_USED_SUBPAGE)actually turns out to be just 2 as__NR_USED_SUBPAGEis 3. Would not HugeTLB size be always greater than four base pages in reality, thus making thisBUG_ON()check just redundant ?
Currently, there is no architectures supporting hugetlb page smaller than 4 base pages. I think the smallest size is 64KB in arm64, but who knows whether if certain architectures supports 8KB in the future or we want to uses more struct pages to store metadata for increasing __NR_USED_SUBPAGE (e.g. change it to 17). So I tend to keep this BUG_ON remain to catch unexpected bugs.
Thanks.
Quoted 12 lines
Quoted 12 lines
Thanks.
Quoted 7 lines
mm/hugetlb.c +1
-0+#endif h = &hstates[hugetlb_max_hstate++];__mutex_init (&h->resize_lock,"resize mutex" , &h->resize_key); h->order = order;Signature · 1 line
2.30.2
Quoted 63 lines · Muchun Song
Quoted 58 lines · Anshuman Khandual
Quoted 47 lines · Muchun Song
Quoted 34 lines · Anshuman Khandual
The HugeTLB order check against
__NR_USED_SUBPAGEis required only whenHUGETLB_PAGE_OPTIMIZE_VMEMMAPis enabled. HenceBUG_ON()trigger should happen only when applicable.Cc Muchun Song <[email protected]>Cc Andrew Morton <[email protected]>Cc Oscar Salvador <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
This patch applies on v6.13-rc1Changes in V2:
- Fixed #ifdef with
CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAPper OscarChanges in V1:
https://lore.kernel.org/all/[email protected]/
mm/hugetlb.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)mm/hugetlb.c +0
-0@@ -4513,11 +4513,13 @@ void __init hugetlb_add_hstate(unsigned int order)struct hstate *h;mm/hugetlb.c void __init hugetlb_add_hstate(unsigned int order) · line 4521
Quoted 10 lines
mm/hugetlb.c +3
-2unsigned long i; -if (size_to_hstate (PAGE_SIZE << order)) { +if (size_to_hstate (PAGE_SIZE << order))return ; - } +BUG_ON (hugetlb_max_hstate >=HUGE_MAX_HSTATE ); +#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP BUG_ON (order <order_base_2 (__NR_USED_SUBPAGE));Hi Anshuman,
Quoted 4 lines
__NR_USED_SUBPAGEindicates how many struct pages are used to store extra metadata for a HugeTLB page. So we need to make sure the order of a HugeTLB page should be bigger than or equal toorder_base_2(__NR_USED_SUBPAGE). So It is not related to HVO. I don't think the changes make sense.Quoted 4 lines
I did think about that but
order_base_2(__NR_USED_SUBPAGE)actually turns out to be just 2 as__NR_USED_SUBPAGEis 3. Would not HugeTLB size be always greater than four base pages in reality, thus making thisBUG_ON()check just redundant ?
Quoted 6 lines
Currently, there is no architectures supporting hugetlb page smaller than 4 base pages. I think the smallest size is 64KB in arm64, but who knows whether if certain architectures supports 8KB in the future or we want to uses more struct pages to store metadata for increasing
__NR_USED_SUBPAGE(e.g. change it to 17). So I tend to keep thisBUG_ONremain to catch unexpected bugs.
Sure, fair enough.