mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] speed up /proc/filesystems
@ 2025-03-29 19:28 Mateusz Guzik
  2025-03-29 19:28 ` [PATCH 1/2] proc: add a helper for marking files as permanent by external consumers Mateusz Guzik
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Mateusz Guzik @ 2025-03-29 19:28 UTC (permalink / raw)
  To: brauner; +Cc: viro, jack, linux-kernel, linux-fsdevel, Mateusz Guzik

I accidentally found out it is used a lot *and* is incredibly slow.

Part of it is procfs protecting the file from going away on each op,
other part is content generatin being dog slow.

Turns out procfs did not provide an interface to mark files as
permanent. I added easiest hack I could think of to remedy the problem,
I am not going to argue how to do it.

Mateusz Guzik (2):
  proc: add a helper for marking files as permanent by external
    consumers
  fs: cache the string generated by reading /proc/filesystems

 fs/filesystems.c        | 148 +++++++++++++++++++++++++++++++++++++---
 fs/proc/generic.c       |   6 ++
 include/linux/proc_fs.h |   1 +
 3 files changed, 147 insertions(+), 8 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] proc: add a helper for marking files as permanent by external consumers
@ 2025-04-01 11:14 Alexey Dobriyan
  2025-04-01 12:17 ` Mateusz Guzik
  0 siblings, 1 reply; 14+ messages in thread
From: Alexey Dobriyan @ 2025-04-01 11:14 UTC (permalink / raw)
  To: Mateusz Guzik
  Cc: Christian Brauner, Al Viro, Jan Kara, Linux Kernel, linux-fsdevel

> +void proc_make_permanent(struct proc_dir_entry *de)
> +{
> + pde_make_permanent(de);
> +}
> +EXPORT_SYMBOL(proc_make_permanent);

no, no, no, no

this is wrong!

marking should be done in the context of a module!

the reason it is not exported is because the aren't safeguards against
module misuse

the flag is supposed to be used in case where
a) PDE itself is never removed and,
b) all the code supporting is never removed,
so that locking can be skipped

this it fine to mark /proc/filesystems because kernel controls it

this is fine to mark /proc/aaa if all module does is to write some
info to it and deletes it during rmmod

but it is not fine to mark /proc/aaa/bbb if "bbb" is created/deleted
while module is running,
locking _must_ be done in this case

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] proc: add a helper for marking files as permanent by external consumers
@ 2025-04-01 11:18 Alexey Dobriyan
  0 siblings, 0 replies; 14+ messages in thread
From: Alexey Dobriyan @ 2025-04-01 11:18 UTC (permalink / raw)
  To: Mateusz Guzik
  Cc: Christian Brauner, Al Viro, Jan Kara, Linux Kernel, linux-fsdevel

>  static int __init proc_filesystems_init(void)
>  {
> - proc_create_single("filesystems", 0, NULL, filesystems_proc_show);
> + struct proc_dir_entry *pde;
> +
> + pde = proc_create_single("filesystems", 0, NULL, filesystems_proc_show);
> + proc_make_permanent(pde);

The only function which should be used is pde_make_permanent()
so that the flag is silently turned off when the code is modular.

Code is fine as-is in this very case but when people start copying it
to real modules
they will start mark PDEs as permanent when it is not true!

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-04-05  5:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-29 19:28 [PATCH 0/2] speed up /proc/filesystems Mateusz Guzik
2025-03-29 19:28 ` [PATCH 1/2] proc: add a helper for marking files as permanent by external consumers Mateusz Guzik
2025-03-29 19:28 ` [PATCH 2/2] fs: cache the string generated by reading /proc/filesystems Mateusz Guzik
2025-03-29 20:53   ` Andreas Schwab
2025-04-04  8:41     ` Christoph Hellwig
2025-04-05  4:55       ` Mateusz Guzik
2025-04-05  5:26         ` Mateusz Guzik
2025-04-01 10:30   ` Christian Brauner
2025-04-01 12:12     ` Mateusz Guzik
2025-04-01 10:34 ` [PATCH 0/2] speed up /proc/filesystems Christian Brauner
2025-04-01 11:14 [PATCH 1/2] proc: add a helper for marking files as permanent by external consumers Alexey Dobriyan
2025-04-01 12:17 ` Mateusz Guzik
2025-04-01 12:21   ` Mateusz Guzik
2025-04-01 11:18 Alexey Dobriyan

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®