mm: Override mTHP "enabled" defaults at kernel cmdline
Subsystems (4)
Ryan Roberts
reviewerPATCH v2 1/1 mm: Override mTHP "enabled" defaults at kernel cmdline
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
thp_anon=<size>[KMG]:<value>
See Documentation/admin-guide/mm/transhuge.rst for more details.
Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (275d686abcb59). (although I had to fix a minor build bug in stackdepot.c due to MIN() not being defined in this tree).
Thanks,
Ryan
.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +8 -0
@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.
Documentation/admin-guide/mm/transhuge.rst +20 -6
@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would block the collapse:: A higher value may increase memory footprint for some workloads. -Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always + +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``. Hugepages in tmpfs/shmem ========================
mm/huge_memory.c +54 -1
73 lines not on this page · raw message
--
2.43.0
Ryan Roberts
reviewerQuoted 13 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
Quoted 8 lines
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
Forgot to link the references, oops:
[1] https://lore.kernel.org/linux-mm/[email protected]/
[2] https://lore.kernel.org/linux-mm/CAGsJ_4wiZRP9siEk9WpAYRjj-gehxptGY9XWC8k3N4QHBppAhQ@mail.gmail.com/
Quoted 153 lines
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +8
-0@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +20
-6@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would block the collapse:: A higher value may increase memory footprint for some workloads. -Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always + +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``. Hugepages in tmpfs/shmem ========================mm/huge_memory.c +54
-2@@ -82,6 +82,7 @@ unsigned long huge_zero_pfn __read_mostly = ~0UL;unsigned long huge_anon_orders_always__read_mostly ;unsigned long huge_anon_orders_madvise__read_mostly ;unsigned long huge_anon_orders_inherit__read_mostly ; +static bool anon_orders_configured; unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, unsigned long vm_flags,@@ -672,7 +673,10 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)* disable all other sizes. powerpc's PMD_ORDER isn't a compile-time * constant so we have to do this here. */ - huge_anon_orders_inherit =BIT (PMD_ORDER ); +if (!anon_orders_configured) { + huge_anon_orders_inherit =BIT (PMD_ORDER ); + anon_orders_configured = true; + } *hugepage_kobj =kobject_create_and_add ("transparent_hugepage" , mm_kobj);if (unlikely (!*hugepage_kobj)) {@@ -857,6 +861,55 @@ static int __init setup_transparent_hugepage(char *str) }__setup ("transparent_hugepage=" , setup_transparent_hugepage); +static int __init setup_thp_anon (char *str) +{ +unsigned long size; +char *state; +int order; +int ret =0 ; + +if (!str) + goto out; + + size = (unsigned long )memparse (str, &state); + order =ilog2 (size >>PAGE_SHIFT ); +if (*state !=':' || !is_power_of_2 (size) || size <=PAGE_SIZE || + !(BIT (order) &THP_ORDERS_ALL_ANON )) + goto out; + + state++; + +if (!strcmp (state,"always" )) { +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_always); + ret =1 ; + }else if (!strcmp (state,"inherit" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_inherit); + ret =1 ; + }else if (!strcmp (state,"madvise" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +set_bit (order, &huge_anon_orders_madvise); + ret =1 ; + }else if (!strcmp (state,"never" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); + ret =1 ; + } + +if (ret) + anon_orders_configured = true; +out: +if (!ret) +pr_warn ("thp_anon=%s: cannot parse, ignored\n" , str); +return ret; +} +__setup ("thp_anon=" , setup_thp_anon); +pmd_t maybe_pmd_mkwrite (pmd_t pmd,struct vm_area_struct *vma) {if (likely (vma->vm_flags &VM_WRITE )) --2.43.0
Barry Song
reviewerQuoted 105 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +8
-0@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +20
-6@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would block the collapse:: A higher value may increase memory footprint for some workloads. -Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always + +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``. Hugepages in tmpfs/shmem ========================mm/huge_memory.c +1
-0@@ -82,6 +82,7 @@ unsigned long huge_zero_pfn __read_mostly = ~0UL;unsigned long huge_anon_orders_always__read_mostly ;unsigned long huge_anon_orders_madvise__read_mostly ;unsigned long huge_anon_orders_inherit__read_mostly ; +static bool anon_orders_configured; unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, unsigned long vm_flags,
mm/huge_memory.c static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj) · line 679
Quoted 8 lines
mm/huge_memory.c +4
-1@@ -672,7 +673,10 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)* disable all other sizes. powerpc's PMD_ORDER isn't a compile-time * constant so we have to do this here. */ - huge_anon_orders_inherit =BIT (PMD_ORDER ); +if (!anon_orders_configured) { + huge_anon_orders_inherit =BIT (PMD_ORDER ); + anon_orders_configured = true; + }
If a user configures 64KB and doesn't adjust anything for PMD_ORDER, then PMD_ORDER will be set to "never", correct? This seems to change the default behavior of PMD_ORDER. Could we instead achieve this by checking if PMD_ORDER has been explicitly configured?
Quoted 39 lines
mm/huge_memory.c +32
-0*hugepage_kobj =kobject_create_and_add ("transparent_hugepage" , mm_kobj);if (unlikely (!*hugepage_kobj)) {@@ -857,6 +861,55 @@ static int __init setup_transparent_hugepage(char *str) }__setup ("transparent_hugepage=" , setup_transparent_hugepage); +static int __init setup_thp_anon (char *str) +{ +unsigned long size; +char *state; +int order; +int ret =0 ; + +if (!str) + goto out; + + size = (unsigned long )memparse (str, &state); + order =ilog2 (size >>PAGE_SHIFT ); +if (*state !=':' || !is_power_of_2 (size) || size <=PAGE_SIZE || + !(BIT (order) &THP_ORDERS_ALL_ANON )) + goto out; + + state++; + +if (!strcmp (state,"always" )) { +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_always); + ret =1 ; + }else if (!strcmp (state,"inherit" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_inherit); + ret =1 ; + }else if (!strcmp (state,"madvise" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +set_bit (order, &huge_anon_orders_madvise);
mm/huge_memory.c static int __init setup_transparent_hugepage(char *str) · line 905
Quoted 10 lines
mm/huge_memory.c +10
-0+ ret =1 ; + }else if (!strcmp (state,"never" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); + ret =1 ; + } + +if (ret) + anon_orders_configured = true;
I mean:
if (ret && order == PMD_ORDER)
anon_pmd_order_configured = true;
Quoted 11 lines
mm/huge_memory.c +7
-1+out: +if (!ret) +pr_warn ("thp_anon=%s: cannot parse, ignored\n" , str); +return ret; +} +__setup ("thp_anon=" , setup_thp_anon); +pmd_t maybe_pmd_mkwrite (pmd_t pmd,struct vm_area_struct *vma) {if (likely (vma->vm_flags &VM_WRITE )) --
Quoted 2 lines
2.43.0
Thanks
Barry
Ryan Roberts
reviewerQuoted 103 lines · Barry Song
Quoted 102 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +8
-0@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +20
-6@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would block the collapse:: A higher value may increase memory footprint for some workloads. -Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always + +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``. Hugepages in tmpfs/shmem ========================mm/huge_memory.c +1
-0@@ -82,6 +82,7 @@ unsigned long huge_zero_pfn __read_mostly = ~0UL;unsigned long huge_anon_orders_always__read_mostly ;unsigned long huge_anon_orders_madvise__read_mostly ;unsigned long huge_anon_orders_inherit__read_mostly ; +static bool anon_orders_configured;
Quoted 16 lines
mm/huge_memory.c static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj) · line 679
Quoted 11 lines
mm/huge_memory.c +4
-1unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, unsigned long vm_flags,@@ -672,7 +673,10 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)* disable all other sizes. powerpc's PMD_ORDER isn't a compile-time * constant so we have to do this here. */ - huge_anon_orders_inherit =BIT (PMD_ORDER ); +if (!anon_orders_configured) { + huge_anon_orders_inherit =BIT (PMD_ORDER ); + anon_orders_configured = true; + }If a user configures 64KB and doesn't adjust anything for
PMD_ORDER, thenPMD_ORDERwill be set to "never", correct? This seems to change the default behavior ofPMD_ORDER. Could we instead achieve this by checking ifPMD_ORDERhas been explicitly configured?
Yes, that's how it's implemented in this patch, and the accompanying docs also state:
If ``thp_anon=`` is specified at least once, any anon THP sizes not explicitly configured on the command line are implicitly set to ``never``.
My initial approach did exactly as you suggest. But in the original series, I also had a similar patch to configure file thp with "thp_file=". And for file, all of the orders default to always. So if taking the same approach with that control, the user would have to explicitly opt-out of all supported orders rather than just opt-in to the orders they want. And I thought that could get tricky in future if support is added for more orders. I felt that was potentially very confusing so decided it was clearer to have the above rule and make both controls consistent.
What do you think?
Quoted 72 lines
Quoted 40 lines
mm/huge_memory.c +32
-0*hugepage_kobj =kobject_create_and_add ("transparent_hugepage" , mm_kobj);if (unlikely (!*hugepage_kobj)) {@@ -857,6 +861,55 @@ static int __init setup_transparent_hugepage(char *str) }__setup ("transparent_hugepage=" , setup_transparent_hugepage); +static int __init setup_thp_anon (char *str) +{ +unsigned long size; +char *state; +int order; +int ret =0 ; + +if (!str) + goto out; + + size = (unsigned long )memparse (str, &state); + order =ilog2 (size >>PAGE_SHIFT ); +if (*state !=':' || !is_power_of_2 (size) || size <=PAGE_SIZE || + !(BIT (order) &THP_ORDERS_ALL_ANON )) + goto out; + + state++; + +if (!strcmp (state,"always" )) { +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_always); + ret =1 ; + }else if (!strcmp (state,"inherit" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_inherit); + ret =1 ; + }else if (!strcmp (state,"madvise" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +set_bit (order, &huge_anon_orders_madvise);mm/huge_memory.c static int __init setup_transparent_hugepage(char *str) · line 905
Quoted 10 lines
mm/huge_memory.c +10
-0+ ret =1 ; + }else if (!strcmp (state,"never" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); + ret =1 ; + } + +if (ret) + anon_orders_configured = true;I mean:
if (ret && order ==
PMD_ORDER)anon_pmd_order_configured = true;Quoted 11 lines
mm/huge_memory.c +7
-1+out: +if (!ret) +pr_warn ("thp_anon=%s: cannot parse, ignored\n" , str); +return ret; +} +__setup ("thp_anon=" , setup_thp_anon); +pmd_t maybe_pmd_mkwrite (pmd_t pmd,struct vm_area_struct *vma) {if (likely (vma->vm_flags &VM_WRITE )) --Quoted 2 lines
2.43.0
Thanks
Barry
Quoted 138 lines · Ryan Roberts
Quoted 103 lines · Barry Song
Quoted 102 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +8
-0@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +20
-6@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would block the collapse:: A higher value may increase memory footprint for some workloads. -Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always + +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``. Hugepages in tmpfs/shmem ========================mm/huge_memory.c +1
-0@@ -82,6 +82,7 @@ unsigned long huge_zero_pfn __read_mostly = ~0UL;unsigned long huge_anon_orders_always__read_mostly ;unsigned long huge_anon_orders_madvise__read_mostly ;unsigned long huge_anon_orders_inherit__read_mostly ; +static bool anon_orders_configured;Quoted 16 lines
mm/huge_memory.c static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj) · line 679
Quoted 11 lines
mm/huge_memory.c +4
-1unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, unsigned long vm_flags,@@ -672,7 +673,10 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)* disable all other sizes. powerpc's PMD_ORDER isn't a compile-time * constant so we have to do this here. */ - huge_anon_orders_inherit =BIT (PMD_ORDER ); +if (!anon_orders_configured) { + huge_anon_orders_inherit =BIT (PMD_ORDER ); + anon_orders_configured = true; + }If a user configures 64KB and doesn't adjust anything for
PMD_ORDER, thenPMD_ORDERwill be set to "never", correct? This seems to change the default behavior ofPMD_ORDER. Could we instead achieve this by checking ifPMD_ORDERhas been explicitly configured?Yes, that's how it's implemented in this patch, and the accompanying docs also state:
If ``thp_anon=`` is specified at least once, any anon THP sizes not explicitly configured on the command line are implicitly set to ``never``.
My initial approach did exactly as you suggest. But in the original series, I also had a similar patch to configure file thp with "thp_file=". And for file, all of the orders default to
always. So if taking the same approach with that control, the user would have to explicitly opt-out of all supported orders rather than just opt-in to the orders they want. And I thought that could get tricky in future if support is added for more orders. I felt that was potentially very confusing so decided it was clearer to have the above rule and make both controls consistent.
Quoted 1 line
What do you think?
If this is the intention, once the user sets the command line, they should realize that the default settings have been overridden. I am perfectly fine with this strategy.
with the below cmdline:
thp_anon=64K:always thp_anon=8K:inherit thp_anon=32K:madvise
thp_anon=1M:inherit thp_anon=2M:always
I am getting:
/ # cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/enabled [always] inherit madvise never
/ # cat /sys/kernel/mm/transparent_hugepage/hugepages-32kB/enabled always inherit [madvise] never
/ # cat /sys/kernel/mm/transparent_hugepage/hugepages-1024kB/enabled always [inherit] madvise never
/ # cat /sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled [always] inherit madvise never
Thus,
Quoted 75 lines
Quoted 74 lines
Quoted 42 lines
mm/huge_memory.c +32
-0*hugepage_kobj =kobject_create_and_add ("transparent_hugepage" , mm_kobj);if (unlikely (!*hugepage_kobj)) {@@ -857,6 +861,55 @@ static int __init setup_transparent_hugepage(char *str) }__setup ("transparent_hugepage=" , setup_transparent_hugepage); +static int __init setup_thp_anon (char *str) +{ +unsigned long size; +char *state; +int order; +int ret =0 ; + +if (!str) + goto out; + + size = (unsigned long )memparse (str, &state); + order =ilog2 (size >>PAGE_SHIFT ); +if (*state !=':' || !is_power_of_2 (size) || size <=PAGE_SIZE || + !(BIT (order) &THP_ORDERS_ALL_ANON )) + goto out; + + state++; + +if (!strcmp (state,"always" )) { +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_always); + ret =1 ; + }else if (!strcmp (state,"inherit" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_inherit); + ret =1 ; + }else if (!strcmp (state,"madvise" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +set_bit (order, &huge_anon_orders_madvise);mm/huge_memory.c static int __init setup_transparent_hugepage(char *str) · line 905
Quoted 10 lines
mm/huge_memory.c +10
-0+ ret =1 ; + }else if (!strcmp (state,"never" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); + ret =1 ; + } + +if (ret) + anon_orders_configured = true;I mean:
if (ret && order ==
PMD_ORDER)anon_pmd_order_configured = true;Quoted 11 lines
mm/huge_memory.c +7
-1+out: +if (!ret) +pr_warn ("thp_anon=%s: cannot parse, ignored\n" , str); +return ret; +} +__setup ("thp_anon=" , setup_thp_anon); +pmd_t maybe_pmd_mkwrite (pmd_t pmd,struct vm_area_struct *vma) {if (likely (vma->vm_flags &VM_WRITE )) --Quoted 2 lines
2.43.0
Thanks
Barry
Ryan Roberts
reviewerQuoted 139 lines · Barry Song
Quoted 138 lines · Ryan Roberts
Quoted 103 lines · Barry Song
Quoted 102 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +8
-0@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +20
-6@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would block the collapse:: A higher value may increase memory footprint for some workloads. -Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always + +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``. Hugepages in tmpfs/shmem ========================mm/huge_memory.c +1
-0@@ -82,6 +82,7 @@ unsigned long huge_zero_pfn __read_mostly = ~0UL;unsigned long huge_anon_orders_always__read_mostly ;unsigned long huge_anon_orders_madvise__read_mostly ;unsigned long huge_anon_orders_inherit__read_mostly ; +static bool anon_orders_configured;Quoted 16 lines
mm/huge_memory.c static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj) · line 679
Quoted 11 lines
mm/huge_memory.c +4
-1unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, unsigned long vm_flags,@@ -672,7 +673,10 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)* disable all other sizes. powerpc's PMD_ORDER isn't a compile-time * constant so we have to do this here. */ - huge_anon_orders_inherit =BIT (PMD_ORDER ); +if (!anon_orders_configured) { + huge_anon_orders_inherit =BIT (PMD_ORDER ); + anon_orders_configured = true; + }If a user configures 64KB and doesn't adjust anything for
PMD_ORDER, thenPMD_ORDERwill be set to "never", correct? This seems to change the default behavior ofPMD_ORDER. Could we instead achieve this by checking ifPMD_ORDERhas been explicitly configured?Yes, that's how it's implemented in this patch, and the accompanying docs also state:
If ``thp_anon=`` is specified at least once, any anon THP sizes not explicitly configured on the command line are implicitly set to ``never``.
My initial approach did exactly as you suggest. But in the original series, I also had a similar patch to configure file thp with "thp_file=". And for file, all of the orders default to
always. So if taking the same approach with that control, the user would have to explicitly opt-out of all supported orders rather than just opt-in to the orders they want. And I thought that could get tricky in future if support is added for more orders. I felt that was potentially very confusing so decided it was clearer to have the above rule and make both controls consistent.
Quoted 5 lines
Quoted 1 line
What do you think?
If this is the intention, once the user sets the command line, they should realize that the default settings have been overridden. I am perfectly fine with this strategy.
OK. I can see it from both sides to be honest. Let's see if anyone else has issue with this approach.
Quoted 5 lines
with the below cmdline:
thp_anon=64K:always thp_anon=8K:inherit thp_anon=32K:madvise
thp_anon=1M:inherit thp_anon=2M:always
Quoted 9 lines
I am getting:
/ # cat/sys/kernel/mm/transparent_hugepage/hugepages-64kB/enabled[always] inherit madvise never
/ # cat/sys/kernel/mm/transparent_hugepage/hugepages-32kB/enabledalways inherit [madvise] never
/ # cat/sys/kernel/mm/transparent_hugepage/hugepages-1024kB/enabledalways [inherit] madvise never
/ # cat/sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled[always] inherit madvise never
And you should also be seeing a warning in the boot log that thp_anon=8K:inherit is unrecognised (since anon doesn't support order-1).
Quoted 4 lines
Thus,
Tested-by Barry Song <[email protected]>
Thanks!
Quoted 76 lines
Quoted 76 lines
Quoted 75 lines
Quoted 43 lines
mm/huge_memory.c +32
-0*hugepage_kobj =kobject_create_and_add ("transparent_hugepage" , mm_kobj);if (unlikely (!*hugepage_kobj)) {@@ -857,6 +861,55 @@ static int __init setup_transparent_hugepage(char *str) }__setup ("transparent_hugepage=" , setup_transparent_hugepage); +static int __init setup_thp_anon (char *str) +{ +unsigned long size; +char *state; +int order; +int ret =0 ; + +if (!str) + goto out; + + size = (unsigned long )memparse (str, &state); + order =ilog2 (size >>PAGE_SHIFT ); +if (*state !=':' || !is_power_of_2 (size) || size <=PAGE_SIZE || + !(BIT (order) &THP_ORDERS_ALL_ANON )) + goto out; + + state++; + +if (!strcmp (state,"always" )) { +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_always); + ret =1 ; + }else if (!strcmp (state,"inherit" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_inherit); + ret =1 ; + }else if (!strcmp (state,"madvise" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +set_bit (order, &huge_anon_orders_madvise);mm/huge_memory.c static int __init setup_transparent_hugepage(char *str) · line 905
Quoted 10 lines
mm/huge_memory.c +10
-0+ ret =1 ; + }else if (!strcmp (state,"never" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); + ret =1 ; + } + +if (ret) + anon_orders_configured = true;I mean:
if (ret && order ==
PMD_ORDER)anon_pmd_order_configured = true;Quoted 11 lines
mm/huge_memory.c +7
-1+out: +if (!ret) +pr_warn ("thp_anon=%s: cannot parse, ignored\n" , str); +return ret; +} +__setup ("thp_anon=" , setup_thp_anon); +pmd_t maybe_pmd_mkwrite (pmd_t pmd,struct vm_area_struct *vma) {if (likely (vma->vm_flags &VM_WRITE )) --Quoted 2 lines
2.43.0
Thanks
Barry
Barry Song
reviewerQuoted 165 lines · Ryan Roberts
Quoted 139 lines · Barry Song
Quoted 138 lines · Ryan Roberts
Quoted 103 lines · Barry Song
Quoted 102 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +8
-0@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +20
-6@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would block the collapse:: A higher value may increase memory footprint for some workloads. -Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always + +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``. Hugepages in tmpfs/shmem ========================mm/huge_memory.c +1
-0@@ -82,6 +82,7 @@ unsigned long huge_zero_pfn __read_mostly = ~0UL;unsigned long huge_anon_orders_always__read_mostly ;unsigned long huge_anon_orders_madvise__read_mostly ;unsigned long huge_anon_orders_inherit__read_mostly ; +static bool anon_orders_configured;Quoted 16 lines
mm/huge_memory.c static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj) · line 679
Quoted 11 lines
mm/huge_memory.c +4
-1unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, unsigned long vm_flags,@@ -672,7 +673,10 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)* disable all other sizes. powerpc's PMD_ORDER isn't a compile-time * constant so we have to do this here. */ - huge_anon_orders_inherit =BIT (PMD_ORDER ); +if (!anon_orders_configured) { + huge_anon_orders_inherit =BIT (PMD_ORDER ); + anon_orders_configured = true; + }If a user configures 64KB and doesn't adjust anything for
PMD_ORDER, thenPMD_ORDERwill be set to "never", correct? This seems to change the default behavior ofPMD_ORDER. Could we instead achieve this by checking ifPMD_ORDERhas been explicitly configured?Yes, that's how it's implemented in this patch, and the accompanying docs also state:
If ``thp_anon=`` is specified at least once, any anon THP sizes not explicitly configured on the command line are implicitly set to ``never``.
My initial approach did exactly as you suggest. But in the original series, I also had a similar patch to configure file thp with "thp_file=". And for file, all of the orders default to
always. So if taking the same approach with that control, the user would have to explicitly opt-out of all supported orders rather than just opt-in to the orders they want. And I thought that could get tricky in future if support is added for more orders. I felt that was potentially very confusing so decided it was clearer to have the above rule and make both controls consistent.Quoted 5 lines
Quoted 1 line
What do you think?
If this is the intention, once the user sets the command line, they should realize that the default settings have been overridden. I am perfectly fine with this strategy.
OK. I can see it from both sides to be honest. Let's see if anyone else has issue with this approach.
Quoted 5 lines
with the below cmdline:
thp_anon=64K:always thp_anon=8K:inherit thp_anon=32K:madvise
thp_anon=1M:inherit thp_anon=2M:alwaysQuoted 9 lines
I am getting:
/ # cat/sys/kernel/mm/transparent_hugepage/hugepages-64kB/enabled[always] inherit madvise never
/ # cat/sys/kernel/mm/transparent_hugepage/hugepages-32kB/enabledalways inherit [madvise] never
/ # cat/sys/kernel/mm/transparent_hugepage/hugepages-1024kB/enabledalways [inherit] madvise never
/ # cat/sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled[always] inherit madvise never
Quoted 2 lines
And you should also be seeing a warning in the boot log that thp_anon=8K:inherit is unrecognised (since anon doesn't support order-1).
Indeed.
I am even seeing "Unknown kernel command line parameters "thp_anon=8K:inherit", will be passed to user space."
[ 0.000000] huge_memory: thp_anon=8K:inherit: cannot parse, ignored [ 0.000000] Unknown kernel command line parameters "thp_anon=8K:inherit", will be passed to user space. [ 0.000000] random: crng init done [ 0.000000] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes, linear) [ 0.000000] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes, linear) [ 0.000000] Fallback order for Node 0: 0 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 131072 [ 0.000000] Policy zone: DMA
Quoted 86 lines
Quoted 5 lines
Thus,
Tested-by Barry Song <[email protected]>Thanks!
Quoted 76 lines
Quoted 76 lines
Quoted 75 lines
Quoted 43 lines
mm/huge_memory.c +32
-0*hugepage_kobj =kobject_create_and_add ("transparent_hugepage" , mm_kobj);if (unlikely (!*hugepage_kobj)) {@@ -857,6 +861,55 @@ static int __init setup_transparent_hugepage(char *str) }__setup ("transparent_hugepage=" , setup_transparent_hugepage); +static int __init setup_thp_anon (char *str) +{ +unsigned long size; +char *state; +int order; +int ret =0 ; + +if (!str) + goto out; + + size = (unsigned long )memparse (str, &state); + order =ilog2 (size >>PAGE_SHIFT ); +if (*state !=':' || !is_power_of_2 (size) || size <=PAGE_SIZE || + !(BIT (order) &THP_ORDERS_ALL_ANON )) + goto out; + + state++; + +if (!strcmp (state,"always" )) { +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_always); + ret =1 ; + }else if (!strcmp (state,"inherit" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_madvise); +set_bit (order, &huge_anon_orders_inherit); + ret =1 ; + }else if (!strcmp (state,"madvise" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +set_bit (order, &huge_anon_orders_madvise);mm/huge_memory.c static int __init setup_transparent_hugepage(char *str) · line 905
Quoted 10 lines
mm/huge_memory.c +10
-0+ ret =1 ; + }else if (!strcmp (state,"never" )) { +clear_bit (order, &huge_anon_orders_always); +clear_bit (order, &huge_anon_orders_inherit); +clear_bit (order, &huge_anon_orders_madvise); + ret =1 ; + } + +if (ret) + anon_orders_configured = true;I mean:
if (ret && order ==
PMD_ORDER)anon_pmd_order_configured = true;Quoted 11 lines
mm/huge_memory.c +7
-1+out: +if (!ret) +pr_warn ("thp_anon=%s: cannot parse, ignored\n" , str); +return ret; +} +__setup ("thp_anon=" , setup_thp_anon); +pmd_t maybe_pmd_mkwrite (pmd_t pmd,struct vm_area_struct *vma) {if (likely (vma->vm_flags &VM_WRITE )) --Quoted 2 lines
2.43.0
Thanks
Barry
Quoted 7 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
thp_anon=<size>[KMG]:<value>
Quoted 7 lines
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
Signed-off-by Ryan Roberts <[email protected]>
Make sense to me. Thanks.
Quoted 8 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
thp_anon=<size>[KMG]:<value>
Quoted 7 lines
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
Signed-off-by Ryan Roberts <[email protected]>
Thanks
Barry
Quoted 5 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
Quoted 7 lines
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
I suspect a khugeapged enhancement and/or kernel-config-dependant defaults and/or early system settings will also be able to mitigate that without getting kernel cmdlines involved in the future.
Quoted 66 lines
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +8
-0@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +10
-6@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would block the collapse:: A higher value may increase memory footprint for some workloads. -Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or
Documentation/admin-guide/mm/transhuge.rst that THP is shared. Exceeding the number would block the collapse:: · line 307
Quoted 10 lines
Documentation/admin-guide/mm/transhuge.rst +10
-0+``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always + +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``.
I suggest documenting that "thp_anon=" will not effect the value of "transparent_hugepage=", or any configured default.
Wondering if a syntax like
thp_anon=16K,32K,64K:always;1048K,2048K:madvise
(one could also support ranges, like "16K-64K")
Would be even better. Then, maybe only allow a single instance.
Maybe consider it if it's not too crazy to parse ;)
Signature · 3 lines
Cheers, David / dhildenb
Barry Song
reviewerQuoted 101 lines · David Hildenbrand
Quoted 5 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
Quoted 7 lines
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
I suspect a khugeapged enhancement and/or kernel-config-dependant defaults and/or early system settings will also be able to mitigate that without getting kernel cmdlines involved in the future.
Quoted 66 lines
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +8
-0@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +10
-6@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would block the collapse:: A higher value may increase memory footprint for some workloads. -Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` orDocumentation/admin-guide/mm/transhuge.rst that THP is shared. Exceeding the number would block the collapse:: · line 307
Quoted 10 lines
Documentation/admin-guide/mm/transhuge.rst +10
-0+``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always + +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``.I suggest documenting that "thp_anon=" will not effect the value of "transparent_hugepage=", or any configured default.
Wondering if a syntax like
Quoted 7 lines
thp_anon=16K,32K,64K:always;1048K,2048K:madvise
(one could also support ranges, like "16K-64K")
Would be even better. Then, maybe only allow a single instance.
Maybe consider it if it's not too crazy to parse ;)
I prefer the current approach because it effectively filters cases like this.
[ 0.000000] huge_memory: thp_anon=8K:inherit: cannot parse, ignored [ 0.000000] Unknown kernel command line parameters
"thp_anon=8K:inherit", will be passed to user space.
if we put multiple sizes together, 8K,32K,64K:always
We can't determine whether this command line is legal or illegal as it is partially legal and partially illegal.
Just my two cents :-)
Quoted 5 lines
--
Cheers,David / dhildenb
Thanks
Barry
Quoted 112 lines · Barry Song
Quoted 101 lines · David Hildenbrand
Quoted 5 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
Quoted 7 lines
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
I suspect a khugeapged enhancement and/or kernel-config-dependant defaults and/or early system settings will also be able to mitigate that without getting kernel cmdlines involved in the future.
Quoted 66 lines
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +8
-0@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +10
-6@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would block the collapse:: A higher value may increase memory footprint for some workloads. -Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` orDocumentation/admin-guide/mm/transhuge.rst that THP is shared. Exceeding the number would block the collapse:: · line 307
Quoted 10 lines
Documentation/admin-guide/mm/transhuge.rst +10
-0+``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always + +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``.I suggest documenting that "thp_anon=" will not effect the value of "transparent_hugepage=", or any configured default.
Wondering if a syntax like
Quoted 7 lines
thp_anon=16K,32K,64K:always;1048K,2048K:madvise
(one could also support ranges, like "16K-64K")
Would be even better. Then, maybe only allow a single instance.
Maybe consider it if it's not too crazy to parse ;)
I prefer the current approach because it effectively filters cases like this.
Quoted 8 lines
[ 0.000000] huge_memory: thp_anon=8K:inherit: cannot parse, ignored [ 0.000000] Unknown kernel command line parameters"thp_anon=8K:inherit", will be passed to user space.
if we put multiple sizes together, 8K,32K,64K:always
We can't determine whether this command line is legal or illegal as it is partially legal and partially illegal.
Besides: I wouldn't bother about this "user does something stupid" scenario that much.
But yes, once we support more sizes a cmdline might turn invalid on an older kernel.
However, I don't see the problem here. User passed a non-existant size. Ignore that one but handle the others, like you would with multiple commands?
It can be well defined and documented. The command line is legal, just one size does not exist.
The world will continue turning :)
Signature · 3 lines
Cheers, David / dhildenb
Ryan Roberts
reviewerQuoted 96 lines · David Hildenbrand
Quoted 95 lines · Barry Song
Quoted 94 lines · David Hildenbrand
Quoted 5 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
Quoted 7 lines
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
I suspect a khugeapged enhancement and/or kernel-config-dependant defaults and/or early system settings will also be able to mitigate that without getting kernel cmdlines involved in the future.
Quoted 75 lines
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a
minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++-
3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +0
-0@@ -6631,6 +6631,14 @@<deci-seconds>: poll all this frequency 0: no polling (default)
+ thp_anon= [KNL]
+ Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + SeeDocumentation/admin-guide/mm/transhuge.rstfor more + details.
+
threadirqs [KNL,EARLY]
Force threading of all interrupt handlers except those marked explicitlyIRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +0
-0@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would blockthe collapse::
A higher value may increase memory footprint for some workloads.
Documentation/admin-guide/mm/transhuge.rst +15
-6-Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:always
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Documentation/admin-guide/mm/transhuge.rst that THP is shared. Exceeding the number would block the collapse:: · line 307
Quoted 5 lines
Documentation/admin-guide/mm/transhuge.rst +5
-0+ +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``.I suggest documenting that "thp_anon=" will not effect the value of "transparent_hugepage=", or any configured default.
Did you see the previous conversation with Barry about whether or not to honour configured defaults when any thp_anon= is provided [1]? Sounds like you also think we should honour the PMD "inherit" default if not explicitly provided on the command line? (see link for justification for the approach I'm currently taking).
[1]
https://lore.kernel.org/linux-mm/CAGsJ_4x8ruPspuk_FQVggJMWcXLbRuZFq44gg-Dt7Ewt3ExqTw@mail.gmail.com/
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Wondering if a syntax like
thp_anon=16K,32K,64K:always;1048K,2048K:madvise
Are there examples of that syntax already or have you just made it up? I found examples with the colon (:) but nothing this fancy. I guess that's not a reason not to do it though (other than the risk of screwing up the parser in a subtle way).
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
(one could also support ranges, like "16K-64K")
Would be even better. Then, maybe only allow a single instance.
Maybe consider it if it's not too crazy to parse ;)
I'll take a look. I'm going to be out for 3 weeks from end of Monday though, so probably won't get around to that until I'm back. I know Barry is keen to get this merged, so Barry, if you'd like to take it over that's fine by me (I'm sure you have enough on your plate though).
Quoted 12 lines
Quoted 11 lines
I prefer the current approach because it effectively filters cases like this.
[ 0.000000]
huge_memory: thp_anon=8K:inherit: cannot parse, ignored [ 0.000000] Unknown kernel command line parameters "thp_anon=8K:inherit", will be passed to user space.if we put multiple sizes together, 8K,32K,64K:always
We can't determine whether this command line is legal or illegal as it is partially legal and partially illegal.
Quoted 8 lines
Besides: I wouldn't bother about this "user does something stupid" scenario that much.
But yes, once we support more sizes a cmdline might turn invalid on an older kernel.
However, I don't see the problem here. User passed a non-existant size. Ignore that one but handle the others, like you would with multiple commands?
Yep, the parser could emit a warning for the size and move on.
Quoted 6 lines
It can be well defined and documented. The command line is legal, just one size does not exist.
The world will continue turning :)
Barry Song
reviewerQuoted 128 lines · Ryan Roberts
Quoted 96 lines · David Hildenbrand
Quoted 95 lines · Barry Song
Quoted 94 lines · David Hildenbrand
Quoted 5 lines · Ryan Roberts
Add thp_anon= cmdline parameter to allow specifying the default enablement of each supported anon THP size. The parameter accepts the following format and can be provided multiple times to configure each size:
Quoted 7 lines
thp_anon=<size>[KMG]:<value>
See
Documentation/admin-guide/mm/transhuge.rstfor more details.Configuring the defaults at boot time is useful to allow early user space to take advantage of mTHP before its been configured through sysfs.
I suspect a khugeapged enhancement and/or kernel-config-dependant defaults and/or early system settings will also be able to mitigate that without getting kernel cmdlines involved in the future.
Quoted 75 lines
Signed-off-by Ryan Roberts <[email protected]>---
Hi All,
I've split this off from my RFC at [1] because Barry highlighted that he would benefit from it immediately [2]. There are no changes vs the version in that series.
It applies against today's mm-unstable (
275d686abcb59). (although I had to fix a
minor build bug instackdepot.cdue toMIN()not being defined in this tree).Thanks,
Ryan.../admin-guide/kernel-parameters.txt | 8 +++ Documentation/admin-guide/mm/transhuge.rst | 26 +++++++-- mm/huge_memory.c | 55 ++++++++++++++++++- 3 files changed, 82 insertions(+), 7 deletions(-)Documentation/admin-guide/kernel-parameters.txt +8
-0@@ -6631,6 +6631,14 @@ <deci-seconds>: poll all this frequency 0: no polling (default) + thp_anon= [KNL] + Format: <size>[KMG]:always|madvise|never|inherit + Can be used to control the default behavior of the + system with respect to anonymous transparent hugepages. + Can be used multiple times for multiple anon THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + threadirqs [KNL,EARLY] Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD.Documentation/admin-guide/mm/transhuge.rst +0
-0@@ -284,13 +284,27 @@ that THP is shared. Exceeding the number would blockthe collapse::
A higher value may increase memory footprint for some workloads.
Documentation/admin-guide/mm/transhuge.rst +15
-6-Boot parameter -============== +Boot parameters +=============== -You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:alwaysQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Documentation/admin-guide/mm/transhuge.rst that THP is shared. Exceeding the number would block the collapse:: · line 307
Quoted 5 lines
Documentation/admin-guide/mm/transhuge.rst +5
-0+ +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``.I suggest documenting that "thp_anon=" will not effect the value of "transparent_hugepage=", or any configured default.
Did you see the previous conversation with Barry about whether or not to honour configured defaults when any thp_anon= is provided [1]? Sounds like you also think we should honour the PMD "inherit" default if not explicitly provided on the command line? (see link for justification for the approach I'm currently taking).
[1]
https://lore.kernel.org/linux-mm/CAGsJ_4x8ruPspuk_FQVggJMWcXLbRuZFq44gg-Dt7Ewt3ExqTw@mail.gmail.com/Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Wondering if a syntax like
thp_anon=16K,32K,64K:always;1048K,2048K:madvise
Are there examples of that syntax already or have you just made it up? I found examples with the colon (:) but nothing this fancy. I guess that's not a reason not to do it though (other than the risk of screwing up the parser in a subtle way).
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
(one could also support ranges, like "16K-64K")
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Would be even better. Then, maybe only allow a single instance.
Maybe consider it if it's not too crazy to parse ;)
I'll take a look. I'm going to be out for 3 weeks from end of Monday though, so probably won't get around to that until I'm back. I know Barry is keen to get this merged, so Barry, if you'd like to take it over that's fine by me (I'm sure you have enough on your plate though).
Yes, this command line is definitely needed. However, I also agree with David that it might be worth considering options like '16K-64K' or '16K, 32K, 64K' after further reflection. For example, if users want to enable six sizes, having six separate commands could end up being quite silly :-)
I can address this after the mTHP number counters series.
Quoted 16 lines
Quoted 16 lines
Quoted 4 lines
I prefer the current approach because it effectively filters cases like this.
Quoted 8 lines
[ 0.000000] huge_memory: thp_anon=8K:inherit: cannot parse, ignored [ 0.000000] Unknown kernel command line parameters"thp_anon=8K:inherit", will be passed to user space.
if we put multiple sizes together, 8K,32K,64K:always
We can't determine whether this command line is legal or illegal as it is partially legal and partially illegal.
Besides: I wouldn't bother about this "user does something stupid" scenario that much.
Quoted 13 lines
Quoted 5 lines
But yes, once we support more sizes a cmdline might turn invalid on an older kernel.
However, I don't see the problem here. User passed a non-existant size. Ignore that one but handle the others, like you would with multiple commands?
Yep, the parser could emit a warning for the size and move on.
Quoted 5 lines
It can be well defined and documented. The command line is legal, just one size does not exist.
The world will continue turning :)
Right.
Thanks
Barry
Quoted 26 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Documentation/admin-guide/mm/transhuge.rst +13
-4-You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:alwaysQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Documentation/admin-guide/mm/transhuge.rst that THP is shared. Exceeding the number would block the collapse:: · line 307
Quoted 5 lines
Documentation/admin-guide/mm/transhuge.rst +5
-0+ +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``.I suggest documenting that "thp_anon=" will not effect the value of "transparent_hugepage=", or any configured default.
Quoted 5 lines
Did you see the previous conversation with Barry about whether or not to honour configured defaults when any thp_anon= is provided [1]? Sounds like you also think we should honour the PMD "inherit" default if not explicitly provided on the command line? (see link for justification for the approach I'm currently taking).
I primarily think that we should document it :)
What if someone passes "transparent_hugepage=always" and "thp_anon=..."? I would assume that transparent_hugepage would only affect the global toggle then?
Quoted 5 lines
[1]
https://lore.kernel.org/linux-mm/CAGsJ_4x8ruPspuk_FQVggJMWcXLbRuZFq44gg-Dt7Ewt3ExqTw@mail.gmail.com/Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Wondering if a syntax like
thp_anon=16K,32K,64K:always;1048K,2048K:madvise
Are there examples of that syntax already or have you just made it up? I found examples with the colon (:) but nothing this fancy. I guess that's not a reason not to do it though (other than the risk of screwing up the parser in a subtle way).
I made it up -- mostly ;) I think we are quite flexible on what we can do. As always, maybe we can keep it bit consistent with existing stuff.
For hugetlb_cma we have things like
"<node>:nn[KMGTPE|[,<node>:nn[KMGTPE]]
"memmap=" options are more ... advanced, including memory ranges. There are a bunch more documented in kernel-parameters.txt that have more elaborate formats.
Ranges would probably be the most valuable addition. So maybe we should start with:
thp_anon=16K-64K:always,1048K-2048K:madvise
So to enable all THPs it would simply be
thp_anon=16K-2M:always
Interesting question what would happen if someone passes:
thp_anon=8K-2M:always
Likely we simply would apply it to any size in the range, even if start/end is not a THP size.
But we would want to complain to the user if someone only specifies a single one (or a range does not even select a single one) that does not exist:
thp_anon=8K:always
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
(one could also support ranges, like "16K-64K")
Would be even better. Then, maybe only allow a single instance.
Maybe consider it if it's not too crazy to parse ;)
I'll take a look. I'm going to be out for 3 weeks from end of Monday though, so
Oh, lucky you! Enjoy!
Quoted 3 lines
probably won't get around to that until I'm back. I know Barry is keen to get this merged, so Barry, if you'd like to take it over that's fine by me (I'm sure you have enough on your plate though).
Signature · 3 lines
Cheers, David / dhildenb
Quoted 75 lines · David Hildenbrand
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
(quoted diff) +13
-4-You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:alwaysQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``.I suggest documenting that "thp_anon=" will not effect the value of "transparent_hugepage=", or any configured default.
Quoted 5 lines
Did you see the previous conversation with Barry about whether or not to honour configured defaults when any thp_anon= is provided [1]? Sounds like you also think we should honour the PMD "inherit" default if not explicitly provided on the command line? (see link for justification for the approach I'm currently taking).
I primarily think that we should document it :)
What if someone passes "transparent_hugepage=always" and "thp_anon=..."? I would assume that
transparent_hugepagewould only affect the global toggle then?Quoted 5 lines
[1]
https://lore.kernel.org/linux-mm/CAGsJ_4x8ruPspuk_FQVggJMWcXLbRuZFq44gg-Dt7Ewt3ExqTw@mail.gmail.com/Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Wondering if a syntax like
thp_anon=16K,32K,64K:always;1048K,2048K:madvise
Are there examples of that syntax already or have you just made it up? I found examples with the colon (:) but nothing this fancy. I guess that's not a reason not to do it though (other than the risk of screwing up the parser in a subtle way).
I made it up -- mostly ;) I think we are quite flexible on what we can do. As always, maybe we can keep it bit consistent with existing stuff.
For
hugetlb_cmawe have things like
"<node>:nn[KMGTPE|[,<node>:nn[KMGTPE]]"memmap=" options are more ... advanced, including memory ranges. There are a bunch more documented in kernel-parameters.txt that have more elaborate formats.
Ranges would probably be the most valuable addition. So maybe we should start with:
thp_anon=16K-64K:always,1048K-2048K:madvise
So to enable all THPs it would simply be
thp_anon=16K-2M:always
Interesting question what would happen if someone passes:
thp_anon=8K-2M:always
Quoted 8 lines
Likely we simply would apply it to any size in the range, even if start/end is not a THP size.
But we would want to complain to the user if someone only specifies a single one (or a range does not even select a single one) that does not exist:
thp_anon=8K:always
How about rejecting settings with any illegal size or policy?
I found there are too many corner cases to say "yes" or "no". It seems the code could be much cleaner if we simply reject illegal settings. On the other hand, we should rely on smart users to provide correct settings, shouldn’t we? While working one the code, I felt that extracting partial correct settings from incorrect ones and supporting them might be a bit of over-design.
I have tested the below code by
"thp_anon=16K-64K:always;128K,512K:inherit;256K:madvise;1M-2M:never"
mm/huge_memory.c +102 -1
@@ -81,6 +81,7 @@ unsigned long huge_zero_pfn __read_mostly = ~0UL;unsigned long huge_anon_orders_always__read_mostly ;unsigned long huge_anon_orders_madvise__read_mostly ;unsigned long huge_anon_orders_inherit__read_mostly ; +static bool anon_orders_configured; unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, unsigned long vm_flags,
@@ -737,7 +738,10 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)* disable all other sizes. powerpc's PMD_ORDER isn't a compile-time * constant so we have to do this here. */ - huge_anon_orders_inherit =BIT (PMD_ORDER ); +if (!anon_orders_configured) { + huge_anon_orders_inherit =BIT (PMD_ORDER ); + anon_orders_configured = true; + } *hugepage_kobj =kobject_create_and_add ("transparent_hugepage" , mm_kobj);if (unlikely (!*hugepage_kobj)) {
@@ -922,6 +926,103 @@ static int __init setup_transparent_hugepage(char *str) }__setup ("transparent_hugepage=" , setup_transparent_hugepage); +static inline int get_order_from_str (const char *size_str) +{ +unsigned long size; +char *endptr; +int order; + + size =memparse (size_str, &endptr); + order =fls (size >>PAGE_SHIFT ) -1 ; +if (order & ~THP_ORDERS_ALL_ANON ) { +pr_err ("invalid size in thp_anon= %ld\n" , size); +return -EINVAL ; + } + +return order; +} + +static inline void set_bits (unsigned long *var,int start,int end) +{ +int i; + +for (i = start; i <= end; i++) +set_bit (i, var); +} + +static inline void clear_bits (unsigned long *var,int start,int end) +{ +int i; + +for (i = start; i <= end; i++) +clear_bit (i, var); +} + +static char str_dup[PAGE_SIZE ]__meminitdata ; +static int __init setup_thp_anon (char *str) +{ +char *token, *range, *policy, *subtoken; +char *start_size, *end_size; +int start, end; +char *p; + +if (!str ||strlen (str) +1 >PAGE_SIZE ) + goto err; +strcpy (str_dup, str); + + p = str_dup; +while ((token =strsep (&p,";" )) !=NULL ) { + range =strsep (&token,":" ); + policy = token; + +if (!policy) + goto err; + +while ((subtoken =strsep (&range,"," )) !=NULL ) { +if (strchr (subtoken,'-' )) { + start_size =strsep (&subtoken,"-" ); + end_size = subtoken; + + start =get_order_from_str (start_size); + end =get_order_from_str (end_size); + }else { + start = end =get_order_from_str (subtoken); + } + +if (start <0 || end <0 || start > end) + goto err; + +if (!strcmp (policy,"always" )) { +set_bits (&huge_anon_orders_always, start, end); +clear_bits (&huge_anon_orders_inherit, start, end); +clear_bits (&huge_anon_orders_madvise, start, end); + }else if (!strcmp (policy,"madvise" )) { +set_bits (&huge_anon_orders_madvise, start, end); +clear_bits (&huge_anon_orders_inherit, start, end); +clear_bits (&huge_anon_orders_always, start, end); + }else if (!strcmp (policy,"inherit" )) { +set_bits (&huge_anon_orders_inherit, start, end); +clear_bits (&huge_anon_orders_madvise, start, end); +clear_bits (&huge_anon_orders_always, start, end); + }else if (!strcmp (policy,"never" )) { +clear_bits (&huge_anon_orders_inherit, start, end); +clear_bits (&huge_anon_orders_madvise, start, end); +clear_bits (&huge_anon_orders_always, start, end); + }else { + goto err; + } + } + } + + anon_orders_configured = true; +return 1 ; + +err: +pr_warn ("thp_anon=%s: cannot parse(invalid size or policy), ignored\n" , str); +return 0 ; +} +__setup ("thp_anon=" , setup_thp_anon); +pmd_t maybe_pmd_mkwrite (pmd_t pmd,struct vm_area_struct *vma) {if (likely (vma->vm_flags &VM_WRITE ))
Signature · 20 lines
2.34.1 Everything seems to be correct: / # cat /sys/kernel/mm/transparent_hugepage/hugepages-16kB/enabled [always] inherit madvise never / # cat /sys/kernel/mm/transparent_hugepage/hugepages-32kB/enabled [always] inherit madvise never / # cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/enabled [always] inherit madvise never / # cat /sys/kernel/mm/transparent_hugepage/hugepages-128kB/enabled always [inherit] madvise never / # cat /sys/kernel/mm/transparent_hugepage/hugepages-256kB/enabled always inherit [madvise] never / # cat /sys/kernel/mm/transparent_hugepage/hugepages-512kB/enabled always [inherit] madvise never / # cat /sys/kernel/mm/transparent_hugepage/hugepages-1024kB/enabled always inherit madvise [never] / # cat /sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled always inherit madvise [never]
Quoted 17 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(one could also support ranges, like "16K-64K")
Would be even better. Then, maybe only allow a single instance.
Maybe consider it if it's not too crazy to parse ;)
I'll take a look. I'm going to be out for 3 weeks from end of Monday though, so
Oh, lucky you! Enjoy!
Quoted 3 lines
probably won't get around to that until I'm back. I know Barry is keen to get this merged, so Barry, if you'd like to take it over that's fine by me (I'm sure you have enough on your plate though).
Quoted 5 lines
--
Cheers,David / dhildenb
Thanks
Barry
Quoted 85 lines · Barry Song
Quoted 75 lines · David Hildenbrand
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
(quoted diff) +13
-4-You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:alwaysQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``.I suggest documenting that "thp_anon=" will not effect the value of "transparent_hugepage=", or any configured default.
Quoted 5 lines
Did you see the previous conversation with Barry about whether or not to honour configured defaults when any thp_anon= is provided [1]? Sounds like you also think we should honour the PMD "inherit" default if not explicitly provided on the command line? (see link for justification for the approach I'm currently taking).
I primarily think that we should document it :)
What if someone passes "transparent_hugepage=always" and "thp_anon=..."? I would assume that
transparent_hugepagewould only affect the global toggle then?Quoted 5 lines
[1]
https://lore.kernel.org/linux-mm/CAGsJ_4x8ruPspuk_FQVggJMWcXLbRuZFq44gg-Dt7Ewt3ExqTw@mail.gmail.com/Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Wondering if a syntax like
thp_anon=16K,32K,64K:always;1048K,2048K:madvise
Are there examples of that syntax already or have you just made it up? I found examples with the colon (:) but nothing this fancy. I guess that's not a reason not to do it though (other than the risk of screwing up the parser in a subtle way).
I made it up -- mostly ;) I think we are quite flexible on what we can do. As always, maybe we can keep it bit consistent with existing stuff.
For
hugetlb_cmawe have things like
"<node>:nn[KMGTPE|[,<node>:nn[KMGTPE]]"memmap=" options are more ... advanced, including memory ranges. There are a bunch more documented in kernel-parameters.txt that have more elaborate formats.
Ranges would probably be the most valuable addition. So maybe we should start with:
thp_anon=16K-64K:always,1048K-2048K:madvise
So to enable all THPs it would simply be
thp_anon=16K-2M:always
Interesting question what would happen if someone passes:
thp_anon=8K-2M:always
Quoted 8 lines
Likely we simply would apply it to any size in the range, even if start/end is not a THP size.
But we would want to complain to the user if someone only specifies a single one (or a range does not even select a single one) that does not exist:
thp_anon=8K:always
Quoted 8 lines
How about rejecting settings with any illegal size or policy?
I found there are too many corner cases to say "yes" or "no". It seems the code could be much cleaner if we simply reject illegal settings. On the other hand, we should rely on smart users to provide correct settings, shouldn’t we? While working one the code, I felt that extracting partial correct settings from incorrect ones and supporting them might be a bit of over-design.
No strong opinion on failing configs. Ignoring non-existing sizes might lead to more portable cmdlines between kernel versions.
Quoted 4 lines
I have tested the below code by
"thp_anon=16K-64K:always;128K,512K:inherit;256K:madvise;1M-2M:never"
There are some parameters that separate individual options by ";" already (config_acs). Most parameters use ",". No idea what's better here, and which separator to use for sizes instead when using "," for options. No strong opinion.
Signature · 3 lines
Cheers, David / dhildenb
Quoted 96 lines · David Hildenbrand
Quoted 85 lines · Barry Song
Quoted 75 lines · David Hildenbrand
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
(quoted diff) +13
-4-You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:alwaysQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``.I suggest documenting that "thp_anon=" will not effect the value of "transparent_hugepage=", or any configured default.
Quoted 5 lines
Did you see the previous conversation with Barry about whether or not to honour configured defaults when any thp_anon= is provided [1]? Sounds like you also think we should honour the PMD "inherit" default if not explicitly provided on the command line? (see link for justification for the approach I'm currently taking).
I primarily think that we should document it :)
What if someone passes "transparent_hugepage=always" and "thp_anon=..."? I would assume that
transparent_hugepagewould only affect the global toggle then?Quoted 5 lines
[1]
https://lore.kernel.org/linux-mm/CAGsJ_4x8ruPspuk_FQVggJMWcXLbRuZFq44gg-Dt7Ewt3ExqTw@mail.gmail.com/Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Wondering if a syntax like
thp_anon=16K,32K,64K:always;1048K,2048K:madvise
Are there examples of that syntax already or have you just made it up? I found examples with the colon (:) but nothing this fancy. I guess that's not a reason not to do it though (other than the risk of screwing up the parser in a subtle way).
I made it up -- mostly ;) I think we are quite flexible on what we can do. As always, maybe we can keep it bit consistent with existing stuff.
For
hugetlb_cmawe have things like"<node>:nn[KMGTPE|[,<node>:nn[KMGTPE]]"memmap=" options are more ... advanced, including memory ranges. There are a bunch more documented in kernel-parameters.txt that have more elaborate formats.
Ranges would probably be the most valuable addition. So maybe we should start with:
thp_anon=16K-64K:always,1048K-2048K:madviseSo to enable all THPs it would simply be
thp_anon=16K-2M:alwaysInteresting question what would happen if someone passes:
thp_anon=8K-2M:alwaysQuoted 8 lines
Likely we simply would apply it to any size in the range, even if start/end is not a THP size.
But we would want to complain to the user if someone only specifies a single one (or a range does not even select a single one) that does not exist:
thp_anon=8K:always
Quoted 8 lines
How about rejecting settings with any illegal size or policy?
I found there are too many corner cases to say "yes" or "no". It seems the code could be much cleaner if we simply reject illegal settings. On the other hand, we should rely on smart users to provide correct settings, shouldn’t we? While working one the code, I felt that extracting partial correct settings from incorrect ones and supporting them might be a bit of over-design.
Quoted 2 lines
No strong opinion on failing configs. Ignoring non-existing sizes might lead to more portable cmdlines between kernel versions.
Well, I realized that the code I posted has actually applied the correct parts because it modifies the global variable huge_anon_orders_xxx. Unless I use temporary variables and then copy the results to global ones, the code has been this issue to some extent.
maybe I should remove the below "goto err", instead, ignore the incorrect strings and go to the next strings to parse.
static int __init setup_thp_anon(char *str)
{
...
if (!strcmp(policy, "always")) {
set_bits(&huge_anon_orders_always, start, end);
clear_bits(&huge_anon_orders_inherit,
start, end);
clear_bits(&huge_anon_orders_madvise,
start, end);
} else if (!strcmp(policy, "madvise")) {
...
} else if (!strcmp(policy, "inherit")) {
...
} else if (!strcmp(policy, "never")) {
...
} else {
/* goto err; */ -> pr_err
}
}
}
...
err:
pr_warn("thp_anon=%s: cannot parse(invalid size or policy),
ignored\n", str);
return 0;
}Quoted 10 lines
Quoted 5 lines
I have tested the below code by
"thp_anon=16K-64K:always;128K,512K:inherit;256K:madvise;1M-2M:never"
There are some parameters that separate individual options by ";" already (
config_acs). Most parameters use ",". No idea what's better here, and which separator to use for sizes instead when using "," for options. No strong opinion.
But we have used "," for the purpose "128K,512K:inherit". so here we have to use ";" for "16K-64K:always;128K,512K:inherit"
Quoted 6 lines
--
Cheers,David / dhildenb
Thanks
Barry
Quoted 100 lines · Barry Song
Quoted 96 lines · David Hildenbrand
Quoted 85 lines · Barry Song
Quoted 75 lines · David Hildenbrand
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
(quoted diff) +13
-4-You can change the sysfs boot time defaults of Transparent Hugepage -Support by passing the parameter ``transparent_hugepage=always`` or -``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` -to the kernel command line. +You can change the sysfs boot time default for the top-level "enabled" +control by passing the parameter ``transparent_hugepage=always`` or +``transparent_hugepage=madvise`` or ``transparent_hugepage=never`` to the +kernel command line. + +Alternatively, each supported anonymous THP size can be controlled by +passing ``thp_anon=<size>[KMG]:<state>``, where ``<size>`` is the THP size +and ``<state>`` is one of ``always``, ``madvise``, ``never`` or +``inherit``. + +For example, the following will set 64K THP to ``always``:: + + thp_anon=64K:alwaysQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ +``thp_anon=`` may be specified multiple times to configure all THP sizes as +required. If ``thp_anon=`` is specified at least once, any anon THP sizes +not explicitly configured on the command line are implicitly set to +``never``.I suggest documenting that "thp_anon=" will not effect the value of "transparent_hugepage=", or any configured default.
Quoted 5 lines
Did you see the previous conversation with Barry about whether or not to honour configured defaults when any thp_anon= is provided [1]? Sounds like you also think we should honour the PMD "inherit" default if not explicitly provided on the command line? (see link for justification for the approach I'm currently taking).
I primarily think that we should document it :)
What if someone passes "transparent_hugepage=always" and "thp_anon=..."? I would assume that
transparent_hugepagewould only affect the global toggle then?Quoted 5 lines
[1]
https://lore.kernel.org/linux-mm/CAGsJ_4x8ruPspuk_FQVggJMWcXLbRuZFq44gg-Dt7Ewt3ExqTw@mail.gmail.com/Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Wondering if a syntax like
thp_anon=16K,32K,64K:always;1048K,2048K:madvise
Are there examples of that syntax already or have you just made it up? I found examples with the colon (:) but nothing this fancy. I guess that's not a reason not to do it though (other than the risk of screwing up the parser in a subtle way).
I made it up -- mostly ;) I think we are quite flexible on what we can do. As always, maybe we can keep it bit consistent with existing stuff.
For
hugetlb_cmawe have things like"<node>:nn[KMGTPE|[,<node>:nn[KMGTPE]]"memmap=" options are more ... advanced, including memory ranges. There are a bunch more documented in kernel-parameters.txt that have more elaborate formats.
Ranges would probably be the most valuable addition. So maybe we should start with:
thp_anon=16K-64K:always,1048K-2048K:madviseSo to enable all THPs it would simply be
thp_anon=16K-2M:alwaysInteresting question what would happen if someone passes:
thp_anon=8K-2M:alwaysQuoted 8 lines
Likely we simply would apply it to any size in the range, even if start/end is not a THP size.
But we would want to complain to the user if someone only specifies a single one (or a range does not even select a single one) that does not exist:
thp_anon=8K:always
Quoted 8 lines
How about rejecting settings with any illegal size or policy?
I found there are too many corner cases to say "yes" or "no". It seems the code could be much cleaner if we simply reject illegal settings. On the other hand, we should rely on smart users to provide correct settings, shouldn’t we? While working one the code, I felt that extracting partial correct settings from incorrect ones and supporting them might be a bit of over-design.
Quoted 2 lines
No strong opinion on failing configs. Ignoring non-existing sizes might lead to more portable cmdlines between kernel versions.
Quoted 7 lines
Well, I realized that the code I posted has actually applied the correct parts because it modifies the global variable
huge_anon_orders_xxx. Unless I use temporary variables and then copy the results to global ones, the code has been this issue to some extent.maybe I should remove the below "goto err", instead, ignore the incorrect strings and go to the next strings to parse.
I'll have to look at the full patch to be able to have an opinion :)
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
I have tested the below code by
"thp_anon=16K-64K:always;128K,512K:inherit;256K:madvise;1M-2M:never"
Quoted 7 lines
Quoted 4 lines
There are some parameters that separate individual options by ";" already (
config_acs). Most parameters use ",". No idea what's better here, and which separator to use for sizes instead when using "," for options. No strong opinion.But we have used "," for the purpose "128K,512K:inherit". so here we have to use ";" for "16K-64K:always;128K,512K:inherit"
I know -- I proposed that format -- but I wonder if there is an alternative that would let use use "," in-between options.
Staring at various formats in Documentation/admin-guide/kernel-parameters.txt, I'm not able to come up with something "obviously better".
Signature · 3 lines
Cheers, David / dhildenb