linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/huge_memory: disable thp if thp page size is too large
@ 2021-09-30  2:14 Hao Peng
  2021-09-30 13:19 ` David Hildenbrand
  0 siblings, 1 reply; 4+ messages in thread
From: Hao Peng @ 2021-09-30  2:14 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel

From: Peng Hao <flyingpeng@tencent.com>

After seting the page size to 64k on ARM64, the supported huge page
size is 512M and 1TB. Therefore, if the thp is enabled, the size
of the thp is 512M. In this case, min_free_kbytes will be too large.

On an arm64 server with 64G memory, the page size is 64k, with thp
enabled.
cat /proc/sys/vm/min_free_kbytes
3335104

Therefore, when judging whether to enable thp by default, consider
the size of thp.

Signed-off-by: Peng Hao <flyingpeng@tencent.com>
---
 mm/huge_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 5e9ef0fc261e..03c7f571b3ae 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -437,7 +437,7 @@ static int __init hugepage_init(void)
         * where the extra memory used could hurt more than TLB overhead
         * is likely to save.  The admin can still enable it through /sys.
         */
-       if (totalram_pages() < (512 << (20 - PAGE_SHIFT))) {
+       if (totalram_pages() < (512 << (HPAGE_PMD_SHIFT - PAGE_SHIFT))) {
                transparent_hugepage_flags = 0;
                return 0;
        }
--
2.27.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/huge_memory: disable thp if thp page size is too large
  2021-09-30  2:14 [PATCH] mm/huge_memory: disable thp if thp page size is too large Hao Peng
@ 2021-09-30 13:19 ` David Hildenbrand
  2021-10-06  8:16   ` Hao Peng
  0 siblings, 1 reply; 4+ messages in thread
From: David Hildenbrand @ 2021-09-30 13:19 UTC (permalink / raw)
  To: Hao Peng, akpm; +Cc: linux-mm, linux-kernel

On 30.09.21 04:14, Hao Peng wrote:
> From: Peng Hao <flyingpeng@tencent.com>

"disable thp if thp page size is too large" you disable thp if there is 
not sufficient memory installed in the system (and for that, you use THP 
size), something doesn't add up here.

> 
> After seting the page size to 64k on ARM64, the supported huge page

s/seting/setting/

Fortunately, most distributions already switched to 4k, because 512MB 
THP is pretty much useless, especially on any system that doesn't have 
memory in the range of hundreds of megabytes or terrabytes.

> size is 512M and 1TB. Therefore, if the thp is enabled, the size
> of the thp is 512M. In this case, min_free_kbytes will be too large.
> 
> On an arm64 server with 64G memory, the page size is 64k, with thp
> enabled.
> cat /proc/sys/vm/min_free_kbytes
> 3335104
> 
> Therefore, when judging whether to enable thp by default, consider
> the size of thp.
> 
> Signed-off-by: Peng Hao <flyingpeng@tencent.com>
> ---
>   mm/huge_memory.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 5e9ef0fc261e..03c7f571b3ae 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -437,7 +437,7 @@ static int __init hugepage_init(void)
>           * where the extra memory used could hurt more than TLB overhead
>           * is likely to save.  The admin can still enable it through /sys.
>           */
> -       if (totalram_pages() < (512 << (20 - PAGE_SHIFT))) {
> +       if (totalram_pages() < (512 << (HPAGE_PMD_SHIFT - PAGE_SHIFT))) {
>                  transparent_hugepage_flags = 0;
>                  return 0;
>          }
> --
> 2.27.0
> 


-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/huge_memory: disable thp if thp page size is too large
  2021-09-30 13:19 ` David Hildenbrand
@ 2021-10-06  8:16   ` Hao Peng
  2021-10-06  8:20     ` David Hildenbrand
  0 siblings, 1 reply; 4+ messages in thread
From: Hao Peng @ 2021-10-06  8:16 UTC (permalink / raw)
  To: David Hildenbrand; +Cc: akpm, linux-mm, linux-kernel

On Thu, Sep 30, 2021 at 9:19 PM David Hildenbrand <david@redhat.com> wrote:
>
> On 30.09.21 04:14, Hao Peng wrote:
> > From: Peng Hao <flyingpeng@tencent.com>
>
> "disable thp if thp page size is too large" you disable thp if there is
> not sufficient memory installed in the system (and for that, you use THP
> size), something doesn't add up here.
>
In addition, if THP is enabled, min_free_kbytes will be recalculated.
At this time,
min_free_kbytes is calculated based on the size of THP. If the size of
THP is too l
arge, OOM will easily be triggered.
> >
> > After seting the page size to 64k on ARM64, the supported huge page
>
> s/seting/setting/
>
> Fortunately, most distributions already switched to 4k, because 512MB
> THP is pretty much useless, especially on any system that doesn't have
> memory in the range of hundreds of megabytes or terrabytes.
But the ARM64 Server distribution version I use, such as CentOS for ARM64,
 has a page size of 16KB or 64KB.
Thanks.
>
> > size is 512M and 1TB. Therefore, if the thp is enabled, the size
> > of the thp is 512M. In this case, min_free_kbytes will be too large.
> >
> > On an arm64 server with 64G memory, the page size is 64k, with thp
> > enabled.
> > cat /proc/sys/vm/min_free_kbytes
> > 3335104
> >
> > Therefore, when judging whether to enable thp by default, consider
> > the size of thp.
> >
> > Signed-off-by: Peng Hao <flyingpeng@tencent.com>
> > ---
> >   mm/huge_memory.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> > index 5e9ef0fc261e..03c7f571b3ae 100644
> > --- a/mm/huge_memory.c
> > +++ b/mm/huge_memory.c
> > @@ -437,7 +437,7 @@ static int __init hugepage_init(void)
> >           * where the extra memory used could hurt more than TLB overhead
> >           * is likely to save.  The admin can still enable it through /sys.
> >           */
> > -       if (totalram_pages() < (512 << (20 - PAGE_SHIFT))) {
> > +       if (totalram_pages() < (512 << (HPAGE_PMD_SHIFT - PAGE_SHIFT))) {
> >                  transparent_hugepage_flags = 0;
> >                  return 0;
> >          }
> > --
> > 2.27.0
> >
>
>
> --
> Thanks,
>
> David / dhildenb
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/huge_memory: disable thp if thp page size is too large
  2021-10-06  8:16   ` Hao Peng
@ 2021-10-06  8:20     ` David Hildenbrand
  0 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2021-10-06  8:20 UTC (permalink / raw)
  To: Hao Peng; +Cc: akpm, linux-mm, linux-kernel

On 06.10.21 10:16, Hao Peng wrote:
> On Thu, Sep 30, 2021 at 9:19 PM David Hildenbrand <david@redhat.com> wrote:
>>
>> On 30.09.21 04:14, Hao Peng wrote:
>>> From: Peng Hao <flyingpeng@tencent.com>
>>
>> "disable thp if thp page size is too large" you disable thp if there is
>> not sufficient memory installed in the system (and for that, you use THP
>> size), something doesn't add up here.
>>
> In addition, if THP is enabled, min_free_kbytes will be recalculated.
> At this time,
> min_free_kbytes is calculated based on the size of THP. If the size of
> THP is too l
> arge, OOM will easily be triggered.

Right, I was pointing at the misleading $subject. What about something like:

"mm/huge_memory: disable THP with large THP size on small present memory" ?

>>>
>>> After seting the page size to 64k on ARM64, the supported huge page
>>
>> s/seting/setting/
>>
>> Fortunately, most distributions already switched to 4k, because 512MB
>> THP is pretty much useless, especially on any system that doesn't have
>> memory in the range of hundreds of megabytes or terrabytes.
> But the ARM64 Server distribution version I use, such as CentOS for ARM64,
>   has a page size of 16KB or 64KB.

Yeah, RHEL8 and CENTOS8 are the last remaining "recent distirbutions" 
I'm aware of.


-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-06  8:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30  2:14 [PATCH] mm/huge_memory: disable thp if thp page size is too large Hao Peng
2021-09-30 13:19 ` David Hildenbrand
2021-10-06  8:16   ` Hao Peng
2021-10-06  8:20     ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).