diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-10-19 02:40:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-19 14:53:40 -0400 |
commit | 228ebcbe634a30aec35132ea4375721bcc41bec0 (patch) | |
tree | a875976fd5bde6e2f931aa235c34c88a2738493f | |
parent | b488893a390edfe027bae7a46e9af8083e740668 (diff) |
Uninline find_task_by_xxx set of functions
The find_task_by_something is a set of macros are used to find task by pid
depending on what kind of pid is proposed - global or virtual one. All of
them are wrappers above the most generic one - find_task_by_pid_type_ns() -
and just substitute some args for it.
It turned out, that dereferencing the current->nsproxy->pid_ns construction
and pushing one more argument on the stack inline cause kernel text size to
grow.
This patch moves all this stuff out-of-line into kernel/pid.c. Together
with the next patch it saves a bit less than 400 bytes from the .text
section.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Paul Menage <menage@google.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/ioprio.c | 6 | ||||
-rw-r--r-- | include/linux/sched.h | 15 | ||||
-rw-r--r-- | kernel/capability.c | 6 | ||||
-rw-r--r-- | kernel/futex.c | 7 | ||||
-rw-r--r-- | kernel/futex_compat.c | 3 | ||||
-rw-r--r-- | kernel/pid.c | 19 | ||||
-rw-r--r-- | kernel/ptrace.c | 3 | ||||
-rw-r--r-- | kernel/sched.c | 3 | ||||
-rw-r--r-- | kernel/signal.c | 2 | ||||
-rw-r--r-- | kernel/sys.c | 9 | ||||
-rw-r--r-- | mm/mempolicy.c | 3 | ||||
-rw-r--r-- | mm/migrate.c | 3 |
12 files changed, 41 insertions, 38 deletions
diff --git a/fs/ioprio.c b/fs/ioprio.c index 0a615f87142e..d6ff77e8e7ec 100644 --- a/fs/ioprio.c +++ b/fs/ioprio.c | |||
@@ -94,8 +94,7 @@ asmlinkage long sys_ioprio_set(int which, int who, int ioprio) | |||
94 | if (!who) | 94 | if (!who) |
95 | p = current; | 95 | p = current; |
96 | else | 96 | else |
97 | p = find_task_by_pid_ns(who, | 97 | p = find_task_by_vpid(who); |
98 | current->nsproxy->pid_ns); | ||
99 | if (p) | 98 | if (p) |
100 | ret = set_task_ioprio(p, ioprio); | 99 | ret = set_task_ioprio(p, ioprio); |
101 | break; | 100 | break; |
@@ -182,8 +181,7 @@ asmlinkage long sys_ioprio_get(int which, int who) | |||
182 | if (!who) | 181 | if (!who) |
183 | p = current; | 182 | p = current; |
184 | else | 183 | else |
185 | p = find_task_by_pid_ns(who, | 184 | p = find_task_by_vpid(who); |
186 | current->nsproxy->pid_ns); | ||
187 | if (p) | 185 | if (p) |
188 | ret = get_task_ioprio(p); | 186 | ret = get_task_ioprio(p); |
189 | break; | 187 | break; |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 1301c0875370..f4d969e85612 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1523,9 +1523,8 @@ extern struct pid_namespace init_pid_ns; | |||
1523 | * type and namespace specified | 1523 | * type and namespace specified |
1524 | * find_task_by_pid_ns(): | 1524 | * find_task_by_pid_ns(): |
1525 | * finds a task by its pid in the specified namespace | 1525 | * finds a task by its pid in the specified namespace |
1526 | * find_task_by_pid_type(): | 1526 | * find_task_by_vpid(): |
1527 | * finds a task by its global id with the specified type, e.g. | 1527 | * finds a task by its virtual pid |
1528 | * by global session id | ||
1529 | * find_task_by_pid(): | 1528 | * find_task_by_pid(): |
1530 | * finds a task by its global pid | 1529 | * finds a task by its global pid |
1531 | * | 1530 | * |
@@ -1535,12 +1534,10 @@ extern struct pid_namespace init_pid_ns; | |||
1535 | extern struct task_struct *find_task_by_pid_type_ns(int type, int pid, | 1534 | extern struct task_struct *find_task_by_pid_type_ns(int type, int pid, |
1536 | struct pid_namespace *ns); | 1535 | struct pid_namespace *ns); |
1537 | 1536 | ||
1538 | #define find_task_by_pid_ns(nr, ns) \ | 1537 | extern struct task_struct *find_task_by_pid(pid_t nr); |
1539 | find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns) | 1538 | extern struct task_struct *find_task_by_vpid(pid_t nr); |
1540 | #define find_task_by_pid_type(type, nr) \ | 1539 | extern struct task_struct *find_task_by_pid_ns(pid_t nr, |
1541 | find_task_by_pid_type_ns(type, nr, &init_pid_ns) | 1540 | struct pid_namespace *ns); |
1542 | #define find_task_by_pid(nr) \ | ||
1543 | find_task_by_pid_type(PIDTYPE_PID, nr) | ||
1544 | 1541 | ||
1545 | extern void __set_special_pids(pid_t session, pid_t pgrp); | 1542 | extern void __set_special_pids(pid_t session, pid_t pgrp); |
1546 | 1543 | ||
diff --git a/kernel/capability.c b/kernel/capability.c index d4377c5a36c9..0d0d886d1e84 100644 --- a/kernel/capability.c +++ b/kernel/capability.c | |||
@@ -63,8 +63,7 @@ asmlinkage long sys_capget(cap_user_header_t header, cap_user_data_t dataptr) | |||
63 | read_lock(&tasklist_lock); | 63 | read_lock(&tasklist_lock); |
64 | 64 | ||
65 | if (pid && pid != task_pid_vnr(current)) { | 65 | if (pid && pid != task_pid_vnr(current)) { |
66 | target = find_task_by_pid_ns(pid, | 66 | target = find_task_by_vpid(pid); |
67 | current->nsproxy->pid_ns); | ||
68 | if (!target) { | 67 | if (!target) { |
69 | ret = -ESRCH; | 68 | ret = -ESRCH; |
70 | goto out; | 69 | goto out; |
@@ -198,8 +197,7 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data) | |||
198 | read_lock(&tasklist_lock); | 197 | read_lock(&tasklist_lock); |
199 | 198 | ||
200 | if (pid > 0 && pid != task_pid_vnr(current)) { | 199 | if (pid > 0 && pid != task_pid_vnr(current)) { |
201 | target = find_task_by_pid_ns(pid, | 200 | target = find_task_by_vpid(pid); |
202 | current->nsproxy->pid_ns); | ||
203 | if (!target) { | 201 | if (!target) { |
204 | ret = -ESRCH; | 202 | ret = -ESRCH; |
205 | goto out; | 203 | goto out; |
diff --git a/kernel/futex.c b/kernel/futex.c index 86b2600381b6..32710451dc20 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -446,9 +446,7 @@ static struct task_struct * futex_find_get_task(pid_t pid) | |||
446 | struct task_struct *p; | 446 | struct task_struct *p; |
447 | 447 | ||
448 | rcu_read_lock(); | 448 | rcu_read_lock(); |
449 | p = find_task_by_pid_ns(pid, | 449 | p = find_task_by_vpid(pid); |
450 | current->nsproxy->pid_ns); | ||
451 | |||
452 | if (!p || ((current->euid != p->euid) && (current->euid != p->uid))) | 450 | if (!p || ((current->euid != p->euid) && (current->euid != p->uid))) |
453 | p = ERR_PTR(-ESRCH); | 451 | p = ERR_PTR(-ESRCH); |
454 | else | 452 | else |
@@ -1858,8 +1856,7 @@ sys_get_robust_list(int pid, struct robust_list_head __user * __user *head_ptr, | |||
1858 | 1856 | ||
1859 | ret = -ESRCH; | 1857 | ret = -ESRCH; |
1860 | rcu_read_lock(); | 1858 | rcu_read_lock(); |
1861 | p = find_task_by_pid_ns(pid, | 1859 | p = find_task_by_vpid(pid); |
1862 | current->nsproxy->pid_ns); | ||
1863 | if (!p) | 1860 | if (!p) |
1864 | goto err_unlock; | 1861 | goto err_unlock; |
1865 | ret = -EPERM; | 1862 | ret = -EPERM; |
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c index cc098e1de960..00b572666cc7 100644 --- a/kernel/futex_compat.c +++ b/kernel/futex_compat.c | |||
@@ -125,8 +125,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, | |||
125 | 125 | ||
126 | ret = -ESRCH; | 126 | ret = -ESRCH; |
127 | read_lock(&tasklist_lock); | 127 | read_lock(&tasklist_lock); |
128 | p = find_task_by_pid_ns(pid, | 128 | p = find_task_by_vpid(pid); |
129 | current->nsproxy->pid_ns); | ||
130 | if (!p) | 129 | if (!p) |
131 | goto err_unlock; | 130 | goto err_unlock; |
132 | ret = -EPERM; | 131 | ret = -EPERM; |
diff --git a/kernel/pid.c b/kernel/pid.c index b3e6d7c41b97..73a60e265f52 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -369,6 +369,25 @@ struct task_struct *find_task_by_pid_type_ns(int type, int nr, | |||
369 | 369 | ||
370 | EXPORT_SYMBOL(find_task_by_pid_type_ns); | 370 | EXPORT_SYMBOL(find_task_by_pid_type_ns); |
371 | 371 | ||
372 | struct task_struct *find_task_by_pid(pid_t nr) | ||
373 | { | ||
374 | return find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns); | ||
375 | } | ||
376 | EXPORT_SYMBOL(find_task_by_pid); | ||
377 | |||
378 | struct task_struct *find_task_by_vpid(pid_t vnr) | ||
379 | { | ||
380 | return find_task_by_pid_type_ns(PIDTYPE_PID, vnr, | ||
381 | current->nsproxy->pid_ns); | ||
382 | } | ||
383 | EXPORT_SYMBOL(find_task_by_vpid); | ||
384 | |||
385 | struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns) | ||
386 | { | ||
387 | return find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns); | ||
388 | } | ||
389 | EXPORT_SYMBOL(find_task_by_pid_ns); | ||
390 | |||
372 | struct pid *get_task_pid(struct task_struct *task, enum pid_type type) | 391 | struct pid *get_task_pid(struct task_struct *task, enum pid_type type) |
373 | { | 392 | { |
374 | struct pid *pid; | 393 | struct pid *pid; |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 66e99eb2d8a6..b0ace60ce596 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -444,8 +444,7 @@ struct task_struct *ptrace_get_task_struct(pid_t pid) | |||
444 | return ERR_PTR(-EPERM); | 444 | return ERR_PTR(-EPERM); |
445 | 445 | ||
446 | read_lock(&tasklist_lock); | 446 | read_lock(&tasklist_lock); |
447 | child = find_task_by_pid_ns(pid, | 447 | child = find_task_by_vpid(pid); |
448 | current->nsproxy->pid_ns); | ||
449 | if (child) | 448 | if (child) |
450 | get_task_struct(child); | 449 | get_task_struct(child); |
451 | 450 | ||
diff --git a/kernel/sched.c b/kernel/sched.c index 4ac56fe3c394..5d5e107ebc4e 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -4168,8 +4168,7 @@ struct task_struct *idle_task(int cpu) | |||
4168 | */ | 4168 | */ |
4169 | static struct task_struct *find_process_by_pid(pid_t pid) | 4169 | static struct task_struct *find_process_by_pid(pid_t pid) |
4170 | { | 4170 | { |
4171 | return pid ? | 4171 | return pid ? find_task_by_vpid(pid) : current; |
4172 | find_task_by_pid_ns(pid, current->nsproxy->pid_ns) : current; | ||
4173 | } | 4172 | } |
4174 | 4173 | ||
4175 | /* Actually do priority change: must hold rq lock. */ | 4174 | /* Actually do priority change: must hold rq lock. */ |
diff --git a/kernel/signal.c b/kernel/signal.c index d809cdd6c0f1..783b33a0af06 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -2237,7 +2237,7 @@ static int do_tkill(int tgid, int pid, int sig) | |||
2237 | info.si_uid = current->uid; | 2237 | info.si_uid = current->uid; |
2238 | 2238 | ||
2239 | read_lock(&tasklist_lock); | 2239 | read_lock(&tasklist_lock); |
2240 | p = find_task_by_pid_ns(pid, current->nsproxy->pid_ns); | 2240 | p = find_task_by_vpid(pid); |
2241 | if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { | 2241 | if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { |
2242 | error = check_kill_permission(sig, &info, p); | 2242 | error = check_kill_permission(sig, &info, p); |
2243 | /* | 2243 | /* |
diff --git a/kernel/sys.c b/kernel/sys.c index 23620d52cf37..2befc299129d 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -152,8 +152,7 @@ asmlinkage long sys_setpriority(int which, int who, int niceval) | |||
152 | switch (which) { | 152 | switch (which) { |
153 | case PRIO_PROCESS: | 153 | case PRIO_PROCESS: |
154 | if (who) | 154 | if (who) |
155 | p = find_task_by_pid_ns(who, | 155 | p = find_task_by_vpid(who); |
156 | current->nsproxy->pid_ns); | ||
157 | else | 156 | else |
158 | p = current; | 157 | p = current; |
159 | if (p) | 158 | if (p) |
@@ -210,8 +209,7 @@ asmlinkage long sys_getpriority(int which, int who) | |||
210 | switch (which) { | 209 | switch (which) { |
211 | case PRIO_PROCESS: | 210 | case PRIO_PROCESS: |
212 | if (who) | 211 | if (who) |
213 | p = find_task_by_pid_ns(who, | 212 | p = find_task_by_vpid(who); |
214 | current->nsproxy->pid_ns); | ||
215 | else | 213 | else |
216 | p = current; | 214 | p = current; |
217 | if (p) { | 215 | if (p) { |
@@ -1067,7 +1065,8 @@ asmlinkage long sys_setsid(void) | |||
1067 | * session id and so the check will always fail and make it so | 1065 | * session id and so the check will always fail and make it so |
1068 | * init cannot successfully call setsid. | 1066 | * init cannot successfully call setsid. |
1069 | */ | 1067 | */ |
1070 | if (session > 1 && find_task_by_pid_type(PIDTYPE_PGID, session)) | 1068 | if (session > 1 && find_task_by_pid_type_ns(PIDTYPE_PGID, |
1069 | session, &init_pid_ns)) | ||
1071 | goto out; | 1070 | goto out; |
1072 | 1071 | ||
1073 | group_leader->signal->leader = 1; | 1072 | group_leader->signal->leader = 1; |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index a09ca3b1cf9c..c1592a94582f 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -941,8 +941,7 @@ asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode, | |||
941 | 941 | ||
942 | /* Find the mm_struct */ | 942 | /* Find the mm_struct */ |
943 | read_lock(&tasklist_lock); | 943 | read_lock(&tasklist_lock); |
944 | task = pid ? | 944 | task = pid ? find_task_by_vpid(pid) : current; |
945 | find_task_by_pid_ns(pid, current->nsproxy->pid_ns) : current; | ||
946 | if (!task) { | 945 | if (!task) { |
947 | read_unlock(&tasklist_lock); | 946 | read_unlock(&tasklist_lock); |
948 | return -ESRCH; | 947 | return -ESRCH; |
diff --git a/mm/migrate.c b/mm/migrate.c index c479357b5480..4d6ee03db946 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -925,8 +925,7 @@ asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages, | |||
925 | 925 | ||
926 | /* Find the mm_struct */ | 926 | /* Find the mm_struct */ |
927 | read_lock(&tasklist_lock); | 927 | read_lock(&tasklist_lock); |
928 | task = pid ? | 928 | task = pid ? find_task_by_vpid(pid) : current; |
929 | find_task_by_pid_ns(pid, current->nsproxy->pid_ns) : current; | ||
930 | if (!task) { | 929 | if (!task) { |
931 | read_unlock(&tasklist_lock); | 930 | read_unlock(&tasklist_lock); |
932 | return -ESRCH; | 931 | return -ESRCH; |