[PATCH] Reduce bkl usage in do_coredump
From: Josh Aas
Date: Mon Aug 09 2004 - 09:47:07 EST
A patch that reduces bkl usage in do_coredump is attached. I don't see
anywhere that it is necessary except for the call to format_corename,
which is controlled via sysctl (sys_sysctl holds the bkl).
Also make format_corename() static.
Signed-off-by: Josh Aas <josha@xxxxxxx>
--
Josh Aas
Silicon Graphics, Inc. (SGI)
Linux System Software
651-683-3068
--- a/fs/exec.c 2004-08-09 09:14:53.000000000 -0500
+++ b/fs/exec.c 2004-08-09 09:18:50.000000000 -0500
@@ -1193,7 +1193,7 @@ EXPORT_SYMBOL(set_binfmt);
* name into corename, which must have space for at least
* CORENAME_MAX_SIZE bytes plus one byte for the zero terminator.
*/
-void format_corename(char *corename, const char *pattern, long signr)
+static void format_corename(char *corename, const char *pattern, long signr)
{
const char *pat_ptr = pattern;
char *out_ptr = corename;
@@ -1357,7 +1357,6 @@ int do_coredump(long signr, int exit_cod
struct file * file;
int retval = 0;
- lock_kernel();
binfmt = current->binfmt;
if (!binfmt || !binfmt->core_dump)
goto fail;
@@ -1375,7 +1374,13 @@ int do_coredump(long signr, int exit_cod
if (current->rlim[RLIMIT_CORE].rlim_cur < binfmt->min_coredump)
goto fail_unlock;
- format_corename(corename, core_pattern, signr);
+ /*
+ * lock_kernel() because format_corename() is controlled by sysctl, which
+ * uses lock_kernel()
+ */
+ lock_kernel();
+ format_corename(corename, core_pattern, signr);
+ unlock_kernel();
file = filp_open(corename, O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE, 0600);
if (IS_ERR(file))
goto fail_unlock;
@@ -1402,6 +1407,5 @@ close_fail:
fail_unlock:
complete_all(&mm->core_done);
fail:
- unlock_kernel();
return retval;
}