linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Barry Song <21cnbao@gmail.com>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	 linux-kernel@vger.kernel.org, Barry Song <v-songbaohua@oppo.com>,
	 Lance Yang <ioworker0@gmail.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	 David Hildenbrand <david@redhat.com>,
	Yang Shi <shy828301@gmail.com>, Zi Yan <ziy@nvidia.com>
Subject: Re: [PATCH] mm: huge_memory: don't start_stop_khugepaged for non-PMD THP
Date: Fri, 26 Jul 2024 22:11:38 +1200	[thread overview]
Message-ID: <CAGsJ_4wnc_qYyvHF5xdvsRpR1cXAnBSf93HiyOBhz1RTcOH0zg@mail.gmail.com> (raw)
In-Reply-To: <aeb0fcb9-7c84-4bc4-b89a-5f0f86478aaf@arm.com>

On Fri, Jul 26, 2024 at 9:43 PM Ryan Roberts <ryan.roberts@arm.com> wrote:
>
> On 26/07/2024 09:28, Barry Song wrote:
> > From: Barry Song <v-songbaohua@oppo.com>
> >
> > khugepaged will be automatically started when PMD-sized THP is enabled
> > (either of the per-size anon control or the top-level control are set
> > to "always" or "madvise"), and it'll be automatically shutdown when
> > PMD-sized THP is disabled (when both the per-size anon control and the
> > top-level control are "never").
> >
> > It seems unnecessary to call start_stop_khugepaged() for non-PMD THP,
> > as it would only waste CPU time.
> >
> > Cc: Lance Yang <ioworker0@gmail.com>
> > Cc: Ryan Roberts <ryan.roberts@arm.com>
> > Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Yang Shi <shy828301@gmail.com>
> > Cc: Zi Yan <ziy@nvidia.com>
> > Signed-off-by: Barry Song <v-songbaohua@oppo.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 41460847988c..bd365e35acf7 100644
> > --- a/mm/huge_memory.c
> > +++ b/mm/huge_memory.c
> > @@ -514,7 +514,7 @@ static ssize_t thpsize_enabled_store(struct kobject *kobj,
> >       } else
> >               ret = -EINVAL;
> >
> > -     if (ret > 0) {
> > +     if (ret > 0 && order == HPAGE_PMD_ORDER) {
> >               int err;
> >
> >               err = start_stop_khugepaged();
>
> Personally I see this as a bit of a layering violation; its
> start_stop_khugepaged() that should decide the policy for when to start and stop
> the daemon. thpsize_enabled_store() should just be calling
> start_stop_khugepaged() to notify that something potentially pertinent to the a
> policy decision has changed.
>
> And I don't think this should be a hot path; I'd expect the global thp size
> configuration to be set at boot and remain pretty static. Do you have evidence
> to the contrary?

Absolutely no, I was reading and patching the doc
"Documentation/admin-guide/mm/transhuge.rst"
and was also copying-paste your "enabled" code to "swapin_enabled" with dropping
start_stop_khugepaged() in that case. I believe I don't need it for
enabling/disabling
swapin as swapin is a subset of mTHP not a main entry.

just feel a bit inconsistency between the doc and the code at least for this
moment:
khugepaged will be automatically started when PMD-sized THP is enabled
(either of the per-size anon control or the top-level control are set
to "always" or "madvise"), and it'll be automatically shutdown when
PMD-sized THP is disabled (when both the per-size anon control and the
top-level control are "never").

which triggered me to make this change.

Thanks
Barry


      parent reply	other threads:[~2024-07-26 10:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-26  8:28 Barry Song
2024-07-26  9:43 ` Ryan Roberts
2024-07-26  9:48   ` David Hildenbrand
2024-07-26 10:04     ` Barry Song
2024-07-26 10:45       ` Ryan Roberts
2024-07-26 11:00         ` Barry Song
2024-07-26 11:06           ` Ryan Roberts
2024-07-26 10:11   ` Barry Song [this message]

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=CAGsJ_4wnc_qYyvHF5xdvsRpR1cXAnBSf93HiyOBhz1RTcOH0zg@mail.gmail.com \
    --to=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=ioworker0@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=shy828301@gmail.com \
    --cc=v-songbaohua@oppo.com \
    --cc=ziy@nvidia.com \
    /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