Commit d24d1d3a authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] BSD accounting speedup

From: Ingo Molnar <mingo@elte.hu>

Most distributions turn on process accounting - but even the common
'accounting is off' case is horrible SMP-scalability-wise: it accesses a
global spinlock during every sys_exit() call, which bounces like mad on SMP
(and NUMA) systems.

(i also got rid of the unused return code.)
parent d029f790
...@@ -78,7 +78,7 @@ struct acct ...@@ -78,7 +78,7 @@ struct acct
#ifdef CONFIG_BSD_PROCESS_ACCT #ifdef CONFIG_BSD_PROCESS_ACCT
struct super_block; struct super_block;
extern void acct_auto_close(struct super_block *sb); extern void acct_auto_close(struct super_block *sb);
extern int acct_process(long exitcode); extern void acct_process(long exitcode);
#else #else
#define acct_auto_close(x) do { } while (0) #define acct_auto_close(x) do { } while (0)
#define acct_process(x) do { } while (0) #define acct_process(x) do { } while (0)
......
...@@ -394,17 +394,26 @@ static void do_acct_process(long exitcode, struct file *file) ...@@ -394,17 +394,26 @@ static void do_acct_process(long exitcode, struct file *file)
/* /*
* acct_process - now just a wrapper around do_acct_process * acct_process - now just a wrapper around do_acct_process
*/ */
int acct_process(long exitcode) void acct_process(long exitcode)
{ {
struct file *file = NULL; struct file *file = NULL;
/*
* accelerate the common fastpath:
*/
if (!acct_globals.file)
return;
spin_lock(&acct_globals.lock); spin_lock(&acct_globals.lock);
if (acct_globals.file) { file = acct_globals.file;
file = acct_globals.file; if (!file)
get_file(file); goto out_unlock;
spin_unlock(&acct_globals.lock);
do_acct_process(exitcode, file); get_file(file);
fput(file); spin_unlock(&acct_globals.lock);
} else do_acct_process(exitcode, file);
spin_unlock(&acct_globals.lock); fput(file);
return 0;
out_unlock:
spin_unlock(&acct_globals.lock);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment