From: Ingo Molnar <mingo@elte.hu>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org,
"Stephen C. Tweedie" <sct@redhat.com>,
Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
Subject: [patch] sched, ext3: fix scheduling latencies in ext3
Date: Tue, 14 Sep 2004 12:06:52 +0200 [thread overview]
Message-ID: <20040914100652.GB24622@elte.hu> (raw)
In-Reply-To: <20040914095731.GA24622@elte.hu>
[-- Attachment #1: Type: text/plain, Size: 226 bytes --]
the attached patch fixes long scheduling latencies in the ext3 code, and
it also cleans up the existing lock-break functionality to use the new
primitives.
This patch has been in the -VP patchset for quite some time.
Ingo
[-- Attachment #2: fix-latency-ext3.patch --]
[-- Type: text/plain, Size: 5447 bytes --]
the attached patch fixes long scheduling latencies in the ext3 code, and
it also cleans up the existing lock-break functionality to use the new
primitives.
This patch has been in the -VP patchset for quite some time.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
--- linux/fs/jbd/checkpoint.c.orig
+++ linux/fs/jbd/checkpoint.c
@@ -333,6 +333,10 @@ int log_do_checkpoint(journal_t *journal
break;
}
retry = __flush_buffer(journal, jh, bhs, &batch_count, &drop_count);
+ if (cond_resched_lock(&journal->j_list_lock)) {
+ retry = 1;
+ break;
+ }
} while (jh != last_jh && !retry);
if (batch_count)
@@ -487,6 +491,14 @@ int __journal_clean_checkpoint_list(jour
/* Use trylock because of the ranknig */
if (jbd_trylock_bh_state(jh2bh(jh)))
ret += __try_to_free_cp_buf(jh);
+ /*
+ * This function only frees up some memory
+ * if possible so we dont have an obligation
+ * to finish processing. Bail out if preemption
+ * requested:
+ */
+ if (need_resched())
+ goto out;
} while (jh != last_jh);
}
} while (transaction != last_transaction);
--- linux/fs/jbd/commit.c.orig
+++ linux/fs/jbd/commit.c
@@ -262,7 +262,7 @@ write_out_data:
__journal_file_buffer(jh, commit_transaction,
BJ_Locked);
jbd_unlock_bh_state(bh);
- if (need_resched()) {
+ if (lock_need_resched(&journal->j_list_lock)) {
spin_unlock(&journal->j_list_lock);
goto write_out_data;
}
@@ -288,7 +288,7 @@ write_out_data:
jbd_unlock_bh_state(bh);
journal_remove_journal_head(bh);
put_bh(bh);
- if (need_resched()) {
+ if (lock_need_resched(&journal->j_list_lock)) {
spin_unlock(&journal->j_list_lock);
goto write_out_data;
}
@@ -333,11 +333,7 @@ write_out_data:
jbd_unlock_bh_state(bh);
}
put_bh(bh);
- if (need_resched()) {
- spin_unlock(&journal->j_list_lock);
- cond_resched();
- spin_lock(&journal->j_list_lock);
- }
+ cond_resched_lock(&journal->j_list_lock);
}
spin_unlock(&journal->j_list_lock);
@@ -545,6 +541,8 @@ wait_for_iobuf:
wait_on_buffer(bh);
goto wait_for_iobuf;
}
+ if (cond_resched())
+ goto wait_for_iobuf;
if (unlikely(!buffer_uptodate(bh)))
err = -EIO;
@@ -599,6 +597,8 @@ wait_for_iobuf:
wait_on_buffer(bh);
goto wait_for_ctlbuf;
}
+ if (cond_resched())
+ goto wait_for_ctlbuf;
if (unlikely(!buffer_uptodate(bh)))
err = -EIO;
@@ -719,6 +719,7 @@ skip_commit: /* The journal should be un
J_ASSERT(commit_transaction->t_shadow_list == NULL);
J_ASSERT(commit_transaction->t_log_list == NULL);
+restart_loop:
while (commit_transaction->t_forget) {
transaction_t *cp_transaction;
struct buffer_head *bh;
@@ -792,6 +793,8 @@ skip_commit: /* The journal should be un
release_buffer_page(bh);
}
spin_unlock(&journal->j_list_lock);
+ if (cond_resched())
+ goto restart_loop;
}
/* Done with this transaction! */
--- linux/fs/jbd/recovery.c.orig
+++ linux/fs/jbd/recovery.c
@@ -354,6 +354,8 @@ static int do_one_pass(journal_t *journa
struct buffer_head * obh;
struct buffer_head * nbh;
+ cond_resched(); /* We're under lock_kernel() */
+
/* If we already know where to stop the log traversal,
* check right now that we haven't gone past the end of
* the log. */
--- linux/fs/ext3/ialloc.c.orig
+++ linux/fs/ext3/ialloc.c
@@ -733,6 +733,7 @@ unsigned long ext3_count_free_inodes (st
if (!gdp)
continue;
desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
+ cond_resched();
}
return desc_count;
#endif
--- linux/fs/ext3/namei.c.orig
+++ linux/fs/ext3/namei.c
@@ -674,6 +674,7 @@ static int dx_make_map (struct ext3_dir_
map_tail->hash = h.hash;
map_tail->offs = (u32) ((char *) de - base);
count++;
+ cond_resched();
}
/* XXX: do we need to check rec_len == 0 case? -Chris */
de = (struct ext3_dir_entry_2 *) ((char *) de + le16_to_cpu(de->rec_len));
--- linux/fs/ext3/super.c.orig
+++ linux/fs/ext3/super.c
@@ -1231,6 +1231,8 @@ static int ext3_fill_super (struct super
sbi->s_resuid = EXT3_DEF_RESUID;
sbi->s_resgid = EXT3_DEF_RESGID;
+ unlock_kernel();
+
blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE);
if (!blocksize) {
printk(KERN_ERR "EXT3-fs: unable to set blocksize\n");
@@ -1576,6 +1578,7 @@ static int ext3_fill_super (struct super
percpu_counter_mod(&sbi->s_dirs_counter,
ext3_count_dirs(sb));
+ lock_kernel();
return 0;
failed_mount3:
@@ -1597,6 +1600,7 @@ failed_mount:
out_fail:
sb->s_fs_info = NULL;
kfree(sbi);
+ lock_kernel();
return -EINVAL;
}
@@ -2113,9 +2117,11 @@ int ext3_statfs (struct super_block * sb
* block group descriptors. If the sparse superblocks
* feature is turned on, then not all groups have this.
*/
- for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++)
+ for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
overhead += ext3_bg_has_super(sb, i) +
ext3_bg_num_gdb(sb, i);
+ cond_resched();
+ }
/*
* Every block group has an inode bitmap, a block
--- linux/fs/ext3/balloc.c.orig
+++ linux/fs/ext3/balloc.c
@@ -207,6 +207,11 @@ do_more:
}
jbd_lock_bh_state(bitmap_bh);
#endif
+ if (need_resched()) {
+ jbd_unlock_bh_state(bitmap_bh);
+ cond_resched();
+ jbd_lock_bh_state(bitmap_bh);
+ }
/* @@@ This prevents newly-allocated data from being
* freed and then reallocated within the same
* transaction.
next prev parent reply other threads:[~2004-09-14 10:07 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-14 9:15 [patch] preempt-cleanup.patch, 2.6.9-rc2 Ingo Molnar
2004-09-14 9:34 ` [printk] make console_conditional_schedule() __sched and use cond_resched() William Lee Irwin III
2004-09-14 9:38 ` [patch] preempt-lock-need-resched.patch, 2.6.9-rc2 Ingo Molnar
2004-09-14 9:51 ` [patch] sched: add cond_resched_softirq() Ingo Molnar
2004-09-14 9:57 ` [patch] sched: fix latency in random driver Ingo Molnar
2004-09-14 10:06 ` Ingo Molnar [this message]
2004-09-14 10:13 ` [patch] sched, vfs: fix scheduling latencies in invalidate_inodes() Ingo Molnar
2004-09-14 10:19 ` [patch] sched, vfs: fix scheduling latencies in prune_dcache() and select_parent() Ingo Molnar
2004-09-14 10:25 ` [patch] sched, net: fix scheduling latencies in netstat Ingo Molnar
2004-09-14 10:44 ` [patch] sched, net: fix scheduling latencies in __release_sock Ingo Molnar
2004-09-14 10:50 ` [patch] sched, mm: fix scheduling latencies in copy_page_range() Ingo Molnar
2004-09-14 10:56 ` [patch] sched, mm: fix scheduling latencies in unmap_vmas() Ingo Molnar
2004-09-14 10:59 ` [patch] sched, mm: fix scheduling latencies in get_user_pages() Ingo Molnar
2004-09-14 11:02 ` [patch] sched, mm: fix scheduling latencies in filemap_sync() Ingo Molnar
2004-09-14 11:06 ` [patch] sched, tty: fix scheduling latencies in tty_io.c Ingo Molnar
2004-09-14 10:53 ` Alan Cox
2004-09-14 12:00 ` Ingo Molnar
2004-09-14 11:18 ` Alan Cox
2004-09-14 12:27 ` Ingo Molnar
2004-09-14 12:11 ` Alan Cox
2004-09-14 11:08 ` [patch] sched, pty: fix scheduling latencies in pty.c Ingo Molnar
2004-09-14 11:12 ` [patch] might_sleep() additions to fs-writeback.c Ingo Molnar
2004-09-14 11:25 ` [patch] fix keventd execution dependency Ingo Molnar
2004-09-15 22:18 ` Rusty Russell
2004-09-14 11:28 ` [patch] sched: fix scheduling latencies in mttr.c Ingo Molnar
2004-09-14 11:32 ` [patch] sched: fix scheduling latencies in vgacon.c Ingo Molnar
2004-09-14 11:35 ` [patch] sched: fix scheduling latencies in NTFS mount Ingo Molnar
2004-09-14 13:31 ` Anton Altaparmakov
2004-09-14 11:42 ` [patch] sched: fix scheduling latencies for !PREEMPT kernels Ingo Molnar
2004-09-14 12:55 ` Nick Piggin
2004-09-14 13:22 ` Ingo Molnar
2004-09-14 13:33 ` Nick Piggin
2004-09-14 14:09 ` Andrea Arcangeli
2004-09-14 14:28 ` Nick Piggin
2004-09-14 15:03 ` Andrea Arcangeli
2004-09-14 18:05 ` Robert Love
2004-09-14 18:52 ` William Lee Irwin III
2004-09-14 19:02 ` Robert Love
2004-09-14 19:21 ` William Lee Irwin III
2004-09-14 19:19 ` Alan Cox
2004-09-15 0:22 ` Lee Revell
2004-09-15 1:46 ` William Lee Irwin III
2004-09-15 2:00 ` Lee Revell
2004-09-15 2:36 ` William Lee Irwin III
2004-09-15 2:59 ` Lee Revell
2004-09-15 13:36 ` Hans Reiser
2004-09-15 20:40 ` William Lee Irwin III
2004-09-15 1:18 ` William Lee Irwin III
2004-09-14 19:26 ` Robert Love
2004-09-14 21:06 ` William Lee Irwin III
2004-09-14 19:25 ` Andrea Arcangeli
2004-09-14 19:29 ` Robert Love
2004-09-14 19:34 ` William Lee Irwin III
2004-09-15 1:02 ` Lee Revell
2004-09-15 1:39 ` William Lee Irwin III
2004-09-15 2:11 ` Lee Revell
2004-09-15 11:17 ` Ingo Molnar
2004-09-15 9:56 ` Ingo Molnar
2004-09-15 9:57 ` William Lee Irwin III
2004-09-15 10:12 ` Ingo Molnar
2004-09-14 16:31 ` William Lee Irwin III
2004-09-14 16:39 ` Andrea Arcangeli
2004-09-14 14:54 ` Ingo Molnar
2004-09-14 22:55 ` Nick Piggin
2004-09-15 6:19 ` Ingo Molnar
2004-09-15 8:23 ` Nick Piggin
2004-09-15 8:43 ` Ingo Molnar
2004-09-15 10:09 ` William Lee Irwin III
2004-09-15 10:21 ` Ingo Molnar
2004-09-16 1:03 ` Nick Piggin
2004-09-16 6:14 ` Ingo Molnar
2004-09-15 0:35 ` Lee Revell
2004-09-14 13:25 ` [patch] sched: fix scheduling latencies in mtrr.c Ingo Molnar
2004-09-14 13:15 ` Alan Cox
2004-09-14 15:00 ` Ingo Molnar
2004-09-14 18:22 ` Zwane Mwaikambo
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=20040914100652.GB24622@elte.hu \
--to=mingo@elte.hu \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sct@redhat.com \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/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
all inboxes | Powered by JetHome®