From: Dave Hansen <haveblue@us.ibm.com>
To: Josh Aas <josha@sgi.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>,
steiner@sgi.com
Subject: Re: [PATCH] Reduce bkl usage in do_coredump
Date: Mon, 09 Aug 2004 10:30:32 -0700 [thread overview]
Message-ID: <1092072631.6496.14553.camel@nighthawk> (raw)
In-Reply-To: <41178C49.3080305@sgi.com>
[-- Attachment #1: Type: text/plain, Size: 1015 bytes --]
On Mon, 2004-08-09 at 07:38, Josh Aas wrote:
> 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).
> - 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();
Might be nicer to just put the locking inside of format_corename() if it
is the function itself that really needs the locking. If another use of
it popped up, that user would get the locking for free and couldn't
possibly forget it. Also, it's nicer to put the lock closer to the code
that actually needs it. Untested patch to do that attached.
BTW, were you actually seeing a BKL contention problem, or was this just
for cleanliness?
-- Dave
[-- Attachment #2: coredump_bkl-1.patch --]
[-- Type: text/x-patch, Size: 1325 bytes --]
--- clean-fixup.1/fs/exec.c.orig 2004-08-09 10:25:27.000000000 -0700
+++ clean-fixup.1/fs/exec.c 2004-08-09 10:27:25.000000000 -0700
@@ -1209,7 +1209,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;
@@ -1217,6 +1217,10 @@ void format_corename(char *corename, con
int rc;
int pid_in_pattern = 0;
+ /*
+ * the format is controlled by sysctl, which uses lock_kernel()
+ */
+ lock_kernel();
/* Repeat as long as we have more pattern to process and more output
space */
while (*pat_ptr) {
@@ -1317,6 +1321,8 @@ void format_corename(char *corename, con
}
out:
*out_ptr = 0;
+
+ unlock_kernel();
}
static void zap_threads (struct mm_struct *mm)
@@ -1373,7 +1379,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;
@@ -1418,6 +1423,5 @@ close_fail:
fail_unlock:
complete_all(&mm->core_done);
fail:
- unlock_kernel();
return retval;
}
next prev parent reply other threads:[~2004-08-09 17:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-09 14:38 [PATCH] Reduce bkl usage in do_coredump Josh Aas
2004-08-09 17:30 ` Dave Hansen [this message]
2004-08-09 17:45 ` Josh Aas
2004-08-09 18:13 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1092072631.6496.14553.camel@nighthawk \
--to=haveblue@us.ibm.com \
--cc=akpm@osdl.org \
--cc=josha@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=steiner@sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox