From: Oleg Nesterov Date: Wed, 23 Sep 2009 22:56:49 +0000 (-0700) Subject: do_wait-wakeup-optimization: simplify task_pid_type() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=989264f4645c183331a1279d513f4b1ddc06e1f5;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git do_wait-wakeup-optimization: simplify task_pid_type() task_pid_type() is only used by eligible_pid() which has to check wo_type != PIDTYPE_MAX anyway. Remove this check from task_pid_type() and factor out ->pids[type] access, this shrinks .text a bit and simplifies the code. The matches the behaviour of other similar helpers, say get_task_pid(). The caller must ensure that pid_type is valid, not the callee. Signed-off-by: Oleg Nesterov Cc: Roland McGrath Cc: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/exit.c b/kernel/exit.c index 3fb9a77863d5..650c1d1a55d0 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1101,17 +1101,15 @@ struct wait_opts { int notask_error; }; -static struct pid *task_pid_type(struct task_struct *task, enum pid_type type) +static inline +struct pid *task_pid_type(struct task_struct *task, enum pid_type type) { - struct pid *pid = NULL; - if (type == PIDTYPE_PID) - pid = task->pids[type].pid; - else if (type < PIDTYPE_MAX) - pid = task->group_leader->pids[type].pid; - return pid; + if (type != PIDTYPE_PID) + task = task->group_leader; + return task->pids[type].pid; } -static inline int eligible_pid(struct wait_opts *wo, struct task_struct *p) +static int eligible_pid(struct wait_opts *wo, struct task_struct *p) { return wo->wo_type == PIDTYPE_MAX || task_pid_type(p, wo->wo_type) == wo->wo_pid;