Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139710
b: refs/heads/master
c: 52ee2df
h: refs/heads/master
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Apr 3, 2009
1 parent 1e47814 commit 0d6d856
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2ae448efc87df6d328f5835969076c7f9fce59c3
refs/heads/master: 52ee2dfdd4f51cf422ea6a96a0846dc94244aa37
27 changes: 20 additions & 7 deletions trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1519,17 +1519,23 @@ struct pid_namespace;
*
* see also pid_nr() etc in include/linux/pid.h
*/
pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
struct pid_namespace *ns);

static inline pid_t task_pid_nr(struct task_struct *tsk)
{
return tsk->pid;
}

pid_t task_pid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
static inline pid_t task_pid_nr_ns(struct task_struct *tsk,
struct pid_namespace *ns)
{
return __task_pid_nr_ns(tsk, PIDTYPE_PID, ns);
}

static inline pid_t task_pid_vnr(struct task_struct *tsk)
{
return pid_vnr(task_pid(tsk));
return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
}


Expand All @@ -1551,11 +1557,15 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk)
return tsk->signal->__pgrp;
}

pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk,
struct pid_namespace *ns)
{
return __task_pid_nr_ns(tsk, PIDTYPE_PGID, ns);
}

static inline pid_t task_pgrp_vnr(struct task_struct *tsk)
{
return pid_vnr(task_pgrp(tsk));
return __task_pid_nr_ns(tsk, PIDTYPE_PGID, NULL);
}


Expand All @@ -1564,14 +1574,17 @@ static inline pid_t task_session_nr(struct task_struct *tsk)
return tsk->signal->__session;
}

pid_t task_session_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
static inline pid_t task_session_nr_ns(struct task_struct *tsk,
struct pid_namespace *ns)
{
return __task_pid_nr_ns(tsk, PIDTYPE_SID, ns);
}

static inline pid_t task_session_vnr(struct task_struct *tsk)
{
return pid_vnr(task_session(tsk));
return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL);
}


/**
* pid_alive - check that a task structure is not stale
* @p: Task structure to be checked.
Expand Down
31 changes: 16 additions & 15 deletions trunk/kernel/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,30 +452,31 @@ pid_t pid_vnr(struct pid *pid)
}
EXPORT_SYMBOL_GPL(pid_vnr);

pid_t task_pid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
struct pid_namespace *ns)
{
return pid_nr_ns(task_pid(tsk), ns);
pid_t nr = 0;

rcu_read_lock();
if (!ns)
ns = current->nsproxy->pid_ns;
if (likely(pid_alive(task))) {
if (type != PIDTYPE_PID)
task = task->group_leader;
nr = pid_nr_ns(task->pids[type].pid, ns);
}
rcu_read_unlock();

return nr;
}
EXPORT_SYMBOL(task_pid_nr_ns);
EXPORT_SYMBOL(__task_pid_nr_ns);

pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
{
return pid_nr_ns(task_tgid(tsk), ns);
}
EXPORT_SYMBOL(task_tgid_nr_ns);

pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
{
return pid_nr_ns(task_pgrp(tsk), ns);
}
EXPORT_SYMBOL(task_pgrp_nr_ns);

pid_t task_session_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
{
return pid_nr_ns(task_session(tsk), ns);
}
EXPORT_SYMBOL(task_session_nr_ns);

struct pid_namespace *task_active_pid_ns(struct task_struct *tsk)
{
return ns_of_pid(task_pid(tsk));
Expand Down

0 comments on commit 0d6d856

Please sign in to comment.