]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
proc/kcore: mark proc entry as permanent
authorOmar Sandoval <osandov@fb.com>
Sat, 9 Nov 2024 01:28:39 +0000 (17:28 -0800)
committerChristian Brauner <brauner@kernel.org>
Mon, 2 Dec 2024 10:21:03 +0000 (11:21 +0100)
drgn reads from /proc/kcore to debug the running kernel. For many drgn
scripts, /proc/kcore is actually a bottleneck.

use_pde() and unuse_pde() in prog_reg_read() show up hot in profiles.
Since the entry for /proc/kcore can never be removed, this is useless
overhead that can be trivially avoided by marking the entry as
permanent.

In my benchmark, this reduces the time per read by about 20 nanoseconds,
from 235 nanoseconds per read to 215.

Link: https://github.com/osandov/drgn/issues/106
Signed-off-by: Omar Sandoval <osandov@fb.com>
Link: https://lore.kernel.org/r/60873e6afcfda3f08d0456f19e4733612afcf134.1731115587.git.osandov@fb.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/proc/kcore.c

index e376f48c4b8bf48e36222008d13f22a8cd892e1c..fba609a19ec4dc528099f5155e1e3d4500208678 100644 (file)
@@ -663,6 +663,7 @@ static int release_kcore(struct inode *inode, struct file *file)
 }
 
 static const struct proc_ops kcore_proc_ops = {
+       .proc_flags     = PROC_ENTRY_PERMANENT,
        .proc_read_iter = read_kcore_iter,
        .proc_open      = open_kcore,
        .proc_release   = release_kcore,