[PATCH] proc: faster /proc/$PID lookup
From: Alexey Dobriyan
Date: Fri Jun 13 2014 - 16:03:42 EST
Use first character as a hint for /proc/$PID lookup.
Currently it takes one spinlock and search through dozens of
misc proc entries which can not match /proc/$PID.
Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx>
---
fs/proc/root.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -199,10 +199,17 @@ static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry, unsigned int flags)
{
- if (!proc_lookup(dir, dentry, flags))
- return NULL;
-
- return proc_pid_lookup(dir, dentry, flags);
+ const char c = dentry->d_name.name[0];
+ struct dentry *rv;
+
+ if ('0' <= c && c <= '9') {
+ rv = proc_pid_lookup(dir, dentry, flags);
+ if (rv)
+ rv = proc_lookup(dir, dentry, flags);
+ } else {
+ rv = proc_lookup(dir, dentry, flags);
+ }
+ return rv;
}
static int proc_root_readdir(struct file *file, struct dir_context *ctx)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/