* Re: [PATCH] tmpfs: reset the memory policy on remount with mpol=default
2026-11-27 23:00 [PATCH] tmpfs: reset the memory policy on remount with mpol=default Yifan Feng
@ 2026-11-28 0:10 ` Andrew Morton
2026-11-28 19:03 ` Yifan Feng
2026-11-28 0:11 ` + tmpfs-reset-the-memory-policy-on-remount-with-mpol=default.patch added to mm-new branch Andrew Morton
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 0:10 UTC (permalink / raw)
To: Yifan Feng
Cc: Hugh Dickins, David Hildenbrand, Baolin Wang, Greg Thelen,
linux-mm, linux-kernel
On Fri, 27 Nov 2026 15:00:15 -0800 Yifan Feng <evanfengff@gmail.com> wrote:
> mpol_parse_str() returns a NULL policy for "default", and
> shmem_reconfigure() takes a NULL ctx->mpol to mean that no mpol option
> was given. So a remount with mpol=default succeeds but keeps the old
> policy:
>
> # mount -t tmpfs -o mpol=bind:1 none /mnt
> # mount -o remount,mpol=default /mnt
> # grep /mnt /proc/mounts
> none /mnt tmpfs rw,relatime,mpol=bind:1 0 0
>
> Record that an mpol option was parsed, and replace the policy whenever
> one was.
Oh.
So aiui, remounting with mpol=default "succeeds", but new file
policies still get the old mempolicy instead of using the "process
allocation policy"?
hp2:/usr/src/mm> egrep -r "mempolicy|mpol" tools/testing/selftests/mm
tools/testing/selftests/mm/mkdirty.c:#include <linux/mempolicy.h>
hp2:/usr/src/mm>
Oh.
> Fixes: 5f00110f7273 ("tmpfs: fix use-after-free of mempolicy object")
+cc:stable. Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] tmpfs: reset the memory policy on remount with mpol=default
2026-11-28 0:10 ` Andrew Morton
@ 2026-11-28 19:03 ` Yifan Feng
2026-11-28 19:33 ` Andrew Morton
0 siblings, 1 reply; 9+ messages in thread
From: Yifan Feng @ 2026-11-28 19:03 UTC (permalink / raw)
To: Andrew Morton
Cc: Hugh Dickins, David Hildenbrand, Baolin Wang, Greg Thelen,
linux-mm, linux-kernel
On Fri, 27 Nov 2026 16:10:49 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:
> So aiui, remounting with mpol=default "succeeds", but new file
> policies still get the old mempolicy instead of using the "process
> allocation policy"?
Yes. The remount returns 0, /proc/mounts keeps the old mpol=, and
files created after it are still allocated by the old policy. In a
2-node guest, after mount mpol=interleave:0-1 and remount,mpol=default,
a new 32 MB file was still 16 MB on each node. With the patch it is
all on the node of the writing task.
> hp2:/usr/src/mm> egrep -r "mempolicy|mpol" tools/testing/selftests/mm
I can write a selftest for the tmpfs mpol= option if that is welcome.
Thanks,
Yifan
^ permalink raw reply [flat|nested] 9+ messages in thread
* + tmpfs-reset-the-memory-policy-on-remount-with-mpol=default.patch added to mm-new branch
2026-11-27 23:00 [PATCH] tmpfs: reset the memory policy on remount with mpol=default Yifan Feng
2026-11-28 0:10 ` Andrew Morton
@ 2026-11-28 0:11 ` Andrew Morton
2026-11-29 8:36 ` David Hildenbrand (Arm)
2026-11-29 21:25 ` [-] tmpfs-reset-the-memory-policy-on-remount-with-mpol=default.patch removed from -mm tree Andrew Morton
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2026-11-28 0:11 UTC (permalink / raw)
To: mm-commits, hughd, gthelen, david, baolin.wang, evanfengff, akpm
The patch titled
Subject: tmpfs: reset the memory policy on remount with mpol=default
has been added to the -mm mm-new branch. Its filename is
tmpfs-reset-the-memory-policy-on-remount-with-mpol=default.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/tmpfs-reset-the-memory-policy-on-remount-with-mpol=default.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
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 various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Yifan Feng <evanfengff@gmail.com>
Subject: tmpfs: reset the memory policy on remount with mpol=default
Date: Fri, 27 Nov 2026 15:00:15 -0800
mpol_parse_str() returns a NULL policy for "default", and
shmem_reconfigure() takes a NULL ctx->mpol to mean that no mpol option was
given. So a remount with mpol=default succeeds but keeps the old policy:
# mount -t tmpfs -o mpol=bind:1 none /mnt
# mount -o remount,mpol=default /mnt
# grep /mnt /proc/mounts
none /mnt tmpfs rw,relatime,mpol=bind:1 0 0
Record that an mpol option was parsed, and replace the policy whenever
one was.
Link: https://patch.msgid.link/20261127230015.30733-1-evanfengff@gmail.com
Fixes: 5f00110f7273 ("tmpfs: fix use-after-free of mempolicy object")
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Greg Thelen <gthelen@google.com>
mm/shmem.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/mm/shmem.c~tmpfs-reset-the-memory-policy-on-remount-with-mpol=default
+++ a/mm/shmem.c
@@ -134,6 +134,7 @@ struct shmem_options {
#define SHMEM_SEEN_HUGE 4
#define SHMEM_SEEN_INUMS 8
#define SHMEM_SEEN_QUOTA 16
+#define SHMEM_SEEN_MPOL 32
};
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -4905,6 +4906,7 @@ static int shmem_parse_one(struct fs_con
ctx->mpol = NULL;
if (mpol_parse_str(param->string, &ctx->mpol))
goto bad_value;
+ ctx->seen |= SHMEM_SEEN_MPOL;
break;
}
goto unsupported_parameter;
@@ -5117,7 +5119,7 @@ static int shmem_reconfigure(struct fs_c
/*
* Preserve previous mempolicy unless mpol remount option was specified.
*/
- if (ctx->mpol) {
+ if (ctx->seen & SHMEM_SEEN_MPOL) {
mpol = sbinfo->mpol;
sbinfo->mpol = ctx->mpol; /* transfers initial ref */
ctx->mpol = NULL;
_
Patches currently in -mm which might be from evanfengff@gmail.com are
mm-damon-core-fix-damos_walk-hang-with-zero-watermarks-interval.patch
mm-damon-core-do-not-overwrite-wmarksactivated-in-damos_commit.patch
tools-mm-page_owner_sort-fix-slab-allocator-labelling.patch
tmpfs-reset-the-memory-policy-on-remount-with-mpol=default.patch
^ permalink raw reply [flat|nested] 9+ messages in thread* [-] tmpfs-reset-the-memory-policy-on-remount-with-mpol=default.patch removed from -mm tree
2026-11-27 23:00 [PATCH] tmpfs: reset the memory policy on remount with mpol=default Yifan Feng
2026-11-28 0:10 ` Andrew Morton
2026-11-28 0:11 ` + tmpfs-reset-the-memory-policy-on-remount-with-mpol=default.patch added to mm-new branch Andrew Morton
@ 2026-11-29 21:25 ` Andrew Morton
2026-11-30 8:00 ` [PATCH] tmpfs: reset the memory policy on remount with mpol=default Baolin Wang
2026-11-30 12:21 ` David Hildenbrand
4 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-29 21:25 UTC (permalink / raw)
To: mm-commits, hughd, gthelen, david, baolin.wang, evanfengff, akpm
The quilt patch titled
Subject: tmpfs: reset the memory policy on remount with mpol=default
has been removed from the -mm tree. Its filename was
tmpfs-reset-the-memory-policy-on-remount-with-mpol=default.patch
This patch was dropped because David is taking it
------------------------------------------------------
From: Yifan Feng <evanfengff@gmail.com>
Subject: tmpfs: reset the memory policy on remount with mpol=default
Date: Fri, 27 Nov 2026 15:00:15 -0800
mpol_parse_str() returns a NULL policy for "default", and
shmem_reconfigure() takes a NULL ctx->mpol to mean that no mpol option was
given. So a remount with mpol=default succeeds but keeps the old policy:
# mount -t tmpfs -o mpol=bind:1 none /mnt
# mount -o remount,mpol=default /mnt
# grep /mnt /proc/mounts
none /mnt tmpfs rw,relatime,mpol=bind:1 0 0
Record that an mpol option was parsed, and replace the policy whenever
one was.
Link: https://patch.msgid.link/20261127230015.30733-1-evanfengff@gmail.com
Fixes: 5f00110f7273 ("tmpfs: fix use-after-free of mempolicy object")
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Greg Thelen <gthelen@google.com>
mm/shmem.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/mm/shmem.c~tmpfs-reset-the-memory-policy-on-remount-with-mpol=default
+++ a/mm/shmem.c
@@ -134,6 +134,7 @@ struct shmem_options {
#define SHMEM_SEEN_HUGE 4
#define SHMEM_SEEN_INUMS 8
#define SHMEM_SEEN_QUOTA 16
+#define SHMEM_SEEN_MPOL 32
};
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -4905,6 +4906,7 @@ static int shmem_parse_one(struct fs_con
ctx->mpol = NULL;
if (mpol_parse_str(param->string, &ctx->mpol))
goto bad_value;
+ ctx->seen |= SHMEM_SEEN_MPOL;
break;
}
goto unsupported_parameter;
@@ -5117,7 +5119,7 @@ static int shmem_reconfigure(struct fs_c
/*
* Preserve previous mempolicy unless mpol remount option was specified.
*/
- if (ctx->mpol) {
+ if (ctx->seen & SHMEM_SEEN_MPOL) {
mpol = sbinfo->mpol;
sbinfo->mpol = ctx->mpol; /* transfers initial ref */
ctx->mpol = NULL;
_
Patches currently in -mm which might be from evanfengff@gmail.com are
mm-damon-core-fix-damos_walk-hang-with-zero-watermarks-interval.patch
mm-damon-core-do-not-overwrite-wmarksactivated-in-damos_commit.patch
tools-mm-page_owner_sort-fix-slab-allocator-labelling.patch
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] tmpfs: reset the memory policy on remount with mpol=default
2026-11-27 23:00 [PATCH] tmpfs: reset the memory policy on remount with mpol=default Yifan Feng
` (2 preceding siblings ...)
2026-11-29 21:25 ` [-] tmpfs-reset-the-memory-policy-on-remount-with-mpol=default.patch removed from -mm tree Andrew Morton
@ 2026-11-30 8:00 ` Baolin Wang
2026-11-30 12:21 ` David Hildenbrand
4 siblings, 0 replies; 9+ messages in thread
From: Baolin Wang @ 2026-11-30 8:00 UTC (permalink / raw)
To: Yifan Feng, Hugh Dickins, David Hildenbrand, Andrew Morton
Cc: Greg Thelen, linux-mm, linux-kernel
On 11/28/26 7:00 AM, Yifan Feng wrote:
> mpol_parse_str() returns a NULL policy for "default", and
> shmem_reconfigure() takes a NULL ctx->mpol to mean that no mpol option
> was given. So a remount with mpol=default succeeds but keeps the old
> policy:
>
> # mount -t tmpfs -o mpol=bind:1 none /mnt
> # mount -o remount,mpol=default /mnt
> # grep /mnt /proc/mounts
> none /mnt tmpfs rw,relatime,mpol=bind:1 0 0
>
> Record that an mpol option was parsed, and replace the policy whenever
> one was.
>
> Fixes: 5f00110f7273 ("tmpfs: fix use-after-free of mempolicy object")
> Signed-off-by: Yifan Feng <evanfengff@gmail.com>
> ---
Good catch.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] tmpfs: reset the memory policy on remount with mpol=default
2026-11-27 23:00 [PATCH] tmpfs: reset the memory policy on remount with mpol=default Yifan Feng
` (3 preceding siblings ...)
2026-11-30 8:00 ` [PATCH] tmpfs: reset the memory policy on remount with mpol=default Baolin Wang
@ 2026-11-30 12:21 ` David Hildenbrand
4 siblings, 0 replies; 9+ messages in thread
From: David Hildenbrand @ 2026-11-30 12:21 UTC (permalink / raw)
To: Hugh Dickins, David Hildenbrand, Andrew Morton, Yifan Feng
Cc: Baolin Wang, Greg Thelen, linux-mm, linux-kernel
On Fri, 27 Nov 2026 15:00:15 -0800, Yifan Feng wrote:
> mpol_parse_str() returns a NULL policy for "default", and
> shmem_reconfigure() takes a NULL ctx->mpol to mean that no mpol option
> was given. So a remount with mpol=default succeeds but keeps the old
> policy:
>
> # mount -t tmpfs -o mpol=bind:1 none /mnt
> # mount -o remount,mpol=default /mnt
> # grep /mnt /proc/mounts
> none /mnt tmpfs rw,relatime,mpol=bind:1 0 0
>
> [...]
Applied, thanks!
tree: mm/core.git
branch: shmem-7.5.misc
Applied patches will appear soon in mm-next, followed by linux-next.
Please report any outstanding bugs that were missed during review, so we
can either drop the patch series or decide how to fix it up.
It is encouraged to provide Acked-bys, Reviewed-bys, and Tested-bys even
though the patches have already been applied. If possible, patch trailers
will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. Further, this is not a guarantee that the
patches will go upstream. If in doubt, please check the listed branch.
[1/1] tmpfs: reset the memory policy on remount with mpol=default
https://git.kernel.org/mm/core/c/cbd42552
--
Cheers,
David
^ permalink raw reply [flat|nested] 9+ messages in thread