From: Andrew Morton <akpm@linux-foundation.org>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2] proc: faster open/read/close with "permanent" files
Date: Wed, 19 Feb 2020 13:06:00 -0800 [thread overview]
Message-ID: <20200219130600.3cb5cd65fbd696fe43fb7adc@linux-foundation.org> (raw)
In-Reply-To: <20200219191127.GA15115@avx2>
On Wed, 19 Feb 2020 22:11:27 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:
> Now that "struct proc_ops" exist we can start putting there stuff which
> could not fly with VFS "struct file_operations"...
>
> Most of fs/proc/inode.c file is dedicated to make open/read/.../close reliable
> in the event of disappearing /proc entries which usually happens if module is
> getting removed. Files like /proc/cpuinfo which never disappear simply do not
> need such protection.
>
> Save 2 atomic ops, 1 allocation, 1 free per open/read/close sequence for such
> "permanent" files.
>
> Enable "permanent" flag for
>
> /proc/cpuinfo
> /proc/kmsg
> /proc/modules
> /proc/slabinfo
> /proc/stat
> /proc/sysvipc/*
> /proc/swaps
>
> More will come once I figure out foolproof way to prevent out module
> authors from marking their stuff "permanent" for performance reasons
> when it is not.
>
> This should help with scalability: benchmark is "read /proc/cpuinfo R times
> by N threads scattered over the system".
>
> N R t, s (before) t, s (after)
> -----------------------------------------------------
> 64 4096 1.582458 1.530502 -3.2%
> 256 4096 6.371926 6.125168 -3.9%
> 1024 4096 25.64888 24.47528 -4.6%
I guess that's significant.
> --- a/fs/proc/internal.h
> +++ b/fs/proc/internal.h
> @@ -61,6 +61,7 @@ struct proc_dir_entry {
> struct rb_node subdir_node;
> char *name;
> umode_t mode;
> + u8 flags;
Add a comment describing what this is?
> u8 namelen;
> char inline_name[];
> } __randomize_layout;
>
> ...
>
> --- a/include/linux/proc_fs.h
> +++ b/include/linux/proc_fs.h
> @@ -5,6 +5,7 @@
> #ifndef _LINUX_PROC_FS_H
> #define _LINUX_PROC_FS_H
>
> +#include <linux/compiler.h>
> #include <linux/types.h>
> #include <linux/fs.h>
>
> @@ -12,7 +13,21 @@ struct proc_dir_entry;
> struct seq_file;
> struct seq_operations;
>
> +enum {
> + /*
> + * All /proc entries using this ->proc_ops instance are never removed.
> + *
> + * If in doubt, ignore this flag.
> + */
> +#ifdef MODULE
> + PROC_ENTRY_PERMANENT = 0U,
> +#else
> + PROC_ENTRY_PERMANENT = 1U << 0,
> +#endif
> +};
That feels quite hacky. Is it really needed? Any module which uses
this is simply buggy?
Can we just leave this undefined if MODULE and break the build?
> struct proc_ops {
> + unsigned int proc_flags;
> int (*proc_open)(struct inode *, struct file *);
> ssize_t (*proc_read)(struct file *, char __user *, size_t, loff_t *);
> ssize_t (*proc_write)(struct file *, const char __user *, size_t, loff_t *);
> @@ -25,7 +40,7 @@ struct proc_ops {
> #endif
> int (*proc_mmap)(struct file *, struct vm_area_struct *);
> unsigned long (*proc_get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
> -};
> +} __randomize_layout;
Unchangelogged, unrelated?
> #ifdef CONFIG_PROC_FS
>
next prev parent reply other threads:[~2020-02-19 21:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-19 19:11 [PATCH v2] proc: faster open/read/close with "permanent" files Alexey Dobriyan
2020-02-19 21:06 ` Andrew Morton [this message]
2020-02-20 7:13 ` Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200219130600.3cb5cd65fbd696fe43fb7adc@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=adobriyan@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).