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

Mateusz Guzik posted 3 patches 1 week, 2 days ago
fs/filesystems.c        | 330 +++++++++++++++++++++++++++-------------
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, 250 insertions(+), 108 deletions(-)
[PATCH v4 0/3] revamp fs/filesystems.c
Posted by Mateusz Guzik 1 week, 2 days 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.

v4:
- add missing unlocks in some corner cases
- whitespace touch ups
- s/smp_store_release/rcu_assign_pointer/ [nop, the macro expands to the same thing]
- mark file_systems_string as __read_mostly

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        | 330 +++++++++++++++++++++++++++-------------
 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, 250 insertions(+), 108 deletions(-)

-- 
2.48.1
Re: [PATCH v4 0/3] revamp fs/filesystems.c
Posted by Christian Brauner 5 days, 20 hours ago
On Fri, May 29, 2026 at 07:18:37PM +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.
> 
> 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.

There's a bunch of work in vfs-7.2.procfs on top of what's currently in
there. So please any changes should be a diff on there otherwise we have
to rebase that whole branch when it's already -rc6.