OSDN Git Service

proc: mark more files as permanent
authorAlexey Dobriyan <adobriyan@gmail.com>
Tue, 20 Sep 2022 17:35:23 +0000 (20:35 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 3 Oct 2022 21:21:45 +0000 (14:21 -0700)
Mark
/proc/devices
/proc/kpagecount
/proc/kpageflags
/proc/kpagecgroup
/proc/loadavg
/proc/meminfo
/proc/softirqs
/proc/uptime
/proc/version

as permanent /proc entries, saving alloc/free and some list/spinlock ops
per use.

These files are never removed by the kernel so it is OK to mark them.

Link: https://lkml.kernel.org/r/Yyn527DzDMa+r0Yj@localhost.localdomain
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/proc/devices.c
fs/proc/internal.h
fs/proc/loadavg.c
fs/proc/meminfo.c
fs/proc/page.c
fs/proc/softirqs.c
fs/proc/uptime.c
fs/proc/version.c

index 837971e..fe7bfcb 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/blkdev.h>
+#include "internal.h"
 
 static int devinfo_show(struct seq_file *f, void *v)
 {
@@ -54,7 +55,10 @@ static const struct seq_operations devinfo_ops = {
 
 static int __init proc_devices_init(void)
 {
-       proc_create_seq("devices", 0, NULL, &devinfo_ops);
+       struct proc_dir_entry *pde;
+
+       pde = proc_create_seq("devices", 0, NULL, &devinfo_ops);
+       pde_make_permanent(pde);
        return 0;
 }
 fs_initcall(proc_devices_init);
index 06a80f7..af27718 100644 (file)
@@ -79,6 +79,11 @@ static inline bool pde_is_permanent(const struct proc_dir_entry *pde)
        return pde->flags & PROC_ENTRY_PERMANENT;
 }
 
+static inline void pde_make_permanent(struct proc_dir_entry *pde)
+{
+       pde->flags |= PROC_ENTRY_PERMANENT;
+}
+
 extern struct kmem_cache *proc_dir_entry_cache;
 void pde_free(struct proc_dir_entry *pde);
 
index f32878d..817981e 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/seq_file.h>
 #include <linux/seqlock.h>
 #include <linux/time.h>
+#include "internal.h"
 
 static int loadavg_proc_show(struct seq_file *m, void *v)
 {
@@ -27,7 +28,10 @@ static int loadavg_proc_show(struct seq_file *m, void *v)
 
 static int __init proc_loadavg_init(void)
 {
-       proc_create_single("loadavg", 0, NULL, loadavg_proc_show);
+       struct proc_dir_entry *pde;
+
+       pde = proc_create_single("loadavg", 0, NULL, loadavg_proc_show);
+       pde_make_permanent(pde);
        return 0;
 }
 fs_initcall(proc_loadavg_init);
index 6e89f0e..70e5294 100644 (file)
@@ -162,7 +162,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
 
 static int __init proc_meminfo_init(void)
 {
-       proc_create_single("meminfo", 0, NULL, meminfo_proc_show);
+       struct proc_dir_entry *pde;
+
+       pde = proc_create_single("meminfo", 0, NULL, meminfo_proc_show);
+       pde_make_permanent(pde);
        return 0;
 }
 fs_initcall(proc_meminfo_init);
index a2873a6..f2273b1 100644 (file)
@@ -91,6 +91,7 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf,
 }
 
 static const struct proc_ops kpagecount_proc_ops = {
+       .proc_flags     = PROC_ENTRY_PERMANENT,
        .proc_lseek     = mem_lseek,
        .proc_read      = kpagecount_read,
 };
@@ -268,6 +269,7 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf,
 }
 
 static const struct proc_ops kpageflags_proc_ops = {
+       .proc_flags     = PROC_ENTRY_PERMANENT,
        .proc_lseek     = mem_lseek,
        .proc_read      = kpageflags_read,
 };
@@ -322,6 +324,7 @@ static ssize_t kpagecgroup_read(struct file *file, char __user *buf,
 }
 
 static const struct proc_ops kpagecgroup_proc_ops = {
+       .proc_flags     = PROC_ENTRY_PERMANENT,
        .proc_lseek     = mem_lseek,
        .proc_read      = kpagecgroup_read,
 };
index 12901dc..f461608 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include "internal.h"
 
 /*
  * /proc/softirqs  ... display the number of softirqs
@@ -27,7 +28,10 @@ static int show_softirqs(struct seq_file *p, void *v)
 
 static int __init proc_softirqs_init(void)
 {
-       proc_create_single("softirqs", 0, NULL, show_softirqs);
+       struct proc_dir_entry *pde;
+
+       pde = proc_create_single("softirqs", 0, NULL, show_softirqs);
+       pde_make_permanent(pde);
        return 0;
 }
 fs_initcall(proc_softirqs_init);
index deb99bc..b5343d2 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/time.h>
 #include <linux/time_namespace.h>
 #include <linux/kernel_stat.h>
+#include "internal.h"
 
 static int uptime_proc_show(struct seq_file *m, void *v)
 {
@@ -39,7 +40,10 @@ static int uptime_proc_show(struct seq_file *m, void *v)
 
 static int __init proc_uptime_init(void)
 {
-       proc_create_single("uptime", 0, NULL, uptime_proc_show);
+       struct proc_dir_entry *pde;
+
+       pde = proc_create_single("uptime", 0, NULL, uptime_proc_show);
+       pde_make_permanent(pde);
        return 0;
 }
 fs_initcall(proc_uptime_init);
index b449f18..02e3c3c 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/utsname.h>
+#include "internal.h"
 
 static int version_proc_show(struct seq_file *m, void *v)
 {
@@ -17,7 +18,10 @@ static int version_proc_show(struct seq_file *m, void *v)
 
 static int __init proc_version_init(void)
 {
-       proc_create_single("version", 0, NULL, version_proc_show);
+       struct proc_dir_entry *pde;
+
+       pde = proc_create_single("version", 0, NULL, version_proc_show);
+       pde_make_permanent(pde);
        return 0;
 }
 fs_initcall(proc_version_init);