lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140613200338.GA2149@p183.telecom.by>
Date:	Fri, 13 Jun 2014 23:03:38 +0300
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	viro@...iv.linux.org.uk, akpm@...ux-foundation.org
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] proc: faster /proc/$PID lookup

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@...il.com>
---

 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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ