summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-10-18 23:40:16 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 11:53:40 -0700
commit228ebcbe634a30aec35132ea4375721bcc41bec0 (patch)
treea875976fd5bde6e2f931aa235c34c88a2738493f
parentb488893a390edfe027bae7a46e9af8083e740668 (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.c6
-rw-r--r--include/linux/sched.h15
-rw-r--r--kernel/capability.c6
-rw-r--r--kernel/futex.c7
-rw-r--r--kernel/futex_compat.c3
-rw-r--r--kernel/pid.c19
-rw-r--r--kernel/ptrace.c3
-rw-r--r--kernel/sched.c3
-rw-r--r--kernel/signal.c2
-rw-r--r--kernel/sys.c9
-rw-r--r--mm/mempolicy.c3
-rw-r--r--mm/migrate.c3
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)
if (!who)
p = current;
else
- p = find_task_by_pid_ns(who,
- current->nsproxy->pid_ns);
+ p = find_task_by_vpid(who);
if (p)
ret = set_task_ioprio(p, ioprio);
break;
@@ -182,8 +181,7 @@ asmlinkage long sys_ioprio_get(int which, int who)
if (!who)
p = current;
else
- p = find_task_by_pid_ns(who,
- current->nsproxy->pid_ns);
+ p = find_task_by_vpid(who);
if (p)
ret = get_task_ioprio(p);
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;
* type and namespace specified
* find_task_by_pid_ns():
* finds a task by its pid in the specified namespace
- * find_task_by_pid_type():
- * finds a task by its global id with the specified type, e.g.
- * by global session id
+ * find_task_by_vpid():
+ * finds a task by its virtual pid
* find_task_by_pid():
* finds a task by its global pid
*
@@ -1535,12 +1534,10 @@ extern struct pid_namespace init_pid_ns;
extern struct task_struct *find_task_by_pid_type_ns(int type, int pid,
struct pid_namespace *ns);
-#define find_task_by_pid_ns(nr, ns) \
- find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns)
-#define find_task_by_pid_type(type, nr) \
- find_task_by_pid_type_ns(type, nr, &init_pid_ns)
-#define find_task_by_pid(nr) \
- find_task_by_pid_type(PIDTYPE_PID, nr)
+extern struct task_struct *find_task_by_pid(pid_t nr);
+extern struct task_struct *find_task_by_vpid(pid_t nr);
+extern struct task_struct *find_task_by_pid_ns(pid_t nr,
+ struct pid_namespace *ns);
extern void __set_special_pids(pid_t session, pid_t pgrp);
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)
read_lock(&tasklist_lock);
if (pid && pid != task_pid_vnr(current)) {
- target = find_task_by_pid_ns(pid,
- current->nsproxy->pid_ns);
+ target = find_task_by_vpid(pid);
if (!target) {
ret = -ESRCH;
goto out;
@@ -198,8 +197,7 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data)
read_lock(&tasklist_lock);
if (pid > 0 && pid != task_pid_vnr(current)) {
- target = find_task_by_pid_ns(pid,
- current->nsproxy->pid_ns);
+ target = find_task_by_vpid(pid);
if (!target) {
ret = -ESRCH;
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)
struct task_struct *p;
rcu_read_lock();
- p = find_task_by_pid_ns(pid,
- current->nsproxy->pid_ns);
-
+ p = find_task_by_vpid(pid);
if (!p || ((current->euid != p->euid) && (current->euid != p->uid)))
p = ERR_PTR(-ESRCH);
else
@@ -1858,8 +1856,7 @@ sys_get_robust_list(int pid, struct robust_list_head __user * __user *head_ptr,
ret = -ESRCH;
rcu_read_lock();
- p = find_task_by_pid_ns(pid,
- current->nsproxy->pid_ns);
+ p = find_task_by_vpid(pid);
if (!p)
goto err_unlock;
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,
ret = -ESRCH;
read_lock(&tasklist_lock);
- p = find_task_by_pid_ns(pid,
- current->nsproxy->pid_ns);
+ p = find_task_by_vpid(pid);
if (!p)
goto err_unlock;
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,
EXPORT_SYMBOL(find_task_by_pid_type_ns);
+struct task_struct *find_task_by_pid(pid_t nr)
+{
+ return find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns);
+}
+EXPORT_SYMBOL(find_task_by_pid);
+
+struct task_struct *find_task_by_vpid(pid_t vnr)
+{
+ return find_task_by_pid_type_ns(PIDTYPE_PID, vnr,
+ current->nsproxy->pid_ns);
+}
+EXPORT_SYMBOL(find_task_by_vpid);
+
+struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
+{
+ return find_task_by_pid_type_ns(PIDTYPE_PID, nr, ns);
+}
+EXPORT_SYMBOL(find_task_by_pid_ns);
+
struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
{
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)
return ERR_PTR(-EPERM);
read_lock(&tasklist_lock);
- child = find_task_by_pid_ns(pid,
- current->nsproxy->pid_ns);
+ child = find_task_by_vpid(pid);
if (child)
get_task_struct(child);
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)
*/
static struct task_struct *find_process_by_pid(pid_t pid)
{
- return pid ?
- find_task_by_pid_ns(pid, current->nsproxy->pid_ns) : current;
+ return pid ? find_task_by_vpid(pid) : current;
}
/* 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)
info.si_uid = current->uid;
read_lock(&tasklist_lock);
- p = find_task_by_pid_ns(pid, current->nsproxy->pid_ns);
+ p = find_task_by_vpid(pid);
if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
error = check_kill_permission(sig, &info, p);
/*
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)
switch (which) {
case PRIO_PROCESS:
if (who)
- p = find_task_by_pid_ns(who,
- current->nsproxy->pid_ns);
+ p = find_task_by_vpid(who);
else
p = current;
if (p)
@@ -210,8 +209,7 @@ asmlinkage long sys_getpriority(int which, int who)
switch (which) {
case PRIO_PROCESS:
if (who)
- p = find_task_by_pid_ns(who,
- current->nsproxy->pid_ns);
+ p = find_task_by_vpid(who);
else
p = current;
if (p) {
@@ -1067,7 +1065,8 @@ asmlinkage long sys_setsid(void)
* session id and so the check will always fail and make it so
* init cannot successfully call setsid.
*/
- if (session > 1 && find_task_by_pid_type(PIDTYPE_PGID, session))
+ if (session > 1 && find_task_by_pid_type_ns(PIDTYPE_PGID,
+ session, &init_pid_ns))
goto out;
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,
/* Find the mm_struct */
read_lock(&tasklist_lock);
- task = pid ?
- find_task_by_pid_ns(pid, current->nsproxy->pid_ns) : current;
+ task = pid ? find_task_by_vpid(pid) : current;
if (!task) {
read_unlock(&tasklist_lock);
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,
/* Find the mm_struct */
read_lock(&tasklist_lock);
- task = pid ?
- find_task_by_pid_ns(pid, current->nsproxy->pid_ns) : current;
+ task = pid ? find_task_by_vpid(pid) : current;
if (!task) {
read_unlock(&tasklist_lock);
return -ESRCH;