*** SUBJECT HERE ***
Subsystems (3)
Theodore Ts'o
maintainercover *** SUBJECT HERE ***
The first patch in this patch series hasn't changed since when I had last posted it, but I'm including it again for the benefit of the folks on ocfs2-dev.
Thanks to some work done by Eric Whitney, when he accidentally ran the command "mkfs.ext4 -t xfs", and created a ext4 file system without a journal, it appears that main scalability bottleneck for ext4 is in the jbd2 layer. In fact, his testing on a 48-core system shows that on some workloads, ext4 is roughly comparable with XFS!
The lockstat results indicate that the main bottlenecks are in the j_state_lock and t_handle_lock, especially in start_this_handle() in fs/jbd2/transaction.c. A previous patch, which removed an unneeded grabbing of j_state_lock jbd2_journal_stop() relieved pressure on that lock and was noted to make a significant difference for dbench on a kernel with CONFIG_PREEMPT_RT enabled, as well as on a 48-core AMD
system from HP. This patch is already in 2.6.35, and the benchmark
results can be found here: http://free.linux.hp.com/~enw/ext4/2.6.34/
This patch series removes all exclusive spinlocks when starting and stopping jbd2 handles, which should improve things even more. Since OCFS2 uses the jbd2 layer, and the second patch in this patch series touches ocfs2 a wee bit, I'd appreciate it if you could take a look and let me know what you think. Hopefully, this should also improve OCFS2's scalability.
Best regards,
- Ted
Theodore Ts'o (3):
jbd2: Use atomic variables to avoid taking t_handle_lock in
jbd2_journal_stop
jbd2: Change j_state_lock to be a rwlock_t
jbd2: Remove t_handle_lock from start_this_handle()
fs/ext4/inode.c | 4 +- fs/ext4/super.c | 4 +- fs/jbd2/checkpoint.c | 18 +++--- fs/jbd2/commit.c | 42 +++++++------- fs/jbd2/journal.c | 94 +++++++++++++++---------------- fs/jbd2/transaction.c | 149 ++++++++++++++++++++++++++++--------------------- fs/ocfs2/journal.c | 4 +- include/linux/jbd2.h | 12 ++-- 8 files changed, 174 insertions(+), 153 deletions(-)
Theodore Ts'o
maintainerRFC PATCH 1/3 jbd2: Use atomic variables to avoid taking t_handle_lock in jbd2_journal_stop
By using an atomic_t for t_updates and t_outstanding credits, this should allow us to not need to take transaction t_handle_lock in jbd2_journal_stop().
--- fs/jbd2/checkpoint.c | 2 +- fs/jbd2/commit.c | 13 +++++---- fs/jbd2/transaction.c | 69 +++++++++++++++++++++++++++--------------------- include/linux/jbd2.h | 8 +++--- 4 files changed, 51 insertions(+), 41 deletions(-)
fs/jbd2/checkpoint.c +1 -1
@@ -775,7 +775,7 @@ void __jbd2_journal_drop_transaction(journal_t *journal, transaction_t *transactJ_ASSERT (transaction->t_log_list ==NULL );J_ASSERT (transaction->t_checkpoint_list ==NULL );J_ASSERT (transaction->t_checkpoint_io_list ==NULL ); -J_ASSERT (transaction->t_updates ==0 ); +J_ASSERT (atomic_read (&transaction->t_updates) ==0 );J_ASSERT (journal->j_committing_transaction != transaction);J_ASSERT (journal->j_running_transaction != transaction);
fs/jbd2/commit.c +7 -6
@@ -417,12 +417,12 @@ void jbd2_journal_commit_transaction(journal_t *journal) stats.run.rs_locked);spin_lock (&commit_transaction->t_handle_lock); -while (commit_transaction->t_updates) { +while (atomic_read (&commit_transaction->t_updates)) {DEFINE_WAIT (wait);prepare_to_wait (&journal->j_wait_updates, &wait,TASK_UNINTERRUPTIBLE ); -if (commit_transaction->t_updates) { +if (atomic_read (&commit_transaction->t_updates)) {spin_unlock (&commit_transaction->t_handle_lock);spin_unlock (&journal->j_state_lock);schedule ();
@@ -433,7 +433,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) }spin_unlock (&commit_transaction->t_handle_lock); -J_ASSERT (commit_transaction->t_outstanding_credits <= +J_ASSERT (atomic_read (&commit_transaction->t_outstanding_credits) <= journal->j_max_transaction_buffers);/*
@@ -527,11 +527,12 @@ void jbd2_journal_commit_transaction(journal_t *journal) stats.run.rs_logging = jiffies; stats.run.rs_flushing =jbd2_time_diff (stats.run.rs_flushing, stats.run.rs_logging); - stats.run.rs_blocks = commit_transaction->t_outstanding_credits; + stats.run.rs_blocks = +atomic_read (&commit_transaction->t_outstanding_credits); stats.run.rs_blocks_logged =0 ;J_ASSERT (commit_transaction->t_nr_buffers <= - commit_transaction->t_outstanding_credits); +atomic_read (&commit_transaction->t_outstanding_credits)); err =0 ; descriptor =NULL ;
@@ -616,7 +617,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)* the free space in the log, but this counter is changed * by jbd2_journal_next_log_block() also. */ - commit_transaction->t_outstanding_credits--; +atomic_dec (&commit_transaction->t_outstanding_credits);/* Bump b_count to prevent truncate from stumbling over the shadowed buffer! @@@ This can go if we ever get
fs/jbd2/transaction.c +39 -30
153 lines not on this page · raw message
include/linux/jbd2.h +4 -4
@@ -601,13 +601,13 @@ struct transaction_s* Number of outstanding updates running on this transaction * [t_handle_lock] */ -int t_updates; +atomic_t t_updates;/* * Number of buffers reserved for use by all handles in this transaction * handle but not yet modified. [t_handle_lock] */ -int t_outstanding_credits; +atomic_t t_outstanding_credits;/* * Forward and backward links for the circular list of all transactions
@@ -1258,8 +1258,8 @@ static inline int jbd_space_needed(journal_t *journal) {int nblocks = journal->j_max_transaction_buffers;if (journal->j_committing_transaction) - nblocks += journal->j_committing_transaction-> - t_outstanding_credits; + nblocks +=atomic_read (&journal->j_committing_transaction-> + t_outstanding_credits);return nblocks; }
Signature · 1 line
1.7.0.4
Theodore Ts'o
maintainerRFC PATCH 2/3 jbd2: Change j_state_lock to be a rwlock_t
In reply to Theodore Ts'oLockstat reports have shown that j_state_lock is a major source of lock contention, especially on systems with more than 4 CPU cores. So change it to be a read/write spinlock.
--- fs/ext4/inode.c | 4 +- fs/ext4/super.c | 4 +- fs/jbd2/checkpoint.c | 16 ++++---- fs/jbd2/commit.c | 26 +++++++------- fs/jbd2/journal.c | 94 ++++++++++++++++++++++++------------------------- fs/jbd2/transaction.c | 52 +++++++++++++------------- fs/ocfs2/journal.c | 4 +- include/linux/jbd2.h | 2 +- 8 files changed, 100 insertions(+), 102 deletions(-)
fs/ext4/inode.c +2 -2
@@ -5066,7 +5066,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)transaction_t *transaction;tid_t tid; -spin_lock (&journal->j_state_lock); +read_lock (&journal->j_state_lock);if (journal->j_running_transaction) transaction = journal->j_running_transaction;else
@@ -5075,7 +5075,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) tid = transaction->t_tid; else tid = journal->j_commit_sequence; -spin_unlock (&journal->j_state_lock); +read_unlock (&journal->j_state_lock); ei->i_sync_tid = tid; ei->i_datasync_tid = tid; }
fs/ext4/super.c +2 -2
@@ -3232,7 +3232,7 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) journal->j_min_batch_time = sbi->s_min_batch_time; journal->j_max_batch_time = sbi->s_max_batch_time; -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock);if (test_opt (sb,BARRIER )) journal->j_flags |=JBD2_BARRIER ;else
@@ -3241,7 +3241,7 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) journal->j_flags |=JBD2_ABORT_ON_SYNCDATA_ERR ; else journal->j_flags &= ~JBD2_ABORT_ON_SYNCDATA_ERR; -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock); } static journal_t *ext4_get_journal(struct super_block *sb,
fs/jbd2/checkpoint.c +8 -8
@@ -118,13 +118,13 @@ static int __try_to_free_cp_buf(struct journal_head *jh)void __jbd2_log_wait_for_space (journal_t *journal) {int nblocks, space_left; -assert_spin_locked (&journal->j_state_lock); +/* assert_spin_locked(&journal->j_state_lock); */ nblocks =jbd_space_needed (journal);while (__jbd2_log_space_left (journal) < nblocks) {if (journal->j_flags &JBD2_ABORT )return ; -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock);mutex_lock (&journal->j_checkpoint_mutex);/*
@@ -138,7 +138,7 @@ void __jbd2_log_wait_for_space(journal_t *journal)* filesystem, so abort the journal and leave a stack * trace for forensic evidence. */ -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock);spin_lock (&journal->j_list_lock); nblocks =jbd_space_needed (journal); space_left =__jbd2_log_space_left (journal);
@@ -149,7 +149,7 @@ void __jbd2_log_wait_for_space(journal_t *journal)if (journal->j_committing_transaction) tid = journal->j_committing_transaction->t_tid;spin_unlock (&journal->j_list_lock); -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock);if (chkpt) {jbd2_log_do_checkpoint (journal); }else if (jbd2_cleanup_journal_tail (journal) ==0 ) {
@@ -167,7 +167,7 @@ void __jbd2_log_wait_for_space(journal_t *journal)WARN_ON (1 );jbd2_journal_abort (journal,0 ); } -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock); }else {spin_unlock (&journal->j_list_lock); }
@@ -474,7 +474,7 @@ int jbd2_cleanup_journal_tail(journal_t *journal)* next transaction ID we will write, and where it will * start. */ -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock);spin_lock (&journal->j_list_lock); transaction = journal->j_checkpoint_transactions;if (transaction) {
@@ -496,7 +496,7 @@ int jbd2_cleanup_journal_tail(journal_t *journal)/* If the oldest pinned transaction is at the tail of the log already then there's not much we can do right now. */ if (journal->j_tail_sequence == first_tid) { -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock);return 1 ; }
@@ -516,7 +516,7 @@ int jbd2_cleanup_journal_tail(journal_t *journal) journal->j_free += freed; journal->j_tail_sequence = first_tid; journal->j_tail = blocknr; -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock);/* * If there is an external journal, we need to make sure that
fs/jbd2/commit.c +13 -13
@@ -152,9 +152,9 @@ static int journal_submit_commit_record(journal_t *journal,printk (KERN_WARNING "JBD2: Disabling barriers on %s, " "not supported by device\n" , journal->j_devname); -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock); journal->j_flags &= ~JBD2_BARRIER ; -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock);/* And try again, without the barrier */ lock_buffer (bh);
@@ -182,9 +182,9 @@ retry:printk (KERN_WARNING "JBD2: %s: disabling barries on %s - not supported " "by device\n" , __func__, journal->j_devname); -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock); journal->j_flags &= ~JBD2_BARRIER ; -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock);lock_buffer (bh);clear_buffer_dirty (bh);
@@ -400,7 +400,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)jbd_debug (1 ,"JBD: starting commit of transaction %d\n" , commit_transaction->t_tid); -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock); commit_transaction->t_state =T_LOCKED ;/*
@@ -424,9 +424,9 @@ void jbd2_journal_commit_transaction(journal_t *journal) TASK_UNINTERRUPTIBLE);if (atomic_read (&commit_transaction->t_updates)) {spin_unlock (&commit_transaction->t_handle_lock); -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock);schedule (); -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock);spin_lock (&commit_transaction->t_handle_lock); }finish_wait (&journal->j_wait_updates, &wait);
@@ -497,7 +497,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) start_time =ktime_get (); commit_transaction->t_log_start = journal->j_head;wake_up (&journal->j_wait_transaction_locked); -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock);jbd_debug (3 ,"JBD: commit phase 2\n" );
@@ -519,9 +519,9 @@ void jbd2_journal_commit_transaction(journal_t *journal)* transaction! Now comes the tricky part: we need to write out * metadata. Loop over the transaction's entire buffer list: */ -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock); commit_transaction->t_state =T_COMMIT ; -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock);trace_jbd2_commit_logging (journal, commit_transaction); stats.run.rs_logging = jiffies;
@@ -978,7 +978,7 @@ restart_loop:* __jbd2_journal_drop_transaction(). Otherwise we could race with * other checkpointing code processing the transaction... */ -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock);spin_lock (&journal->j_list_lock);/* * Now recheck if some buffers did not get attached to the transaction
@@ -986,7 +986,7 @@ restart_loop:*/ if (commit_transaction->t_forget) {spin_unlock (&journal->j_list_lock); -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock); goto restart_loop; }
@@ -1038,7 +1038,7 @@ restart_loop: journal->j_average_commit_time*3) / 4; else journal->j_average_commit_time = commit_time; -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock);if (commit_transaction->t_checkpoint_list ==NULL && commit_transaction->t_checkpoint_io_list ==NULL ) {
fs/jbd2/journal.c +46 -48
308 lines not on this page · raw message
fs/jbd2/transaction.c +26 -26
181 lines not on this page · raw message
fs/ocfs2/journal.c +2 -2
@@ -760,13 +760,13 @@ void ocfs2_set_journal_params(struct ocfs2_super *osb)if (osb->osb_commit_interval) commit_interval = osb->osb_commit_interval; -spin_lock (&journal->j_state_lock); +write_lock (&journal->j_state_lock); journal->j_commit_interval = commit_interval;if (osb->s_mount_opt &OCFS2_MOUNT_BARRIER ) journal->j_flags |=JBD2_BARRIER ;else journal->j_flags &= ~JBD2_BARRIER ; -spin_unlock (&journal->j_state_lock); +write_unlock (&journal->j_state_lock); }int ocfs2_journal_init (struct ocfs2_journal *journal,int *dirty)
include/linux/jbd2.h +1 -1
@@ -764,7 +764,7 @@ struct journal_s/* * Protect the various scalars in the journal */ -spinlock_t j_state_lock; +rwlock_t j_state_lock;/* * Number of processes waiting to create a barrier lock [j_state_lock]
Signature · 1 line
1.7.0.4
Theodore Ts'o
maintainerRFC PATCH 3/3 jbd2: Remove t_handle_lock from start_this_handle()
In reply to Theodore Ts'oThis should remove the last exclusive lock from start_this_handle(), so that we should now be able to start multiple transactions at the same time on large SMP systems.
--- fs/jbd2/commit.c | 3 ++- fs/jbd2/transaction.c | 32 ++++++++++++++++++++++---------- include/linux/jbd2.h | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-)
fs/jbd2/commit.c +2 -1
@@ -1004,7 +1004,8 @@ restart_loop:* File the transaction statistics */ stats.ts_tid = commit_transaction->t_tid; - stats.run.rs_handle_count = commit_transaction->t_handle_count; + stats.run.rs_handle_count = +atomic_read (&commit_transaction->t_handle_count);trace_jbd2_run_stats (journal->j_fs_dev->bd_dev, commit_transaction->t_tid, &stats.run);
fs/jbd2/transaction.c +22 -10
@@ -57,6 +57,7 @@ jbd2_get_transaction(journal_t *journal, transaction_t *transaction)spin_lock_init (&transaction->t_handle_lock);atomic_set (&transaction->t_updates,0 );atomic_set (&transaction->t_outstanding_credits,0 ); +atomic_set (&transaction->t_handle_count,0 );INIT_LIST_HEAD (&transaction->t_inode_list);INIT_LIST_HEAD (&transaction->t_private_list);
@@ -178,8 +179,8 @@ repeat_locked:* buffers requested by this operation, we need to stall pending a log * checkpoint to free some more log space. */ -spin_lock (&transaction->t_handle_lock); - needed =atomic_read (&transaction->t_outstanding_credits) + nblocks; + needed =atomic_add_return (nblocks, + &transaction->t_outstanding_credits);if (needed > journal->j_max_transaction_buffers) {/*
@@ -190,7 +191,7 @@ repeat_locked:DEFINE_WAIT (wait);jbd_debug (2 ,"Handle %p starting new commit...\n" , handle); -spin_unlock (&transaction->t_handle_lock); +atomic_sub (nblocks, &transaction->t_outstanding_credits);prepare_to_wait (&journal->j_wait_transaction_locked, &wait,TASK_UNINTERRUPTIBLE );__jbd2_log_start_commit (journal, transaction->t_tid);
@@ -227,29 +228,40 @@ repeat_locked:*/ if (__jbd2_log_space_left (journal) <jbd_space_needed (journal)) {jbd_debug (2 ,"Handle %p waiting for checkpoint...\n" , handle); -spin_unlock (&transaction->t_handle_lock); +atomic_sub (nblocks, &transaction->t_outstanding_credits);__jbd2_log_wait_for_space (journal); goto repeat_locked; }/* OK, account for the buffers that this operation expects to -* use and add the handle to the running transaction. */ - -if (time_after (transaction->t_start, ts)) { +* use and add the handle to the running transaction. +* +* In order for t_max_wait to be reliable, it must be +* protected by a lock. But doing so will mean that +* start_this_handle() can not be run in parallel on SMP +* systems, which limits our scalability. So we only enable +* it when debugging is enabled. We may want to use a +* separate flag, eventually, so we can enable this +* independently of debugging. +*/ +#ifdef CONFIG_JBD2_DEBUG +if (jbd2_journal_enable_debug && +time_after (transaction->t_start, ts)) { ts =jbd2_time_diff (ts, transaction->t_start); +spin_lock (&transaction->t_handle_lock);if (ts > transaction->t_max_wait) transaction->t_max_wait = ts; +spin_unlock (&transaction->t_handle_lock); } +#endif handle->h_transaction = transaction; -atomic_add (nblocks, &transaction->t_outstanding_credits);atomic_inc (&transaction->t_updates); - transaction->t_handle_count++; +atomic_inc (&transaction->t_handle_count);jbd_debug (4 ,"Handle %p given %d credits (total %d, free %d)\n" , handle, nblocks,atomic_read (&transaction->t_outstanding_credits),__jbd2_log_space_left (journal)); -spin_unlock (&transaction->t_handle_lock);read_unlock (&journal->j_state_lock);lock_map_acquire (&handle->h_lockdep_map);
include/linux/jbd2.h +1 -1
@@ -629,7 +629,7 @@ struct transaction_s/* * How many handles used this transaction? [t_handle_lock] */ -int t_handle_count; +atomic_t t_handle_count;/* * This transaction is being forced and some process is
Signature · 1 line
1.7.0.4
Quoted 3 lines · Theodore Ts'o
The first patch in this patch series hasn't changed since when I had last posted it, but I'm including it again for the benefit of the folks on ocfs2-dev.
Thanks!
Quoted 4 lines
Thanks to some work done by Eric Whitney, when he accidentally ran the command "mkfs.ext4 -t xfs", and created a ext4 file system without a journal, it appears that main scalability bottleneck for ext4 is in the jbd2 layer.
I'm certain, as you've surmised, that a lot of this affects
ocfs2 as well. jbd2 improvements make both filesystems better.
Quoted 6 lines
This patch series removes all exclusive spinlocks when starting and stopping jbd2 handles, which should improve things even more. Since OCFS2 uses the jbd2 layer, and the second patch in this patch series touches ocfs2 a wee bit, I'd appreciate it if you could take a look and let me know what you think. Hopefully, this should also improve OCFS2's scalability.
The atomic changes make absolute sense. Ack on them. I had two
reactions to the rwlock: first, a lot of your rwlock changes are on the write_lock() side. You get journal start/stop parallelized, but what about all the underlying access/dirty/commit paths? Second, rwlocks are known to behave worse than spinlocks when they ping the cache line across CPUs.
That said, I have a hunch that you've tested both of the above
concerns. You mention 48 core systems, and clearly if cachelines were going to be a problem, you would have noticed. So if the rwlock changes are faster on 48 core than the spinlocks, I say ack ack ack.
From the ocfs2 perspective, the code is perfectly safe, and any
speedup you see on ext4 ought to be mirrored on ocfs2.
Joel
Signature · 10 lines
A good programming language should have features that make the kind of people who use the phrase "software engineering" shake their heads disapprovingly. - Paul Graham Joel Becker Consulting Software Developer Oracle E-mail: joel.becker at oracle.com Phone: (650) 506-8127
Ted Ts'o
maintainerQuoted 11 lines · Joel Becker
The atomic changes make absolute sense. Ack on them. I had two
reactions to the rwlock: first, a lot of your rwlock changes are on thewrite_lock()side. You get journal start/stop parallelized, but what about all the underlying access/dirty/commit paths? Second, rwlocks are known to behave worse than spinlocks when they ping the cache line across CPUs.
That said, I have a hunch that you've tested both of the above
concerns. You mention 48 core systems, and clearly if cachelines were going to be a problem, you would have noticed. So if the rwlock changes are faster on 48 core than the spinlocks, I say ack ack ack.
We don't have the results from the 48-core machine yet. I was going to try to get measurements from the 48-core machine I have access to at $WORK, but it doesn't have enough hard drive spindles on it. :-(
But yes, I am worried about the cache-line bounce issue, and I'm hoping that we'll get some input from people who can run some measurements on an 8-core and 48-core machine.
I haven't worried about the commit paths yet because they haven't shown up as being significant on any of the lockstat reports. Remember that with jbd2, the commit code only runs on in kjournald, and in general only once every 5 seconds or for every fsync. In contrast, essentially every single file system syscall that modifies the filesystem is going to end up calling start_this_handle(). So if you have multiple threads all creating files, or writing to files, or even just changing the mtime or permissions, it's going to call start_this_handle(), so we're seeing nearly all of the contention on start_this_handle() and to a lesser extent, jbd2_journal_stop(), the function which retires a handle.
Things would probably be different on a workload that tries to simulate a mail transfer agent or a database which is _not_ using O_DIRECT on a preallocated table space file, since there will be many more fsync() calls and thus much more pressure on the commit code. But I didn't want to do any premature optimization until we see how bad it actually gets in those cases.
If you are set up to do some performance measurements on OCFS2, I'd appreciate if you could give it a try and let me know how the patches fare on OCFS2.
Thanks,
- Ted
Quoted 3 lines · Ted Ts'o
If you are set up to do some performance measurements on OCFS2, I'd appreciate if you could give it a try and let me know how the patches fare on OCFS2.
We're lining up a 16-way box here. Do you have a happy dbench
command line or similar that you would like to see run?
Joel
Signature · 10 lines
You can use a screwdriver to screw in screws or to clean your ears, however, the latter needs real skill, determination and a lack of fear of injuring yourself. It is much the same with JavaScript. - Chris Heilmann Joel Becker Consulting Software Developer Oracle E-mail: joel.becker at oracle.com Phone: (650) 506-8127
Ted Ts'o
maintainerQuoted 7 lines · Joel Becker
Quoted 3 lines · Ted Ts'o
If you are set up to do some performance measurements on OCFS2, I'd appreciate if you could give it a try and let me know how the patches fare on OCFS2.
We're lining up a 16-way box here. Do you have a happy dbench
command line or similar that you would like to see run?
The problem with dbench is that the core VFS can end up being the bottleneck. OTOH, it's very easy to run. What would be great if you could try using the Flexible File System Benchmark (FFSB), which is what Eric and Steve used:
http://free.linux.hp.com/~enw/ext4/2.6.34/ http://btrfs.boxacle.net/
It's a bit more work to set it up, though.
- Ted
Ted Ts'o
maintainerRe: [PATCH, RFC 2/3] jbd2: Change j_state_lock to be a rwlock_t
In reply to Theodore Ts'oQuoted 5 lines · Theodore Ts'o
Lockstat reports have shown that
j_state_lockis a major source of lock contention, especially on systems with more than 4 CPU cores. So change it to be a read/write spinlock.Signed-off-by "Theodore Ts'o" <[email protected]>
Oops, this patch can result in a BUG_ON in fs/jbd2/transaction.c. I'm currently testing a fix/replacement patch, but I figured I send a quick warning to folks not to waste time trying this out just yet. I should hopefully have a new, better-tested patch in by tomorrow morning.
- Ted
Re: [PATCH, RFC 0/3] *** SUBJECT HERE *** (ext4 scalability patches)
In reply to Theodore Ts'oQuoted 36 lines · Theodore Ts'o
The first patch in this patch series hasn't changed since when I had last posted it, but I'm including it again for the benefit of the folks on ocfs2-dev.
Thanks to some work done by Eric Whitney, when he accidentally ran the command "mkfs.ext4 -t xfs", and created a ext4 file system without a journal, it appears that main scalability bottleneck for ext4 is in the jbd2 layer. In fact, his testing on a 48-core system shows that on some workloads, ext4 is roughly comparable with XFS!
The lockstat results indicate that the main bottlenecks are in the
j_state_lockandt_handle_lock, especially instart_this_handle()infs/jbd2/transaction.c. A previous patch, which removed an unneeded grabbing ofj_state_lockjbd2_journal_stop()relieved pressure on that lock and was noted to make a significant difference for dbench on a kernel withCONFIG_PREEMPT_RTenabled, as well as on a 48-core AMD
system from HP. This patch is already in 2.6.35, and the benchmark
results can be found here: http://free.linux.hp.com/~enw/ext4/2.6.34/This patch series removes all exclusive spinlocks when starting and stopping jbd2 handles, which should improve things even more. Since OCFS2 uses the jbd2 layer, and the second patch in this patch series touches ocfs2 a wee bit, I'd appreciate it if you could take a look and let me know what you think. Hopefully, this should also improve OCFS2's scalability.
Best regards,
- Ted
Theodore Ts'o (3):
jbd2: Use atomic variables to avoid takingt_handle_lockin
jbd2_journal_stop
jbd2: Changej_state_lockto be arwlock_t
jbd2: Removet_handle_lockfromstart_this_handle()
Quoted 10 lines
fs/ext4/inode.c | 4 +- fs/ext4/super.c | 4 +- fs/jbd2/checkpoint.c | 18 +++--- fs/jbd2/commit.c | 42 +++++++------- fs/jbd2/journal.c | 94 +++++++++++++++---------------- fs/jbd2/transaction.c | 149 ++++++++++++++++++++++++++++--------------------- fs/ocfs2/journal.c | 4 +- include/linux/jbd2.h | 12 ++-- 8 files changed, 174 insertions(+), 153 deletions(-)
My 48 core test results for these patches as applied to 2.6.35 can be found at:
http://free.linux.hp.com/~enw/ext4/2.6.35
Both the Boxacle large_file_creates and random_writes workloads improved significantly and consistently with these patches, and apparently in the single threaded case as well as at increased scale.
The graphs at the URL show one instance of several runs I made to establish repeatability.
I've also taken unmodified 2.6.35 ext4, ext4 without a journal, and xfs data for comparison. In addition, I've collected lock stats and more detailed performance data for reference.
Thanks, Ted!
Eric
Ted Ts'o
maintainerRe: [PATCH, RFC 0/3] *** SUBJECT HERE *** (ext4 scalability patches)
Quoted 10 lines · Eric Whitney
My 48 core test results for these patches as applied to 2.6.35 can be found at:
http://free.linux.hp.com/~enw/ext4/2.6.35
Both the Boxacle
large_file_createsandrandom_writesworkloads improved significantly and consistently with these patches, and apparently in the single threaded case as well as at increased scale.
Thanks for doing these runs! I very much appreciate it --- it's really helped to validate these patches. Looking at your results, the two things which stand out to me is that we've now reached parity with XFS on the random write workload on the 48 and 192 core runs. On the large file creates workload, looking at the lockstats report, it looks like the next big thing we need to work on is to rework the ext4_da_writepages() function.
The problem is one that's known to me for a while; we carefully spend a bunch of CPU time walking the page structures so we have a contiguous extent of dirty pages that need to written out --- and then we turn around and submit each page 4k at a time. This is causing a huge amount of pressure on the block device queue's rlock. That's almost certainly responsible for the increased CPU utilization that we see in both the large file create workload and random writes workload as compared to XFS.
So that's clearly the next thing we need to tackle, and which should further increase ext4's scalability.
- Ted