linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hao Peng <flyingpenghao@gmail.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: David Hildenbrand <david@redhat.com>,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH v2] mm/huge_memory.c: disable THP with large THP size on small present memory
Date: Sat, 9 Oct 2021 09:28:56 +0800	[thread overview]
Message-ID: <CAPm50a+E6mm_qA9h9MSvh4K+WA8Qf6mU=2yig5GyVw9GFJzr8g@mail.gmail.com> (raw)
In-Reply-To: <20211008095123.73b4bubwrpdj6tuz@box.shutemov.name>

On Fri, Oct 8, 2021 at 5:51 PM Kirill A. Shutemov <kirill@shutemov.name> wrote:
>
> On Fri, Oct 08, 2021 at 09:22:00AM +0800, Hao Peng wrote:
> > From: Peng Hao <flyingpeng@tencent.com>
> >
> > After setting 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. But if THP is enabled, min_free_kbytes will
> > be recalculated. At this time, min_free_kbytes is calculated based
> > on the size of THP.
> >
> > 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.
> >
> > V2: title suggested by David Hildenbrand
> >
> > 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))) {
>
> On x86-64 HPAGE_PMD_SHIFT is 21, so you double the amount of memory
> required to enabled THP by default. It doesn't seem to be the intent of
> the patch.
>
> What about something like
>
>         if (totalram_pages() < 256 * HPAGE_PMD_NR)
>
> ?
>
I think that setting the threshold to 512M here is also a rough
estimate. If it is 512M
of memory and 2M of THP is used, there are only 256 pages in total.
This is actually
too small. In addition, THP is disabled by default, but you can also enable THP
dynamically.
Thanks.
> >                 transparent_hugepage_flags = 0;
> >                 return 0;
> >         }
> > --
> > 2.27.0
> >
>
> --
>  Kirill A. Shutemov

  reply	other threads:[~2021-10-09  1:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08  1:22 [PATCH v2] mm/huge_memory.c: disable THP with large THP size on small present memory Hao Peng
2021-10-08  9:51 ` Kirill A. Shutemov
2021-10-09  1:28   ` Hao Peng [this message]
2021-10-10 22:43     ` David Rientjes
2021-10-11  3:55       ` Hao Peng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPm50a+E6mm_qA9h9MSvh4K+WA8Qf6mU=2yig5GyVw9GFJzr8g@mail.gmail.com' \
    --to=flyingpenghao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).