+ mm-override-mthp-enabled-defaults-at-kernel-cmdline-v6.patch added to mm-unstable branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm: override mTHP "enabled" defaults at kernel cmdline
has been added to the -mm mm-unstable branch.  Its filename is
     mm-override-mthp-enabled-defaults-at-kernel-cmdline-v6.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-override-mthp-enabled-defaults-at-kernel-cmdline-v6.patch

This patch will later appear in the mm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Ryan Roberts <ryan.roberts@xxxxxxx>
Subject: mm: override mTHP "enabled" defaults at kernel cmdline
Date: Tue, 20 Aug 2024 22:52:44 +1200

some minor cleanup according to David's comments

Link: https://lkml.kernel.org/r/20240820105244.62703-1-21cnbao@xxxxxxxxx
Signed-off-by: Ryan Roberts <ryan.roberts@xxxxxxx>
Co-developed-by: Barry Song <v-songbaohua@xxxxxxxx>
Signed-off-by: Barry Song <v-songbaohua@xxxxxxxx>
Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
Tested-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
Acked-by: David Hildenbrand <david@xxxxxxxxxx>
Cc: Jonathan Corbet <corbet@xxxxxxx>
Cc: Lance Yang <ioworker0@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 Documentation/admin-guide/kernel-parameters.txt |    4 -
 Documentation/admin-guide/mm/transhuge.rst      |    5 +
 mm/huge_memory.c                                |   41 ++++++--------
 3 files changed, 25 insertions(+), 25 deletions(-)

--- a/Documentation/admin-guide/kernel-parameters.txt~mm-override-mthp-enabled-defaults-at-kernel-cmdline-v6
+++ a/Documentation/admin-guide/kernel-parameters.txt
@@ -6632,8 +6632,8 @@
 	thp_anon=	[KNL]
 			Format: <size>,<size>[KMG]:<state>;<size>-<size>[KMG]:<state>
 			state is one of "always", "madvise", "never" or "inherit".
-			Can be used to control the default behavior of the
-			system with respect to anonymous transparent hugepages.
+			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.
--- a/Documentation/admin-guide/mm/transhuge.rst~mm-override-mthp-enabled-defaults-at-kernel-cmdline-v6
+++ a/Documentation/admin-guide/mm/transhuge.rst
@@ -294,8 +294,9 @@ kernel command line.
 
 Alternatively, each supported anonymous THP size can be controlled by
 passing ``thp_anon=<size>,<size>[KMG]:<state>;<size>-<size>[KMG]:<state>``,
-where ``<size>`` is the THP size and ``<state>`` is one of ``always``,
-``madvise``, ``never`` or ``inherit``.
+where ``<size>`` is the THP size (must be a power of 2 of PAGE_SIZE and
+supported anonymous THP)  and ``<state>`` is one of ``always``, ``madvise``,
+``never`` or ``inherit``.
 
 For example, the following will set 16K, 32K, 64K THP to ``always``,
 set 128K, 512K to ``inherit``, set 256K to ``madvise`` and 1M, 2M
--- a/mm/huge_memory.c~mm-override-mthp-enabled-defaults-at-kernel-cmdline-v6
+++ a/mm/huge_memory.c
@@ -81,7 +81,7 @@ unsigned long huge_zero_pfn __read_mostl
 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;
+static bool anon_orders_configured __initdata;
 
 unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma,
 					 unsigned long vm_flags,
@@ -734,10 +734,8 @@ static int __init hugepage_init_sysfs(st
 	 * disable all other sizes. powerpc's PMD_ORDER isn't a compile-time
 	 * constant so we have to do this here.
 	 */
-	if (!anon_orders_configured) {
+	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)) {
@@ -930,10 +928,10 @@ static inline int get_order_from_str(con
 
 	size = memparse(size_str, &endptr);
 
-	if (!is_power_of_2(size >> PAGE_SHIFT))
+	if (!is_power_of_2(size))
 		goto err;
 	order = get_order(size);
-	if ((1 << order) & ~THP_ORDERS_ALL_ANON)
+	if (BIT(order) & ~THP_ORDERS_ALL_ANON)
 		goto err;
 
 	return order;
@@ -942,13 +940,13 @@ err:
 	return -EINVAL;
 }
 
-static char str_dup[PAGE_SIZE] __meminitdata;
+static char str_dup[PAGE_SIZE] __initdata;
 static int __init setup_thp_anon(char *str)
 {
 	char *token, *range, *policy, *subtoken;
 	unsigned long always, inherit, madvise;
 	char *start_size, *end_size;
-	int start, end;
+	int start, end, nr;
 	char *p;
 
 	if (!str || strlen(str) + 1 > PAGE_SIZE)
@@ -980,22 +978,23 @@ static int __init setup_thp_anon(char *s
 			if (start < 0 || end < 0 || start > end)
 				goto err;
 
+			nr = end - start + 1;
 			if (!strcmp(policy, "always")) {
-				bitmap_set(&always, start, end - start + 1);
-				bitmap_clear(&inherit, start, end - start + 1);
-				bitmap_clear(&madvise, start, end - start + 1);
+				bitmap_set(&always, start, nr);
+				bitmap_clear(&inherit, start, nr);
+				bitmap_clear(&madvise, start, nr);
 			} else if (!strcmp(policy, "madvise")) {
-				bitmap_set(&madvise, start, end - start + 1);
-				bitmap_clear(&inherit, start, end - start + 1);
-				bitmap_clear(&always, start, end - start + 1);
+				bitmap_set(&madvise, start, nr);
+				bitmap_clear(&inherit, start, nr);
+				bitmap_clear(&always, start, nr);
 			} else if (!strcmp(policy, "inherit")) {
-				bitmap_set(&inherit, start, end - start + 1);
-				bitmap_clear(&madvise, start, end - start + 1);
-				bitmap_clear(&always, start, end - start + 1);
+				bitmap_set(&inherit, start, nr);
+				bitmap_clear(&madvise, start, nr);
+				bitmap_clear(&always, start, nr);
 			} else if (!strcmp(policy, "never")) {
-				bitmap_clear(&inherit, start, end - start + 1);
-				bitmap_clear(&madvise, start, end - start + 1);
-				bitmap_clear(&always, start, end - start + 1);
+				bitmap_clear(&inherit, start, nr);
+				bitmap_clear(&madvise, start, nr);
+				bitmap_clear(&always, start, nr);
 			} else {
 				pr_err("invalid policy %s in thp_anon boot parameter\n", policy);
 				goto err;
@@ -1010,7 +1009,7 @@ static int __init setup_thp_anon(char *s
 	return 1;
 
 err:
-	pr_warn("thp_anon=%s: cannot parse, ignored\n", str);
+	pr_warn("thp_anon=%s: error parsing string, ignoring setting\n", str);
 	return 0;
 }
 __setup("thp_anon=", setup_thp_anon);
_

Patches currently in -mm which might be from ryan.roberts@xxxxxxx are

mm-cleanup-count_mthp_stat-definition.patch
mm-tidy-up-shmem-mthp-controls-and-stats.patch
mm-override-mthp-enabled-defaults-at-kernel-cmdline.patch
mm-override-mthp-enabled-defaults-at-kernel-cmdline-v6.patch





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux