split the slow path in acct_process() off

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2014-05-07 05:12:09 -04:00
parent cdd37e2309
commit e25ff11ff1

View file

@ -599,8 +599,9 @@ void acct_collect(long exitcode, int group_dead)
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&current->sighand->siglock);
} }
static void acct_process_in_ns(struct pid_namespace *ns) static void slow_acct_process(struct pid_namespace *ns)
{ {
for ( ; ns; ns = ns->parent) {
struct file *file = NULL; struct file *file = NULL;
struct bsd_acct_struct *acct; struct bsd_acct_struct *acct;
@ -609,13 +610,13 @@ static void acct_process_in_ns(struct pid_namespace *ns)
* accelerate the common fastpath: * accelerate the common fastpath:
*/ */
if (!acct || !acct->file) if (!acct || !acct->file)
return; continue;
spin_lock(&acct_lock); spin_lock(&acct_lock);
file = acct->file; file = acct->file;
if (unlikely(!file)) { if (unlikely(!file)) {
spin_unlock(&acct_lock); spin_unlock(&acct_lock);
return; continue;
} }
get_file(file); get_file(file);
spin_unlock(&acct_lock); spin_unlock(&acct_lock);
@ -623,10 +624,10 @@ static void acct_process_in_ns(struct pid_namespace *ns)
do_acct_process(acct, ns, file); do_acct_process(acct, ns, file);
fput(file); fput(file);
} }
}
/** /**
* acct_process - now just a wrapper around acct_process_in_ns, * acct_process
* which in turn is a wrapper around do_acct_process.
* *
* handles process accounting for an exiting task * handles process accounting for an exiting task
*/ */
@ -639,6 +640,11 @@ void acct_process(void)
* alive and holds its namespace, which in turn holds * alive and holds its namespace, which in turn holds
* its parent. * its parent.
*/ */
for (ns = task_active_pid_ns(current); ns != NULL; ns = ns->parent) for (ns = task_active_pid_ns(current); ns != NULL; ns = ns->parent) {
acct_process_in_ns(ns); struct bsd_acct_struct *acct = ns->bacct;
if (acct && acct->file)
break;
}
if (unlikely(ns))
slow_acct_process(ns);
} }