aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2017-11-17 18:26:49 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-17 19:10:00 -0500
commit3ee2a19908f27b8fea8ff14ffa8b755585eb7b4a (patch)
tree4dc375234b65b25e1f8088691faad72f80a2cb5b /fs/proc
parentc643401218be0f4ab3522e0c0a63016596d6e9ca (diff)
proc: : uninline name_to_int()
Save ~360 bytes. add/remove: 1/0 grow/shrink: 0/4 up/down: 104/-463 (-359) function old new delta name_to_int - 104 +104 proc_pid_lookup 217 126 -91 proc_lookupfd_common 212 121 -91 proc_task_lookup 289 194 -95 __proc_create 588 402 -186 Link: http://lkml.kernel.org/r/20170912194850.GA17730@avx2 Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/Makefile1
-rw-r--r--fs/proc/internal.h23
-rw-r--r--fs/proc/util.c23
3 files changed, 25 insertions, 22 deletions
diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index f7456c4e7d0f..ead487e80510 100644
--- a/fs/proc/Makefile
+++ b/fs/proc/Makefile
@@ -21,6 +21,7 @@ proc-y += loadavg.o
21proc-y += meminfo.o 21proc-y += meminfo.o
22proc-y += stat.o 22proc-y += stat.o
23proc-y += uptime.o 23proc-y += uptime.o
24proc-y += util.o
24proc-y += version.o 25proc-y += version.o
25proc-y += softirqs.o 26proc-y += softirqs.o
26proc-y += namespaces.o 27proc-y += namespaces.o
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index a34195e92b20..9aad373cf11d 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -103,28 +103,7 @@ static inline struct task_struct *get_proc_task(struct inode *inode)
103void task_dump_owner(struct task_struct *task, mode_t mode, 103void task_dump_owner(struct task_struct *task, mode_t mode,
104 kuid_t *ruid, kgid_t *rgid); 104 kuid_t *ruid, kgid_t *rgid);
105 105
106static inline unsigned name_to_int(const struct qstr *qstr) 106unsigned name_to_int(const struct qstr *qstr);
107{
108 const char *name = qstr->name;
109 int len = qstr->len;
110 unsigned n = 0;
111
112 if (len > 1 && *name == '0')
113 goto out;
114 while (len-- > 0) {
115 unsigned c = *name++ - '0';
116 if (c > 9)
117 goto out;
118 if (n >= (~0U-9)/10)
119 goto out;
120 n *= 10;
121 n += c;
122 }
123 return n;
124out:
125 return ~0U;
126}
127
128/* 107/*
129 * Offset of the first process in the /proc root directory.. 108 * Offset of the first process in the /proc root directory..
130 */ 109 */
diff --git a/fs/proc/util.c b/fs/proc/util.c
new file mode 100644
index 000000000000..c29aa497394b
--- /dev/null
+++ b/fs/proc/util.c
@@ -0,0 +1,23 @@
1#include <linux/dcache.h>
2
3unsigned name_to_int(const struct qstr *qstr)
4{
5 const char *name = qstr->name;
6 int len = qstr->len;
7 unsigned n = 0;
8
9 if (len > 1 && *name == '0')
10 goto out;
11 while (len-- > 0) {
12 unsigned c = *name++ - '0';
13 if (c > 9)
14 goto out;
15 if (n >= (~0U-9)/10)
16 goto out;
17 n *= 10;
18 n += c;
19 }
20 return n;
21out:
22 return ~0U;
23}