From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Linus Torvalds <torvalds@osdl.org>,
Daniel Walker <dwalker@mvista.com>, Ingo Molnar <mingo@elte.hu>,
"Stephen C. Tweedie" <sct@redhat.com>,
Andrew Morton <akpm@osdl.org>
Subject: kjournald wasting CPU in invert_lock fs/jbd/commit.c
Date: Mon, 11 Jul 2005 18:17:02 -0400 [thread overview]
Message-ID: <1121120222.6087.44.camel@localhost.localdomain> (raw)
I noticed that the code in commit.c of the jbd system can waste CPU
cycles. The offending code is as follows.
static int inverted_lock(journal_t *journal, struct buffer_head *bh)
{
if (!jbd_trylock_bh_state(bh)) {
spin_unlock(&journal->j_list_lock);
schedule();
return 0;
}
return 1;
}
[...]
void journal_commit_transaction(journal_t *journal)
{
[...]
write_out_data:
cond_resched();
spin_lock(&journal->j_list_lock);
while (commit_transaction->t_sync_datalist) {
struct buffer_head *bh;
jh = commit_transaction->t_sync_datalist;
commit_transaction->t_sync_datalist = jh->b_tnext;
bh = jh2bh(jh);
if (buffer_locked(bh)) {
BUFFER_TRACE(bh, "locked");
if (!inverted_lock(journal, bh))
goto write_out_data;
This code makes a loop if the jbd_trylock_bh_state fails. This code will
wait till whoever owns the lock releases it. But it is really in a busy
loop and will only be interrupted when the kjournald uses up all its
quota. So it's basically just wasting CPU cycles here. The following
patch should fix this.
Signed-off-by: Steven Rostedt rostedt@goodmis.org
---
--- a/fs/jbd/commit.c 2005-07-11 17:51:37.000000000 -0400
+++ b/fs/jbd/commit.c 2005-07-11 17:51:58.000000000 -0400
@@ -87,7 +87,7 @@ static int inverted_lock(journal_t *jour
{
if (!jbd_trylock_bh_state(bh)) {
spin_unlock(&journal->j_list_lock);
- schedule();
+ yield();
return 0;
}
return 1;
next reply other threads:[~2005-07-11 22:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-11 22:17 Steven Rostedt [this message]
2005-07-11 22:41 ` kjournald wasting CPU in invert_lock fs/jbd/commit.c Andrew Morton
2005-07-11 23:09 ` Steven Rostedt
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=1121120222.6087.44.camel@localhost.localdomain \
--to=rostedt@goodmis.org \
--cc=akpm@osdl.org \
--cc=dwalker@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=sct@redhat.com \
--cc=torvalds@osdl.org \
/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