linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Czerner <lczerner@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, sandeen@redhat.com, lczerner@redhat.com
Subject: [PATCH] ext4: fix lazyinit thread prevent from sleep
Date: Fri, 22 Oct 2010 20:57:45 +0200	[thread overview]
Message-ID: <1287773865-31168-1-git-send-email-lczerner@redhat.com> (raw)

In my test lazyinit threat (in linux-next tree) consumes too much CPU
(90%). The reason is that there is a bug preventing the threat to sleep
and hence it keeps walking the li_request_list until the time for next
scheduled request comes.

It is because the next_wakeup is originally set to jiffies - 1 so the
thread is assuming that there is no reason to sleep, because the time
for next scheduled event is already came, however that is not true.

I have fixed that by setting next_wakeup to MAX_JIFFY_OFFSET initially
and than setting value of the next scheduled request (the one with the
smallest lr_next_sched value). It has been tested and now the CPU
utilization of lazyinit thread is under 1% (with one request in the list).

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 fs/ext4/super.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 82ceb8b..f0b424a 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2710,7 +2710,7 @@ static int ext4_lazyinit_thread(void *arg)
 
 cont_thread:
 	while (true) {
-		next_wakeup = jiffies-1;
+		next_wakeup = MAX_JIFFY_OFFSET;
 
 		mutex_lock(&eli->li_list_mtx);
 		if (list_empty(&eli->li_request_list)) {
@@ -2722,10 +2722,11 @@ cont_thread:
 			elr = list_entry(pos, struct ext4_li_request,
 					 lr_request);
 
-			if (time_before_eq(jiffies, elr->lr_next_sched))
-				continue;
+			if (time_after_eq(jiffies, elr->lr_next_sched))
+				ret = ext4_run_li_request(elr);
 
-			if ((ret = ext4_run_li_request(elr)) != 0) {
+			if (ret) {
+				ret = 0;
 				ext4_remove_li_request(elr);
 				continue;
 			}
-- 
1.7.2.3


             reply	other threads:[~2010-10-22 18:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22 18:57 Lukas Czerner [this message]
2010-10-25 14:46 ` [PATCH] ext4: fix lazyinit thread prevent from sleep Ted Ts'o

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=1287773865-31168-1-git-send-email-lczerner@redhat.com \
    --to=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=tytso@mit.edu \
    /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;
as well as URLs for NNTP newsgroup(s).