OpenVZ Forum - RDF feed
type: channel
items: [PATCH 4/6] Use pid_to_nr() in process info functions

[PATCH 4/6] Use pid_to_nr() in process info functions
type: item
description: Subject: [PATCH 4/6] Use pid_to_nr() in process info functions From: Sukadev Bhattiprolu <sukadev@us.ibm.com> Use pid_to_nr() function in getppid(), getpgid() and getsid() functions so they return the correct pid_t for processes in multiple pid namespaces. Note: We don't need pid_to_nr() in getpid() because the process always "sees itself" as being in its active pid namespace. Using pid_to_nr() in getpid() would unnecessarily hurt its performance. Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com> --- include/linux/sched.h | 24 ++++++++++++++++++++++++ kernel/sys.c | 10 +++++----- kernel/timer.c | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) Index: lx26-22-rc6-mm1/include/linux/sched.h =================================================================== --- lx26-22-rc6-mm1.orig/include/linux/sched.h 2007-07-05 18:53:42.000000000 -0700 +++ lx26-22-rc6-mm1/include/linux/sched.h 2007-07-05 18:57:34.000000000 -0700 @@ -1200,6 +1200,30 @@ static inline struct pid *task_tgid(stru return task->group_leader->pids[PIDTYPE_PID].pid; } +/* NOTE: Caller must hold rcu_readlock() */ +static inline struct pid *task_parent_tgid(struct task_struct *task) +{ + return task_tgid(rcu_dereference(task->real_parent)); +} + +/* NOTE: Caller must hold rcu_readlock() */ +static inline struct pid *task_parent_pid(struct task_struct *task) +{ + return task_pid(rcu_dereference(task->real_parent)); +} + +/* NOTE: Caller must hold rcu_readlock() */ +static inline struct pid *task_tracer_tgid(struct task_struct *task) +{ + return task_tgid(rcu_dereference(task->parent)); +} + +/* NOTE: Caller must hold rcu_readlock() */ +static inline struct pid *task_tracer_pid(struct task_struct *task) +{ + return task_pid(rcu_dereference(task->parent)); +} + static inline struct pid *task_pgrp(struct task_struct *task) { return task->group_leader->pids[PIDTYPE_PGID].pid; Index: lx26-22-rc6-mm1/kernel/timer.c =================================================================== --- lx26-22-rc6-mm1.or…
creator: Sukadev Bhattiprolu
date: 2007-07-06T05:55:12-00:00