From: Barry Song <21cnbao@gmail.com>
To: akpm@linux-foundation.org
Cc: baohua@kernel.org, baolin.wang@linux.alibaba.com, corbet@lwn.net,
david@redhat.com, ioworker0@gmail.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
ryan.roberts@arm.com, v-songbaohua@oppo.com
Subject: Re: [PATCH v4] mm: Override mTHP "enabled" defaults at kernel cmdline
Date: Thu, 15 Aug 2024 10:46:35 +1200 [thread overview]
Message-ID: <20240814224635.43272-1-21cnbao@gmail.com> (raw)
In-Reply-To: <20240814020247.67297-1-21cnbao@gmail.com>
On Wed, Aug 14, 2024 at 2:03 PM Barry Song <21cnbao@gmail.com> wrote:
>
> From: Ryan Roberts <ryan.roberts@arm.com>
>
> 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>,<size>[KMG]:<value>;<size>-<size>[KMG]:<value>
>
> An example:
>
> thp_anon=16K-64K:always;128K,512K:inherit;256K:madvise;1M-2M:never
>
> 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.
>
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
> Co-developed-by: Barry Song <v-songbaohua@oppo.com>
> Signed-off-by: Barry Song <v-songbaohua@oppo.com>
> ---
Hi Andrew,
I saw you have pulled v4. Thanks!
Can you please squash the below changes suggested by Baolin and David?
From af42aa80f45d89798027e44a8711f7737e08b115 Mon Sep 17 00:00:00 2001
From: Barry Song <v-songbaohua@oppo.com>
Date: Thu, 15 Aug 2024 10:34:16 +1200
Subject: [PATCH] mm: use get_oder() and check size is is_power_of_2
Using get_order() is more robust according to Baolin.
It is also better to filter illegal size such as 3KB,
16KB according to David.
Suggested-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Suggested-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Barry Song <v-songbaohua@oppo.com>
---
mm/huge_memory.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 01beda16aece..d6dade8ac5f6 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -952,14 +952,17 @@ static inline int get_order_from_str(const char *size_str)
int order;
size = memparse(size_str, &endptr);
- order = fls(size >> PAGE_SHIFT) - 1;
- if ((1 << order) & ~THP_ORDERS_ALL_ANON) {
- pr_err("invalid size %s(order %d) in thp_anon boot parameter\n",
- size_str, order);
- return -EINVAL;
- }
+
+ if (!is_power_of_2(size >> PAGE_SHIFT))
+ goto err;
+ order = get_order(size);
+ if ((1 << order) & ~THP_ORDERS_ALL_ANON)
+ goto err;
return order;
+err:
+ pr_err("invalid size %s in thp_anon boot parameter\n", size_str);
+ return -EINVAL;
}
static char str_dup[PAGE_SIZE] __meminitdata;
--
2.34.1
Thanks
Barry
prev parent reply other threads:[~2024-08-14 22:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 2:02 Barry Song
2024-08-14 7:53 ` Baolin Wang
2024-08-14 8:09 ` Barry Song
2024-08-14 8:18 ` David Hildenbrand
2024-08-14 8:54 ` Barry Song
2024-08-15 10:26 ` David Hildenbrand
2024-08-15 23:50 ` Barry Song
2024-08-16 9:33 ` David Hildenbrand
2024-08-16 9:47 ` Barry Song
2024-08-14 22:46 ` 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=20240814224635.43272-1-21cnbao@gmail.com \
--to=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=corbet@lwn.net \
--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=v-songbaohua@oppo.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