Skip to content

Commit

Permalink
bsdacct: account dying tasks in all relevant namespaces
Browse files Browse the repository at this point in the history
This just makes the acct_proces walk the pid namespaces from current up to
the top and account a task in each with the accounting turned on.

ns->parent access if safe lockless, since current it still alive and holds
its namespace, which in turn holds its parent.

Signed-off-by: Pavel Emelyanov <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
xemul authored and torvalds committed Jul 25, 2008
1 parent b5a7174 commit 7d1e135
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions kernel/acct.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,15 +631,9 @@ void acct_collect(long exitcode, int group_dead)
spin_unlock_irq(&current->sighand->siglock);
}

/**
* acct_process - now just a wrapper around do_acct_process
*
* handles process accounting for an exiting task
*/
void acct_process(void)
static void acct_process_in_ns(struct pid_namespace *ns)
{
struct file *file = NULL;
struct pid_namespace *ns = task_active_pid_ns(current);
struct bsd_acct_struct *acct;

acct = ns->bacct;
Expand All @@ -661,3 +655,16 @@ void acct_process(void)
do_acct_process(acct, ns, file);
fput(file);
}

/**
* acct_process - now just a wrapper around do_acct_process
*
* handles process accounting for an exiting task
*/
void acct_process(void)
{
struct pid_namespace *ns;

for (ns = task_active_pid_ns(current); ns != NULL; ns = ns->parent)
acct_process_in_ns(ns);
}

0 comments on commit 7d1e135

Please sign in to comment.