mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
proc: mark more files as permanent
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>
This commit is contained in:
parent
da6f79164e
commit
ef1d61781b
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user