[PATCH v3 0/3] revamp fs/filesystems.c

Mateusz Guzik posted 3 patches 1 month, 3 weeks ago
There is a newer version of this series
fs/filesystems.c        | 332 +++++++++++++++++++++++++++-------------
fs/ocfs2/super.c        |   1 -
fs/proc/generic.c       |  12 ++
fs/proc/internal.h      |   3 +
include/linux/fs.h      |   2 +-
include/linux/proc_fs.h |  10 ++
6 files changed, 252 insertions(+), 108 deletions(-)
[PATCH v3 0/3] revamp fs/filesystems.c
Posted by Mateusz Guzik 1 month, 3 weeks ago
The file is a mess with a hand-rolled linked list in a desperate need of
a clean up.

The code to emit /proc/filesystems is used frequently because libselinux
reads the file, which in turn is linked into numerous frequently used
programs (even ones you would not suspect, like sed!). In order to
combat that pre-gen the string instead of pointer-chasing and printfing
one by-one.

open+read+close cycle single-threaded (ops/s):
before: 442732
after:  1063462 (+140%)

Additionally scalability is also improved thanks to bypassing ref
maintenance on open/close.

open+read+close cycle with 20 processes (ops/s):
before: 606177
after:	3300576 (+444%)

The main bottleneck afterwards is the spurious lockref trip on open.

Alexey Dobriyan (1):
  proc: allow to mark /proc files permanent outside of fs/proc/

Christian Brauner (1):
  fs: RCU-ify filesystems list

Mateusz Guzik (1):
  fs: cache the string generated by reading /proc/filesystems

 fs/filesystems.c        | 332 +++++++++++++++++++++++++++-------------
 fs/ocfs2/super.c        |   1 -
 fs/proc/generic.c       |  12 ++
 fs/proc/internal.h      |   3 +
 include/linux/fs.h      |   2 +-
 include/linux/proc_fs.h |  10 ++
 6 files changed, 252 insertions(+), 108 deletions(-)

-- 
2.48.1
Re: [PATCH v3 0/3] revamp fs/filesystems.c
Posted by Christian Brauner 1 month, 3 weeks ago
On Sun, 26 Apr 2026 00:08:41 +0200, Mateusz Guzik wrote:
> The file is a mess with a hand-rolled linked list in a desperate need of
> a clean up.
> 
> The code to emit /proc/filesystems is used frequently because libselinux
> reads the file, which in turn is linked into numerous frequently used
> programs (even ones you would not suspect, like sed!). In order to
> combat that pre-gen the string instead of pointer-chasing and printfing
> one by-one.
> 
> [...]

Applied to the vfs-7.2.procfs branch of the vfs/vfs.git tree.
Patches in the vfs-7.2.procfs branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now 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. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: master

[1/3] proc: allow to mark /proc files permanent outside of fs/proc/
      https://git.kernel.org/vfs/vfs/c/b26811a2ab58
[2/3] fs: RCU-ify filesystems list
      https://git.kernel.org/vfs/vfs/c/1fe9dc896f66
[3/3] fs: cache the string generated by reading /proc/filesystems
      https://git.kernel.org/vfs/vfs/c/3bd2c4fa951a
Why does GNU sed abuse /proc/filesystems? Re: [PATCH v3 0/3] revamp fs/filesystems.c
Posted by Cedric Blancher 1 month, 3 weeks ago
On Sun, 26 Apr 2026 at 00:09, Mateusz Guzik <mjguzik@gmail.com> wrote:
>
> The file is a mess with a hand-rolled linked list in a desperate need of
> a clean up.
>
> The code to emit /proc/filesystems is used frequently because libselinux
> reads the file, which in turn is linked into numerous frequently used
> programs (even ones you would not suspect, like sed!). In order to
> combat that pre-gen the string instead of pointer-chasing and printfing
> one by-one.

Why is GNU sed touching /proc/filesystems in the first place? This is
not really a stable API, and would actually be a thing which should
NOT be touched by a "simple" userland tool.

<rant>maybe rename /proc/filesystems to
/proc/filesystems_only_for_admin_purposes</rant>, or stick an ACL on
it to prevent abuse?

Ced
-- 
Cedric Blancher <cedric.blancher@gmail.com>
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur
Re: Why does GNU sed abuse /proc/filesystems? Re: [PATCH v3 0/3] revamp fs/filesystems.c
Posted by Mateusz Guzik 1 month, 3 weeks ago
On Tue, Apr 28, 2026 at 08:36:00AM +0200, Cedric Blancher wrote:
> On Sun, 26 Apr 2026 at 00:09, Mateusz Guzik <mjguzik@gmail.com> wrote:
> >
> > The file is a mess with a hand-rolled linked list in a desperate need of
> > a clean up.
> >
> > The code to emit /proc/filesystems is used frequently because libselinux
> > reads the file, which in turn is linked into numerous frequently used
> > programs (even ones you would not suspect, like sed!). In order to
> > combat that pre-gen the string instead of pointer-chasing and printfing
> > one by-one.
> 
> Why is GNU sed touching /proc/filesystems in the first place? This is
> not really a stable API, and would actually be a thing which should
> NOT be touched by a "simple" userland tool.
> 
> <rant>maybe rename /proc/filesystems to
> /proc/filesystems_only_for_admin_purposes</rant>, or stick an ACL on
> it to prevent abuse?
> 

It has support for file creation with the -i switch. For that reason it
links with libselinux which does the dirty on binary startup.