* [PATCH] tmpfs: escape the space in the mpol mount option
@ 2026-11-28 23:37 Yifan Feng
2026-11-29 2:13 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Yifan Feng @ 2026-11-28 23:37 UTC (permalink / raw)
To: Hugh Dickins, David Hildenbrand, Andrew Morton
Cc: Baolin Wang, Gregory Price, linux-mm, linux-kernel, Yifan Feng
The policy names "weighted interleave" and "prefer (many)" contain a
space, and shmem_show_mpol() prints the name as it is. Readers of
/proc/mounts take the space as the end of the options field, so
mount(8) reads back mpol=prefer and an unrelated remount replaces the
policy:
# mount -t tmpfs -o 'mpol=prefer (many):0-1' none /mnt
# mount -o remount,size=128M /mnt
# grep /mnt /proc/mounts
none /mnt tmpfs rw,relatime,size=131072k,inode64,mpol=local 0 0
With "weighted interleave" the same remount fails with EINVAL.
Escape the value like the other fields of the line, so that the space
is printed as \040.
Fixes: b27abaccf8e8 ("mm/mempolicy: add MPOL_PREFERRED_MANY for multiple preferred nodes")
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
---
Tested in a 2-node NUMA QEMU guest with util-linux 2.33.1: findmnt and getmntent() show the whole policy, both remounts keep it, and the options read from /proc/mounts mount again to an identical line.
Found and written with the help of an AI coding assistant.
mm/shmem.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index a5713109c843..75f0223084a7 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2045,7 +2045,8 @@ static void shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
mpol_to_str(buffer, sizeof(buffer), mpol);
- seq_printf(seq, ",mpol=%s", buffer);
+ seq_puts(seq, ",mpol=");
+ seq_escape(seq, buffer, " \t\n\\");
}
static struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo)
base-commit: 822ba3a89c7896b26e4beb70e2ebffb881924dfe
--
2.39.3 (Apple Git-146)
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] tmpfs: escape the space in the mpol mount option
2026-11-28 23:37 [PATCH] tmpfs: escape the space in the mpol mount option Yifan Feng
@ 2026-11-29 2:13 ` Andrew Morton
2026-11-30 2:09 ` Yifan Feng
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2026-11-29 2:13 UTC (permalink / raw)
To: Yifan Feng
Cc: Hugh Dickins, David Hildenbrand, Baolin Wang, Gregory Price,
linux-mm, linux-kernel
On Sat, 28 Nov 2026 15:37:47 -0800 Yifan Feng <evanfengff@gmail.com> wrote:
> The policy names "weighted interleave" and "prefer (many)" contain a
> space, and shmem_show_mpol() prints the name as it is. Readers of
> /proc/mounts take the space as the end of the options field, so
> mount(8) reads back mpol=prefer and an unrelated remount replaces the
> policy:
A little more info please.
> # mount -t tmpfs -o 'mpol=prefer (many):0-1' none /mnt
what's in /proc mounts at this point?
> # mount -o remount,size=128M /mnt
> # grep /mnt /proc/mounts
> none /mnt tmpfs rw,relatime,size=131072k,inode64,mpol=local 0 0
>
> With "weighted interleave" the same remount fails with EINVAL.
>
> Escape the value like the other fields of the line, so that the space
> is printed as \040.
and what does /proc/mounts look like after making this change?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tmpfs: escape the space in the mpol mount option
2026-11-29 2:13 ` Andrew Morton
@ 2026-11-30 2:09 ` Yifan Feng
2026-11-30 2:12 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Yifan Feng @ 2026-11-30 2:09 UTC (permalink / raw)
To: Andrew Morton
Cc: Hugh Dickins, David Hildenbrand, Baolin Wang, Gregory Price,
linux-mm, linux-kernel
On Sat, 28 Nov 2026 18:13:19 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:
> > # mount -t tmpfs -o 'mpol=prefer (many):0-1' none /mnt
>
> what's in /proc mounts at this point?
none /mnt tmpfs rw,relatime,inode64,mpol=prefer (many):0-1 0 0
That is seven fields where six are expected. findmnt and getmntent()
stop at the space, so the options they return end in "mpol=prefer".
> and what does /proc/mounts look like after making this change?
After the mount:
none /mnt tmpfs rw,relatime,inode64,mpol=prefer\040(many):0-1 0 0
After the remount with size=128M:
none /mnt tmpfs rw,relatime,size=131072k,inode64,mpol=prefer\040(many):0-1 0 0
findmnt and getmntent() decode the \040, and the options they return
end in "mpol=prefer (many):0-1".
I can send a v2 with these lines in the changelog if you prefer.
Thanks,
Yifan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tmpfs: escape the space in the mpol mount option
2026-11-30 2:09 ` Yifan Feng
@ 2026-11-30 2:12 ` Andrew Morton
2026-11-30 11:13 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2026-11-30 2:12 UTC (permalink / raw)
To: Yifan Feng
Cc: Hugh Dickins, David Hildenbrand, Baolin Wang, Gregory Price,
linux-mm, linux-kernel
On Sun, 29 Nov 2026 18:09:05 -0800 Yifan Feng <evanfengff@gmail.com> wrote:
> On Sat, 28 Nov 2026 18:13:19 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:
>
> > > # mount -t tmpfs -o 'mpol=prefer (many):0-1' none /mnt
> >
> > what's in /proc mounts at this point?
>
> none /mnt tmpfs rw,relatime,inode64,mpol=prefer (many):0-1 0 0
>
> That is seven fields where six are expected. findmnt and getmntent()
> stop at the space, so the options they return end in "mpol=prefer".
>
> > and what does /proc/mounts look like after making this change?
>
> After the mount:
>
> none /mnt tmpfs rw,relatime,inode64,mpol=prefer\040(many):0-1 0 0
>
> After the remount with size=128M:
>
> none /mnt tmpfs rw,relatime,size=131072k,inode64,mpol=prefer\040(many):0-1 0 0
>
> findmnt and getmntent() decode the \040, and the options they return
> end in "mpol=prefer (many):0-1".
Great, thanks.
> I can send a v2 with these lines in the changelog if you prefer.
If you could please. I expect David will be processing this patch.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tmpfs: escape the space in the mpol mount option
2026-11-30 2:12 ` Andrew Morton
@ 2026-11-30 11:13 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand (Arm) @ 2026-11-30 11:13 UTC (permalink / raw)
To: Andrew Morton, Yifan Feng
Cc: Hugh Dickins, Baolin Wang, Gregory Price, linux-mm, linux-kernel
On 11/30/26 03:12, Andrew Morton wrote:
> On Sun, 29 Nov 2026 18:09:05 -0800 Yifan Feng <evanfengff@gmail.com> wrote:
>
>> On Sat, 28 Nov 2026 18:13:19 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:
>>
>>>
>>> what's in /proc mounts at this point?
>>
>> none /mnt tmpfs rw,relatime,inode64,mpol=prefer (many):0-1 0 0
>>
>> That is seven fields where six are expected. findmnt and getmntent()
>> stop at the space, so the options they return end in "mpol=prefer".
>>
>>> and what does /proc/mounts look like after making this change?
>>
>> After the mount:
>>
>> none /mnt tmpfs rw,relatime,inode64,mpol=prefer\040(many):0-1 0 0
>>
>> After the remount with size=128M:
>>
>> none /mnt tmpfs rw,relatime,size=131072k,inode64,mpol=prefer\040(many):0-1 0 0
>>
>> findmnt and getmntent() decode the \040, and the options they return
>> end in "mpol=prefer (many):0-1".
>
> Great, thanks.
>
>> I can send a v2 with these lines in the changelog if you prefer.
>
> If you could please. I expect David will be processing this patch.
Yes please.
--
Cheers,
David
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-30 11:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28 23:37 [PATCH] tmpfs: escape the space in the mpol mount option Yifan Feng
2026-11-29 2:13 ` Andrew Morton
2026-11-30 2:09 ` Yifan Feng
2026-11-30 2:12 ` Andrew Morton
2026-11-30 11:13 ` David Hildenbrand (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®