Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.kernel > #84174 > unrolled thread

Bug#1083159: mount: tmpfs size for /tmp is randomly ignored

Started byVincent Lefevre <vincent@vinc17.net>
First post2024-10-03 15:40 +0200
Last post2025-05-06 13:00 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.debian.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Bug#1083159: mount: tmpfs size for /tmp is randomly ignored Vincent Lefevre <vincent@vinc17.net> - 2024-10-03 15:40 +0200
    Processed: Re: Bug#1083159: mount: tmpfs size for /tmp is  randomly ignored "Debian Bug Tracking System" <owner@bugs.debian.org> - 2024-10-03 15:40 +0200
    Bug#1083159: mount: tmpfs size for /tmp is randomly ignored Salvatore Bonaccorso <carnil@debian.org> - 2025-02-21 20:40 +0100
      Bug#1083159: mount: tmpfs size for /tmp is randomly ignored Vincent Lefevre <vincent@vinc17.net> - 2025-05-06 12:20 +0200
        Bug#1083159: mount: tmpfs size for /tmp is randomly ignored Vincent Lefevre <vincent@vinc17.net> - 2025-05-06 13:00 +0200

#84174 — Bug#1083159: mount: tmpfs size for /tmp is randomly ignored

FromVincent Lefevre <vincent@vinc17.net>
Date2024-10-03 15:40 +0200
SubjectBug#1083159: mount: tmpfs size for /tmp is randomly ignored
Message-ID<JtudH-gEYU-1@gated-at.bofh.it>
Control: reassign -1 src:linux
Control: found -1 6.10.12-1
Control: severity -1 minor
Control: notforwarded -1
Control: retitle -1 linux: for tmpfs, /proc/mounts and /proc/self/mountinfo do not always show the size when corresponding to the default, at least on /tmp

Summary: On my Debian/unstable machines, a tmpfs file system is
mounted on /tmp with the default size=50% option; this is the
current default in Debian. In this case, /proc/mounts and the
"mount" command (based on /proc/self/mountinfo) do not always
show the resulting size (as a number of KB) for /tmp; this is
random and can change only after a reboot.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

[toc] | [next] | [standalone]


#84175 — Processed: Re: Bug#1083159: mount: tmpfs size for /tmp is randomly ignored

From"Debian Bug Tracking System" <owner@bugs.debian.org>
Date2024-10-03 15:40 +0200
SubjectProcessed: Re: Bug#1083159: mount: tmpfs size for /tmp is randomly ignored
Message-ID<JtudH-gEYU-13@gated-at.bofh.it>
In reply to#84174
Processing control commands:

> reassign -1 src:linux
Bug #1083159 [systemd] mount: tmpfs size for /tmp is randomly ignored
Bug reassigned from package 'systemd' to 'src:linux'.
No longer marked as found in versions systemd/256.6-1.
Ignoring request to alter fixed versions of bug #1083159 to the same values previously set
> found -1 6.10.12-1
Bug #1083159 [src:linux] mount: tmpfs size for /tmp is randomly ignored
Marked as found in versions linux/6.10.12-1.
> severity -1 minor
Bug #1083159 [src:linux] mount: tmpfs size for /tmp is randomly ignored
Severity set to 'minor' from 'normal'
> notforwarded -1
Bug #1083159 [src:linux] mount: tmpfs size for /tmp is randomly ignored
Unset Bug forwarded-to-address
> retitle -1 linux: for tmpfs, /proc/mounts and /proc/self/mountinfo do not always show the size when corresponding to the default, at least on /tmp
Bug #1083159 [src:linux] mount: tmpfs size for /tmp is randomly ignored
Changed Bug title to 'linux: for tmpfs, /proc/mounts and /proc/self/mountinfo do not always show the size when corresponding to the default, at least on /tmp' from 'mount: tmpfs size for /tmp is randomly ignored'.

-- 
1083159: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1083159
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems

[toc] | [prev] | [next] | [standalone]


#86033

FromSalvatore Bonaccorso <carnil@debian.org>
Date2025-02-21 20:40 +0100
Message-ID<KiH2p-XUf-1@gated-at.bofh.it>
In reply to#84174
Hi Vincent,

On Thu, Oct 03, 2024 at 03:29:47PM +0200, Vincent Lefevre wrote:
> Control: reassign -1 src:linux
> Control: found -1 6.10.12-1
> Control: severity -1 minor
> Control: notforwarded -1
> Control: retitle -1 linux: for tmpfs, /proc/mounts and /proc/self/mountinfo do not always show the size when corresponding to the default, at least on /tmp
> 
> Summary: On my Debian/unstable machines, a tmpfs file system is
> mounted on /tmp with the default size=50% option; this is the
> current default in Debian. In this case, /proc/mounts and the
> "mount" command (based on /proc/self/mountinfo) do not always
> show the resulting size (as a number of KB) for /tmp; this is
> random and can change only after a reboot.

I stumpled over this bug while reviewing open bugs, and my take is
that this is actually not a bug. *But* I hope one of my more
experienced colegues in the team might review this claim.

Let's start from:

https://www.kernel.org/doc/html/latest/filesystems/vfs.html#mount-options

The important bits are:

Showing options
---------------

If a filesystem accepts mount options, it must define show_options() to
show all the currently active options.  The rules are:

  - options MUST be shown which are not default or their values differ
    from the default

  - options MAY be shown which are enabled by default or have their
    default value

tmpfs is defined in "mm/shmem.c and we have (current mainline):

5263 #ifdef CONFIG_TMPFS
5264         .statfs         = shmem_statfs,
5265         .show_options   = shmem_show_options,
5266 #endif

shmem_show_options() handles showming mount options for tmpfs:

4878 static int shmem_show_options(struct seq_file *seq, struct dentry *root)
4879 {
4880         struct shmem_sb_info *sbinfo = SHMEM_SB(root->d_sb);
4881         struct mempolicy *mpol;
4882
4883         if (sbinfo->max_blocks != shmem_default_max_blocks())
4884                 seq_printf(seq, ",size=%luk", K(sbinfo->max_blocks));
[...]

So size is only showed if sbinfo->max_blocks != shmem_default_max_blocks().

Let's look at shmem_default_max_blocks():

 147 #ifdef CONFIG_TMPFS
 148 static unsigned long shmem_default_max_blocks(void)
 149 {
 150         return totalram_pages() / 2;
 151 }

So this is 50% of ram as *default* which matches tmpfs(5):

   Mount options
       The tmpfs filesystem supports the following mount options:

       size=bytes
              Specify  an  upper  limit  on the size of the filesystem.
              The size is given in bytes,  and  rounded  up  to  entire
              pages.  The limit is removed if the size is 0.

              The size may have a k, m, or g suffix for Ki, Mi, Gi (bi‐
              nary  kilo  (kibi),  binary  mega (mebi), and binary giga
              (gibi)).

              The size may also have a % suffix to limit this  instance
              to a percentage of physical RAM.

              The  default,  when  neither size nor nr_blocks is speci‐
              fied, is size=50%.

So my undestanding would be that the code here is coherent with the
specification that if size corresponds to the default value, the code
may, but does not must show it.

Does this make sense?

Regards,
Salvatore

[toc] | [prev] | [next] | [standalone]


#87394

FromVincent Lefevre <vincent@vinc17.net>
Date2025-05-06 12:20 +0200
Message-ID<KJnz3-17tW-3@gated-at.bofh.it>
In reply to#86033
Sorry, I forgot to reply...

On 2025-02-21 20:33:21 +0100, Salvatore Bonaccorso wrote:
> Let's start from:
> 
> https://www.kernel.org/doc/html/latest/filesystems/vfs.html#mount-options
> 
> The important bits are:
> 
> Showing options
> ---------------
> 
> If a filesystem accepts mount options, it must define show_options() to
> show all the currently active options.  The rules are:
> 
>   - options MUST be shown which are not default or their values differ
>     from the default
> 
>   - options MAY be shown which are enabled by default or have their
>     default value

But, IMHO, a fixed choice should be made. This should not be random.
Otherwise, this is confusing, and can break scripts that detect
changes in the configuration.

Now, with your analysis of the code...

> tmpfs is defined in "mm/shmem.c and we have (current mainline):
> 
> 5263 #ifdef CONFIG_TMPFS
> 5264         .statfs         = shmem_statfs,
> 5265         .show_options   = shmem_show_options,
> 5266 #endif
> 
> shmem_show_options() handles showming mount options for tmpfs:
> 
> 4878 static int shmem_show_options(struct seq_file *seq, struct dentry *root)
> 4879 {
> 4880         struct shmem_sb_info *sbinfo = SHMEM_SB(root->d_sb);
> 4881         struct mempolicy *mpol;
> 4882
> 4883         if (sbinfo->max_blocks != shmem_default_max_blocks())
> 4884                 seq_printf(seq, ",size=%luk", K(sbinfo->max_blocks));
> [...]
> 
> So size is only showed if sbinfo->max_blocks != shmem_default_max_blocks().
> 
> Let's look at shmem_default_max_blocks():
> 
>  147 #ifdef CONFIG_TMPFS
>  148 static unsigned long shmem_default_max_blocks(void)
>  149 {
>  150         return totalram_pages() / 2;
>  151 }
> 
> So this is 50% of ram as *default* which matches tmpfs(5):
> 
>    Mount options
>        The tmpfs filesystem supports the following mount options:
> 
>        size=bytes
>               Specify  an  upper  limit  on the size of the filesystem.
>               The size is given in bytes,  and  rounded  up  to  entire
>               pages.  The limit is removed if the size is 0.
> 
>               The size may have a k, m, or g suffix for Ki, Mi, Gi (bi‐
>               nary  kilo  (kibi),  binary  mega (mebi), and binary giga
>               (gibi)).
> 
>               The size may also have a % suffix to limit this  instance
>               to a percentage of physical RAM.
> 
>               The  default,  when  neither size nor nr_blocks is speci‐
>               fied, is size=50%.
> 
> So my undestanding would be that the code here is coherent with the
> specification that if size corresponds to the default value, the code
> may, but does not must show it.
> 
> Does this make sense?

According to the above code, the size is never shown for the default
as the condition sbinfo->max_blocks != shmem_default_max_blocks() is
false. But this is not what I observe: the size is shown randomly
(more precisely, whether the size is shown is chosen at boot time),
though it is always the default here.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)

[toc] | [prev] | [next] | [standalone]


#87395

FromVincent Lefevre <vincent@vinc17.net>
Date2025-05-06 13:00 +0200
Message-ID<KJobL-17H1-1@gated-at.bofh.it>
In reply to#87394
On 2025-05-06 12:13:24 +0200, Vincent Lefevre wrote:
> On 2025-02-21 20:33:21 +0100, Salvatore Bonaccorso wrote:
[...]
> > So size is only showed if sbinfo->max_blocks != shmem_default_max_blocks().
> > 
> > Let's look at shmem_default_max_blocks():
> > 
> >  147 #ifdef CONFIG_TMPFS
> >  148 static unsigned long shmem_default_max_blocks(void)
> >  149 {
> >  150         return totalram_pages() / 2;
> >  151 }
[...]

The bug may be the use of totalram_pages(), while the documentation
says:

> >        size=bytes
[...]
> >               The size may also have a % suffix to limit this  instance
> >               to a percentage of physical RAM.
                                     ^^^^^^^^^^^^

According to https://stackoverflow.com/a/60882958/3782797 (and
the answer given b MistralAI) it is get_num_physpages() that
gives the whole physical memory.

I suspect that totalram_pages() is not constant over the time,
so using it is buggy as there is no way for the user to know
what size is actually used for the 50% default.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.kernel


csiph-web