Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 40414
b: refs/heads/master
c: a98b609
h: refs/heads/master
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Oct 28, 2006
1 parent b8c7f9a commit 0c89d2f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 36 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: b8534d7bd89df0cd41cd47bcd6733a05ea9a691a
refs/heads/master: a98b6094261c0112e9c455c96995972181bff049
59 changes: 24 additions & 35 deletions trunk/kernel/taskstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,19 @@ static void send_cpu_listeners(struct sk_buff *skb, unsigned int cpu)
up_write(&listeners->sem);
}

static int fill_pid(pid_t pid, struct task_struct *pidtsk,
static int fill_pid(pid_t pid, struct task_struct *tsk,
struct taskstats *stats)
{
int rc = 0;
struct task_struct *tsk = pidtsk;

if (!pidtsk) {
read_lock(&tasklist_lock);
if (!tsk) {
rcu_read_lock();
tsk = find_task_by_pid(pid);
if (!tsk) {
read_unlock(&tasklist_lock);
if (tsk)
get_task_struct(tsk);
rcu_read_unlock();
if (!tsk)
return -ESRCH;
}
get_task_struct(tsk);
read_unlock(&tasklist_lock);
} else
get_task_struct(tsk);

Expand All @@ -214,40 +212,28 @@ static int fill_pid(pid_t pid, struct task_struct *pidtsk,

}

static int fill_tgid(pid_t tgid, struct task_struct *tgidtsk,
static int fill_tgid(pid_t tgid, struct task_struct *first,
struct taskstats *stats)
{
struct task_struct *tsk, *first;
struct task_struct *tsk;
unsigned long flags;
int rc = -ESRCH;

/*
* Add additional stats from live tasks except zombie thread group
* leaders who are already counted with the dead tasks
*/
first = tgidtsk;
if (!first) {
read_lock(&tasklist_lock);
rcu_read_lock();
if (!first)
first = find_task_by_pid(tgid);
if (!first) {
read_unlock(&tasklist_lock);
return -ESRCH;
}
get_task_struct(first);
read_unlock(&tasklist_lock);
} else
get_task_struct(first);

if (!first || !lock_task_sighand(first, &flags))
goto out;

tsk = first;
read_lock(&tasklist_lock);
/* Start with stats from dead tasks */
if (first->sighand) {
spin_lock_irqsave(&first->sighand->siglock, flags);
if (first->signal->stats)
memcpy(stats, first->signal->stats, sizeof(*stats));
spin_unlock_irqrestore(&first->sighand->siglock, flags);
}
if (first->signal->stats)
memcpy(stats, first->signal->stats, sizeof(*stats));

tsk = first;
do {
if (tsk->exit_state == EXIT_ZOMBIE && thread_group_leader(tsk))
continue;
Expand All @@ -260,15 +246,18 @@ static int fill_tgid(pid_t tgid, struct task_struct *tgidtsk,
delayacct_add_tsk(stats, tsk);

} while_each_thread(first, tsk);
read_unlock(&tasklist_lock);
stats->version = TASKSTATS_VERSION;

unlock_task_sighand(first, &flags);
rc = 0;
out:
rcu_read_unlock();

stats->version = TASKSTATS_VERSION;
/*
* Accounting subsytems can also add calls here to modify
* fields of taskstats.
*/
put_task_struct(first);
return 0;
return rc;
}


Expand Down

0 comments on commit 0c89d2f

Please sign in to comment.