[PATCH 03/12] mm: shmem: don't expose 'deny' and 'force' via the kernel command line
From: Baolin Wang
Date: Fri Sep 18 2026 - 00:00:22 EST
Based on the previous discussion with Lorenzo[1], the 'deny' and 'force'
options are testing-only configurations and shouldn't be exposed via the
shmem kernel command line.
So drop these debug options from the shmem kernel command line and update
the documentation to make this clear.
[1] https://lore.kernel.org/all/6e4aae7b-2c71-4109-945c-6481efde3636@xxxxxxxxxxxxxxxxx/
Suggested-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
Signed-off-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
---
Documentation/admin-guide/mm/transhuge.rst | 4 ++--
mm/shmem.c | 12 ++++++------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst
index b187d618452f..0a8265d1cb55 100644
--- a/Documentation/admin-guide/mm/transhuge.rst
+++ b/Documentation/admin-guide/mm/transhuge.rst
@@ -389,8 +389,8 @@ is not defined within a valid ``thp_anon``, its policy will default to
Similarly to ``transparent_hugepage``, you can control the hugepage
allocation policy for the internal shmem mount by using the kernel parameter
``transparent_hugepage_shmem=<policy>``, where ``<policy>`` is one of the
-seven valid policies for shmem (``always``, ``within_size``, ``advise``,
-``never``, ``deny``, and ``force``).
+four valid policies for shmem (``always``, ``within_size``, ``advise``,
+``never``).
Similarly to ``transparent_hugepage_shmem``, you can control the default
hugepage allocation policy for the tmpfs mount by using the kernel parameter
diff --git a/mm/shmem.c b/mm/shmem.c
index b572c60f2af8..951e922091fe 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -668,7 +668,7 @@ static unsigned int shmem_huge_global_enabled(struct inode *inode, pgoff_t index
}
}
-static int shmem_parse_huge(const char *str)
+static int shmem_parse_huge(const char *str, bool skip_deny_force)
{
int huge;
@@ -683,9 +683,9 @@ static int shmem_parse_huge(const char *str)
huge = SHMEM_HUGE_WITHIN_SIZE;
else if (!strcmp(str, "advise"))
huge = SHMEM_HUGE_ADVISE;
- else if (!strcmp(str, "deny"))
+ else if (!strcmp(str, "deny") && !skip_deny_force)
huge = SHMEM_HUGE_DENY;
- else if (!strcmp(str, "force"))
+ else if (!strcmp(str, "force") && !skip_deny_force)
huge = SHMEM_HUGE_FORCE;
else
return -EINVAL;
@@ -5680,7 +5680,7 @@ static ssize_t shmem_enabled_store(struct kobject *kobj,
if (count && tmp[count - 1] == '\n')
tmp[count - 1] = '\0';
- huge = shmem_parse_huge(tmp);
+ huge = shmem_parse_huge(tmp, /*skip_deny_force=*/false);
if (huge == -EINVAL)
return huge;
@@ -5807,7 +5807,7 @@ static int __init setup_transparent_hugepage_shmem(char *str)
{
int huge;
- huge = shmem_parse_huge(str);
+ huge = shmem_parse_huge(str, /*skip_deny_force=*/true);
if (huge == -EINVAL) {
pr_warn("transparent_hugepage_shmem= cannot parse, ignored\n");
return huge;
@@ -5822,7 +5822,7 @@ static int __init setup_transparent_hugepage_tmpfs(char *str)
{
int huge;
- huge = shmem_parse_huge(str);
+ huge = shmem_parse_huge(str, /*skip_deny_force=*/true);
if (huge < 0) {
pr_warn("transparent_hugepage_tmpfs= cannot parse, ignored\n");
return huge;
--
2.47.3