I've made a similar setup, 2s8c machine, but using 2GB ramdisk instead
of a real disk (I don't have easy access to a good disk setup ATM, but
I guess we're more interested in code above the block layer anyway).
Made an XFS on /dev/ram0 with 16 ags, 64MB log, otherwise same config as
yours.
I found that performance is a little unstable, so I sync and echo 3 >
drop_caches between each run. When it starts reclaiming memory, things
get a bit more erratic (and XFS seemed to be almost livelocking for tens
of seconds in inode reclaim).
So about this XFS livelock type thingy. It looks like this, and happens
periodically while running the above fs_mark benchmark requiring reclaim
of inodes:
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
15 0 6900 31032 192 471852 0 0 28 183296 8520 46672 5 91 4 0
19 0 7044 22928 192 466712 96 144 1056 115586 8622 41695 3 96 1 0
19 0 7136 59884 192 471200 160 92 6768 34564 995 542 1 99 0 0
19 0 7244 17008 192 467860 0 104 2068 32953 1044 630 1 99 0 0
18 0 7244 43436 192 467324 0 0 12 0 817 405 0 100 0 0
18 0 7244 43684 192 467324 0 0 0 0 806 425 0 100 0 0
18 0 7244 43932 192 467324 0 0 0 0 808 403 0 100 0 0
18 0 7244 44924 192 467324 0 0 0 0 808 398 0 100 0 0
18 0 7244 45456 192 467324 0 0 0 0 809 409 0 100 0 0
18 0 7244 45472 192 467324 0 0 0 0 805 412 0 100 0 0
18 0 7244 46392 192 467324 0 0 0 0 807 401 0 100 0 0
18 0 7244 47012 192 467324 0 0 0 0 810 414 0 100 0 0
18 0 7244 47260 192 467324 0 0 0 0 806 396 0 100 0 0
18 0 7244 47752 192 467324 0 0 0 0 806 403 0 100 0 0
18 0 7244 48204 192 467324 0 0 0 0 810 409 0 100 0 0
18 0 7244 48608 192 467324 0 0 0 0 807 412 0 100 0 0
18 0 7244 48876 192 467324 0 0 0 0 805 406 0 100 0 0
18 0 7244 49000 192 467324 0 0 0 0 809 402 0 100 0 0
18 0 7244 49408 192 467324 0 0 0 0 807 396 0 100 0 0
18 0 7244 49908 192 467324 0 0 0 0 809 406 0 100 0 0
18 0 7244 50032 192 467324 0 0 0 0 805 404 0 100 0 0
18 0 7244 50032 192 467324 0 0 0 0 805 406 0 100 0 0
19 0 7244 73436 192 467324 0 0 0 6340 808 384 0 100 0 0
20 0 7244 490220 192 467324 0 0 0 8411 830 389 0 100 0 0
18 0 7244 620092 192 467324 0 0 0 4 809 435 0 100 0 0
18 0 7244 620344 192 467324 0 0 0 0 806 430 0 100 0 0
16 0 7244 682620 192 467324 0 0 44 80 890 326 0 100 0 0
12 0 7244 604464 192 479308 76 0 11716 73555 2242 14318 2 94 4 0
12 0 7244 556700 192 483488 0 0 4276 77680 6576 92285 1 97 2 0
17 0 7244 502508 192 485456 0 0 2092 98368 6308 91919 1 96 4 0
11 0 7244 416500 192 487116 0 0 1760 114844 7414 63025 2 96 2 0
Nothing much happening except 100% system time for seconds at a time
(length of time varies). This is on a ramdisk, so it isn't waiting
for IO.
During this time, lots of things are contending on the lock:
60.37% fs_mark [kernel.kallsyms] [k] __write_lock_failed
4.30% kswapd0 [kernel.kallsyms] [k] __write_lock_failed
3.70% fs_mark [kernel.kallsyms] [k] try_wait_for_completion
3.59% fs_mark [kernel.kallsyms] [k] _raw_write_lock
3.46% kswapd1 [kernel.kallsyms] [k] __write_lock_failed
|
--- __write_lock_failed
|
|--99.92%-- xfs_inode_ag_walk
| xfs_inode_ag_iterator
| xfs_reclaim_inode_shrink
| shrink_slab
| shrink_zone
| balance_pgdat
| kswapd
| kthread
| kernel_thread_helper
--0.08%-- [...]
3.02% fs_mark [kernel.kallsyms] [k] _raw_spin_lock
1.82% fs_mark [kernel.kallsyms] [k] _xfs_buf_find
1.16% fs_mark [kernel.kallsyms] [k] memcpy
0.86% fs_mark [kernel.kallsyms] [k] _raw_spin_lock_irqsave
0.75% fs_mark [kernel.kallsyms] [k] xfs_log_commit_cil
|
--- xfs_log_commit_cil
_xfs_trans_commit
|
|--60.00%-- xfs_remove
| xfs_vn_unlink
| vfs_unlink
| do_unlinkat
| sys_unlink
I'm not sure if there was a long-running read locker in there causing
all the write lockers to fail, or if they are just running into one
another. But anyway, I hacked the following patch which seemed to
improve that behaviour. I haven't run any throughput numbers on it yet,
but I could if you're interested (and it's not completely broken!)
Batch pag_ici_lock acquisition on the reclaim path, and also skip inodes
that appear to be busy to improve locking efficiency.
Index: source/fs/xfs/linux-2.6/xfs_sync.c
===================================================================
@@ -87,6 +87,91 @@ xfs_inode_ag_lookup(returnip;}+#define RECLAIM_BATCH_SIZE 32+STATICint+xfs_inode_ag_walk_reclaim(+structxfs_mount*mp,+structxfs_perag*pag,+int(*execute)(structxfs_inode*ip,+structxfs_perag*pag,intflags),+intflags,+inttag,+intexclusive,+int*nr_to_scan)+{+uint32_tfirst_index;+intlast_error=0;+intskipped;+xfs_inode_t*batch[RECLAIM_BATCH_SIZE];+intbatchnr;+inti;++BUG_ON(!exclusive);++restart:+skipped=0;+first_index=0;+next_batch:+batchnr=0;+/* fill the batch */+write_lock(&pag->pag_ici_lock);+do{+xfs_inode_t*ip;++ip=xfs_inode_ag_lookup(mp,pag,&first_index,tag);+if(!ip)+break;+if(!(flags&SYNC_WAIT)&&+(!xfs_iflock_free(ip)||+__xfs_iflags_test(ip,XFS_IRECLAIM)))+continue;++/*+*Theradixtreelockhereprotectsathreadinxfs_igetfrom+*racingwithusstartingreclaimontheinode.Oncewehave+*theXFS_IRECLAIMflagsetitwillnottouchus.+*/+spin_lock(&ip->i_flags_lock);+ASSERT_ALWAYS(__xfs_iflags_test(ip,XFS_IRECLAIMABLE));+if(__xfs_iflags_test(ip,XFS_IRECLAIM)){+/* ignore as it is already under reclaim */+spin_unlock(&ip->i_flags_lock);+continue;+}+__xfs_iflags_set(ip,XFS_IRECLAIM);+spin_unlock(&ip->i_flags_lock);++batch[batchnr++]=ip;+}while((*nr_to_scan)--&&batchnr<RECLAIM_BATCH_SIZE);+write_unlock(&pag->pag_ici_lock);++for(i=0;i<batchnr;i++){+interror=0;+xfs_inode_t*ip=batch[i];++/* execute doesn't require pag->pag_ici_lock */+error=execute(ip,pag,flags);+if(error==EAGAIN){+skipped++;+continue;+}+if(error)+last_error=error;++/* bail out if the filesystem is corrupted. */+if(error==EFSCORRUPTED)+break;+}+if(batchnr==RECLAIM_BATCH_SIZE)+gotonext_batch;++if(0&&skipped){+delay(1);+gotorestart;+}+returnlast_error;+}+STATICintxfs_inode_ag_walk(structxfs_mount*mp,
@@ -789,23 +879,6 @@ xfs_reclaim_inode({interror=0;-/*-*Theradixtreelockhereprotectsathreadinxfs_igetfromracing-*withusstartingreclaimontheinode.Oncewehavethe-*XFS_IRECLAIMflagsetitwillnottouchus.-*/-spin_lock(&ip->i_flags_lock);-ASSERT_ALWAYS(__xfs_iflags_test(ip,XFS_IRECLAIMABLE));-if(__xfs_iflags_test(ip,XFS_IRECLAIM)){-/* ignore as it is already under reclaim */-spin_unlock(&ip->i_flags_lock);-write_unlock(&pag->pag_ici_lock);-return0;-}-__xfs_iflags_set(ip,XFS_IRECLAIM);-spin_unlock(&ip->i_flags_lock);-write_unlock(&pag->pag_ici_lock);-xfs_ilock(ip,XFS_ILOCK_EXCL);if(!xfs_iflock_nowait(ip)){if(!(sync_mode&SYNC_WAIT))
From: Dave Chinner <david@fromorbit.com> Date: 2010-06-08 15:23:32
On Fri, Jul 30, 2010 at 12:05:46AM +1000, Nick Piggin wrote:
On Wed, Jul 28, 2010 at 11:17:44PM +1000, Dave Chinner wrote:
quoted
Something very strange is happening, and to make matters worse I
cannot reproduce it with a debug kernel (ran for 3 hours without
failing). Hence it smells like a race condition somewhere.
I've reproduced it without delayed logging, so it is not directly
related to that functionality.
I've seen this warning:
Filesystem "ram0": inode 0x704680 background reclaim flush failed with 117
Which indicates we failed to mark an inode stale when freeing an
inode cluster, but I think I've fixed that and the problem still
shows up. It's posible the last version didn't fix it, but....
I've seen that one a couple of times too. Keeps coming back each
time you echo 3 > /proc/sys/vm/drop_caches :)
Yup - it's an unflushable inode that is pinning the tail of the log,
hence causing the log space hangs.
quoted
Now I've got the ag iterator rotor patch in place as well and
possibly a different version of the cluster free fix to what I
previously tested and it's now been running for almost half an hour.
I can't say yet whether I've fixed the bug of just changed the
timing enough to avoid it. I'll leave this test running over night
and redo individual patch testing tomorrow.
I reproduced it with fs_stress now too. Any patches I could test
for you just let me know.
You should see them in a few minutes ;)
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
From: Nick Piggin <hidden> Date: 2010-06-08 20:22:08
On Fri, Jul 30, 2010 at 08:56:58AM +1000, Dave Chinner wrote:
On Fri, Jul 30, 2010 at 12:05:46AM +1000, Nick Piggin wrote:
quoted
On Wed, Jul 28, 2010 at 11:17:44PM +1000, Dave Chinner wrote:
quoted
Something very strange is happening, and to make matters worse I
cannot reproduce it with a debug kernel (ran for 3 hours without
failing). Hence it smells like a race condition somewhere.
I've reproduced it without delayed logging, so it is not directly
related to that functionality.
I've seen this warning:
Filesystem "ram0": inode 0x704680 background reclaim flush failed with 117
Which indicates we failed to mark an inode stale when freeing an
inode cluster, but I think I've fixed that and the problem still
shows up. It's posible the last version didn't fix it, but....
I've seen that one a couple of times too. Keeps coming back each
time you echo 3 > /proc/sys/vm/drop_caches :)
Yup - it's an unflushable inode that is pinning the tail of the log,
hence causing the log space hangs.
quoted
quoted
Now I've got the ag iterator rotor patch in place as well and
possibly a different version of the cluster free fix to what I
previously tested and it's now been running for almost half an hour.
I can't say yet whether I've fixed the bug of just changed the
timing enough to avoid it. I'll leave this test running over night
and redo individual patch testing tomorrow.
I reproduced it with fs_stress now too. Any patches I could test
for you just let me know.
You should see them in a few minutes ;)
It's certainly not locking up like it used to... Thanks!
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
I've made a similar setup, 2s8c machine, but using 2GB ramdisk instead
of a real disk (I don't have easy access to a good disk setup ATM, but
I guess we're more interested in code above the block layer anyway).
Made an XFS on /dev/ram0 with 16 ags, 64MB log, otherwise same config as
yours.
I found that performance is a little unstable, so I sync and echo 3 >
drop_caches between each run. When it starts reclaiming memory, things
get a bit more erratic (and XFS seemed to be almost livelocking for tens
of seconds in inode reclaim).
From: Dave Chinner <david@fromorbit.com> Date: 2010-07-27 13:27:37
On Tue, Jul 27, 2010 at 09:36:26PM +1000, Nick Piggin wrote:
On Tue, Jul 27, 2010 at 06:06:32PM +1000, Nick Piggin wrote:
On this same system, same setup (vanilla kernel with sha given below),
I have now twice reproduced a complete hang in XFS. I can give more
information, test patches or options etc if required.
setup.sh looks like this:
#!/bin/bash
modprobe rd rd_size=$[2*1024*1024]
dd if=/dev/zero of=/dev/ram0 bs=4K
mkfs.xfs -f -l size=64m -d agcount=16 /dev/ram0
mount -o delaylog,logbsize=262144,nobarrier /dev/ram0 mnt
The 'dd' is required to ensure rd driver does not allocate pages
during IO (which can lead to out of memory deadlocks). Running just
involves changing into mnt directory and
while true
do
sync
echo 3 > /proc/sys/vm/drop_caches
../dbench -c ../loadfiles/client.txt -t20 8
rm -rf clients
done
And wait for it to hang (happend in < 5 minutes here)
It's waiting on log space to be freed up. Either there's an
accounting problem (possible), or you've got an xfslogd/xfsaild
spinning and not making progress competing log IOs or pushing the
tail of the log. I'll see if I can reproduce it.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
From: Dave Chinner <david@fromorbit.com> Date: 2010-07-27 14:55:09
On Tue, Jul 27, 2010 at 11:30:38PM +1000, Dave Chinner wrote:
On Tue, Jul 27, 2010 at 09:36:26PM +1000, Nick Piggin wrote:
quoted
On Tue, Jul 27, 2010 at 06:06:32PM +1000, Nick Piggin wrote:
On this same system, same setup (vanilla kernel with sha given below),
I have now twice reproduced a complete hang in XFS. I can give more
information, test patches or options etc if required.
setup.sh looks like this:
#!/bin/bash
modprobe rd rd_size=$[2*1024*1024]
dd if=/dev/zero of=/dev/ram0 bs=4K
mkfs.xfs -f -l size=64m -d agcount=16 /dev/ram0
mount -o delaylog,logbsize=262144,nobarrier /dev/ram0 mnt
The 'dd' is required to ensure rd driver does not allocate pages
during IO (which can lead to out of memory deadlocks). Running just
involves changing into mnt directory and
while true
do
sync
echo 3 > /proc/sys/vm/drop_caches
../dbench -c ../loadfiles/client.txt -t20 8
rm -rf clients
done
And wait for it to hang (happend in < 5 minutes here)
It's waiting on log space to be freed up. Either there's an
accounting problem (possible), or you've got an xfslogd/xfsaild
spinning and not making progress competing log IOs or pushing the
tail of the log. I'll see if I can reproduce it.
Ok, I've just reproduced it. From some tracing:
touch-3340 [004] 1844935.582716: xfs_log_reserve: dev 1:0 type CREATE t_ocnt 2 t_cnt 2 t_curr_res 167148 t_unit_res 167148 t_flags XLOG_TIC_INITED|XLOG_TIC_PERM_RESERV reserve_headq 0xffff88010f489c78 write_headq 0x(null) grant_reserve_cycle 314 grant_reserve_bytes 24250680 grant_write_cycle 314 grant_write_bytes 24250680 curr_cycle 314 curr_block 44137 tail_cycle 313 tail_block 48532
The key part here is this:
curr_cycle 314 curr_block 44137 tail_cycle 313 tail_block 48532
This says the tail of the log is roughly 62MB behind the head. i.e
the log is full and we are waiting for tail pushing to write the
item holding the tail in place to disk so it can them be moved
forward. That's better than an accounting problem, at least.
So what is holding the tail in place? The first item on the AIL
appears to be:
xfsaild/ram0-2997 [000] 1844800.800764: xfs_buf_cond_lock: dev 1:0 bno 0x280120 len 0x2000 hold 3 pincount 0 lock 0 flags ASYNC|DONE|STALE|PAGE_CACHE caller xfs_buf_item_trylock
A stale buffer. Given that the next objects show this trace:
xfsaild/ram0-2997 [000] 1844800.800767: xfs_ilock_nowait: dev 1:0 ino 0x500241 flags ILOCK_SHARED caller xfs_inode_item_trylock
xfsaild/ram0-2997 [000] 1844800.800768: xfs_buf_rele: dev 1:0 bno 0x280120 len 0x2000 hold 4 pincount 0 lock 0 flags ASYNC|DONE|STALE|PAGE_CACHE caller _xfs_buf_find
xfsaild/ram0-2997 [000] 1844800.800769: xfs_iunlock: dev 1:0 ino 0x500241 flags ILOCK_SHARED caller xfs_inode_item_pushbuf
we see the next item on the AIL is an inode but the trace is
followed by a release on the original buffer, than tells me the
inode is flush locked and it returned XFS_ITEM_PUSHBUF to push the
inode buffer out. That results in xfs_inode_item_pushbuf() being
called, and that tries to lock the inode buffer to flush it.
xfs_buf_rele is called if the trylock on the buffer fails.
IOWs, this looks to be another problem with inode cluster freeing.
Ok, so we can't flush the buffer because it is locked. Why is it
locked? Well, that is unclear as yet. None of the blocked processes
should be holding an inode buffer locked, and a stale buffer should
be unlocked during transaction commit and not live longer than
the log IO that writes the transaction to disk. That is, it should
not get locked again before everything is freed up.
That's as much as I can get from post-mortem analysis - I need to
capture a trace that spans the lockup to catch what happens
to the buffer that we are hung on. That will have to wait until the
morning....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
I've made a similar setup, 2s8c machine, but using 2GB ramdisk instead
of a real disk (I don't have easy access to a good disk setup ATM, but
I guess we're more interested in code above the block layer anyway).
Made an XFS on /dev/ram0 with 16 ags, 64MB log, otherwise same config as
yours.
I found that performance is a little unstable, so I sync and echo 3 >
drop_caches between each run. When it starts reclaiming memory, things
get a bit more erratic (and XFS seemed to be almost livelocking for tens
of seconds in inode reclaim).
So about this XFS livelock type thingy. It looks like this, and happens
periodically while running the above fs_mark benchmark requiring reclaim
of inodes:
....
Nothing much happening except 100% system time for seconds at a time
(length of time varies). This is on a ramdisk, so it isn't waiting
for IO.
During this time, lots of things are contending on the lock:
60.37% fs_mark [kernel.kallsyms] [k] __write_lock_failed
4.30% kswapd0 [kernel.kallsyms] [k] __write_lock_failed
3.70% fs_mark [kernel.kallsyms] [k] try_wait_for_completion
3.59% fs_mark [kernel.kallsyms] [k] _raw_write_lock
3.46% kswapd1 [kernel.kallsyms] [k] __write_lock_failed
|
--- __write_lock_failed
|
|--99.92%-- xfs_inode_ag_walk
| xfs_inode_ag_iterator
| xfs_reclaim_inode_shrink
| shrink_slab
| shrink_zone
| balance_pgdat
| kswapd
| kthread
| kernel_thread_helper
--0.08%-- [...]
3.02% fs_mark [kernel.kallsyms] [k] _raw_spin_lock
1.82% fs_mark [kernel.kallsyms] [k] _xfs_buf_find
1.16% fs_mark [kernel.kallsyms] [k] memcpy
0.86% fs_mark [kernel.kallsyms] [k] _raw_spin_lock_irqsave
0.75% fs_mark [kernel.kallsyms] [k] xfs_log_commit_cil
|
--- xfs_log_commit_cil
_xfs_trans_commit
|
|--60.00%-- xfs_remove
| xfs_vn_unlink
| vfs_unlink
| do_unlinkat
| sys_unlink
I'm not sure if there was a long-running read locker in there causing
all the write lockers to fail, or if they are just running into one
another.
The longest hold is in the inode cluster writeback
(xfs_iflush_cluster), but if there is no IO then I don't see how
that would be a problem.
I suspect that it might be caused by having several CPUs
all trying to run the shrinker at the same time and them all
starting at the same AG and therefore lockstepping and getting
nothing done because they are all scanning the same inodes.
Maybe a start AG rotor for xfs_inode_ag_iterator() is needed to
avoid this lockstepping. I've attached a patch below to do this
- can you give it a try?
But anyway, I hacked the following patch which seemed to
improve that behaviour. I haven't run any throughput numbers on it yet,
but I could if you're interested (and it's not completely broken!)
Batching is certainly something that I have been considering, but
apart from the excessive scanning bug, the per-ag inode tree lookups
hve not featured prominently in any profiling I've done, so it
hasn't been a high priority.
You patch looks like it will work fine, but I think it can be made a
lot cleaner. I'll have a closer look at this once I get to the bottom of
the dbench hang you are seeing....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
xfs: add an AG iterator start rotor
From: Dave Chinner <redacted>
To avoid multiple CPUs from executing inode cache shrinkers on the same AG all
at the same time, make every shrinker call start on a different AG. This will
mostly prevent concurrent shrinker calls from competing for the serialising
pag_ici_lock and lock-stepping reclaim.
Signed-off-by: Dave Chinner <redacted>
---
fs/xfs/linux-2.6/xfs_sync.c | 11 ++++++++++-
fs/xfs/xfs_mount.h | 1 +
2 files changed, 11 insertions(+), 1 deletions(-)
From: Dave Chinner <david@fromorbit.com> Date: 2010-07-28 13:14:44
On Wed, Jul 28, 2010 at 12:58:09AM +1000, Dave Chinner wrote:
On Tue, Jul 27, 2010 at 11:30:38PM +1000, Dave Chinner wrote:
quoted
On Tue, Jul 27, 2010 at 09:36:26PM +1000, Nick Piggin wrote:
quoted
On Tue, Jul 27, 2010 at 06:06:32PM +1000, Nick Piggin wrote:
On this same system, same setup (vanilla kernel with sha given below),
I have now twice reproduced a complete hang in XFS. I can give more
information, test patches or options etc if required.
setup.sh looks like this:
#!/bin/bash
modprobe rd rd_size=$[2*1024*1024]
dd if=/dev/zero of=/dev/ram0 bs=4K
mkfs.xfs -f -l size=64m -d agcount=16 /dev/ram0
mount -o delaylog,logbsize=262144,nobarrier /dev/ram0 mnt
The 'dd' is required to ensure rd driver does not allocate pages
during IO (which can lead to out of memory deadlocks). Running just
involves changing into mnt directory and
while true
do
sync
echo 3 > /proc/sys/vm/drop_caches
../dbench -c ../loadfiles/client.txt -t20 8
rm -rf clients
done
And wait for it to hang (happend in < 5 minutes here)
It's waiting on log space to be freed up. Either there's an
accounting problem (possible), or you've got an xfslogd/xfsaild
spinning and not making progress competing log IOs or pushing the
tail of the log. I'll see if I can reproduce it.
Ok, I've just reproduced it. From some tracing:
touch-3340 [004] 1844935.582716: xfs_log_reserve: dev 1:0 type CREATE t_ocnt 2 t_cnt 2 t_curr_res 167148 t_unit_res 167148 t_flags XLOG_TIC_INITED|XLOG_TIC_PERM_RESERV reserve_headq 0xffff88010f489c78 write_headq 0x(null) grant_reserve_cycle 314 grant_reserve_bytes 24250680 grant_write_cycle 314 grant_write_bytes 24250680 curr_cycle 314 curr_block 44137 tail_cycle 313 tail_block 48532
The key part here is this:
curr_cycle 314 curr_block 44137 tail_cycle 313 tail_block 48532
This says the tail of the log is roughly 62MB behind the head. i.e
the log is full and we are waiting for tail pushing to write the
item holding the tail in place to disk so it can them be moved
forward. That's better than an accounting problem, at least.
So what is holding the tail in place? The first item on the AIL
appears to be:
xfsaild/ram0-2997 [000] 1844800.800764: xfs_buf_cond_lock: dev 1:0 bno 0x280120 len 0x2000 hold 3 pincount 0 lock 0 flags ASYNC|DONE|STALE|PAGE_CACHE caller xfs_buf_item_trylock
A stale buffer. Given that the next objects show this trace:
xfsaild/ram0-2997 [000] 1844800.800767: xfs_ilock_nowait: dev 1:0 ino 0x500241 flags ILOCK_SHARED caller xfs_inode_item_trylock
xfsaild/ram0-2997 [000] 1844800.800768: xfs_buf_rele: dev 1:0 bno 0x280120 len 0x2000 hold 4 pincount 0 lock 0 flags ASYNC|DONE|STALE|PAGE_CACHE caller _xfs_buf_find
xfsaild/ram0-2997 [000] 1844800.800769: xfs_iunlock: dev 1:0 ino 0x500241 flags ILOCK_SHARED caller xfs_inode_item_pushbuf
we see the next item on the AIL is an inode but the trace is
followed by a release on the original buffer, than tells me the
inode is flush locked and it returned XFS_ITEM_PUSHBUF to push the
inode buffer out. That results in xfs_inode_item_pushbuf() being
called, and that tries to lock the inode buffer to flush it.
xfs_buf_rele is called if the trylock on the buffer fails.
IOWs, this looks to be another problem with inode cluster freeing.
Ok, so we can't flush the buffer because it is locked. Why is it
locked? Well, that is unclear as yet. None of the blocked processes
should be holding an inode buffer locked, and a stale buffer should
be unlocked during transaction commit and not live longer than
the log IO that writes the transaction to disk. That is, it should
not get locked again before everything is freed up.
That's as much as I can get from post-mortem analysis - I need to
capture a trace that spans the lockup to catch what happens
to the buffer that we are hung on. That will have to wait until the
morning....
Ok, so I got a trace of all the inode and buffer locking and log
item operations, and the reason the hang has occurred can bee seen
here:
dbench-3084 [007] 1877156.395784: xfs_buf_item_unlock_stale: dev 1:0 bno 0x80040 len 0x2000 hold 2 pincount 0 lock 0 flags |ASYNC|DONE|STALE|PAGE_CACHE recur 1 refcount 1 bliflags |STALE|INODE_ALLOC|STALE_INODE lidesc 0x(null) liflags IN_AIL
The key points in this trace is that when we are unlocking a stale
buffer during transaction commit - we don't actually unlock it. WHat
we do it:
/*
* If the buf item is marked stale, then don't do anything. We'll
* unlock the buffer and free the buf item when the buffer is unpinned
* for the last time.
*/
if (bip->bli_flags & XFS_BLI_STALE) {
trace_xfs_buf_item_unlock_stale(bip);
ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL);
if (!aborted) {
atomic_dec(&bip->bli_refcount);
return;
}
}
But from the above trace it can be seen that the buffer pincount is zero.
Hence it will never get and unpin callback, and hence never get unlocked.
As a result, this process here is the one that is stuck on the buffer:
dbench D 0000000000000007 0 3084 1 0x00000004
ffff880104e07608 0000000000000086 ffff880104e075b8 0000000000014000
ffff880104e07fd8 0000000000014000 ffff880104e07fd8 ffff880104c1d770
0000000000014000 0000000000014000 ffff880104e07fd8 0000000000014000
Call Trace:
[<ffffffff817e59cd>] schedule_timeout+0x1ed/0x2c0
[<ffffffff810de9de>] ? ring_buffer_lock_reserve+0x9e/0x160
[<ffffffff817e690e>] __down+0x7e/0xc0
[<ffffffff812f41d5>] ? _xfs_buf_find+0x145/0x290
[<ffffffff810a05d0>] down+0x40/0x50
[<ffffffff812f41d5>] ? _xfs_buf_find+0x145/0x290
[<ffffffff812f314d>] xfs_buf_lock+0x4d/0x110
[<ffffffff812f41d5>] _xfs_buf_find+0x145/0x290
[<ffffffff812f4380>] xfs_buf_get+0x60/0x1c0
[<ffffffff812ea8f0>] xfs_trans_get_buf+0xe0/0x180
[<ffffffff812ccdab>] xfs_ialloc_inode_init+0xcb/0x1c0
[<ffffffff812cdaf9>] xfs_ialloc_ag_alloc+0x179/0x4a0
[<ffffffff812cdeff>] xfs_dialloc+0xdf/0x870
[<ffffffff8105ec88>] ? pvclock_clocksource_read+0x58/0xd0
[<ffffffff812d2105>] xfs_ialloc+0x65/0x6b0
[<ffffffff812eb032>] xfs_dir_ialloc+0x82/0x2d0
[<ffffffff8128ce83>] ? ftrace_raw_event_xfs_lock_class+0xd3/0xe0
[<ffffffff812ecad7>] ? xfs_create+0x1a7/0x690
[<ffffffff812ecd37>] xfs_create+0x407/0x690
[<ffffffff812f9f97>] xfs_vn_mknod+0xa7/0x1c0
[<ffffffff812fa0e0>] xfs_vn_create+0x10/0x20
[<ffffffff8114ca6c>] vfs_create+0xac/0xd0
[<ffffffff8114d6ec>] do_last+0x51c/0x620
[<ffffffff8114f6d8>] do_filp_open+0x228/0x640
[<ffffffff812c1f18>] ? xfs_dir2_block_getdents+0x218/0x220
[<ffffffff8115a62a>] ? alloc_fd+0x10a/0x150
[<ffffffff8113f919>] do_sys_open+0x69/0x140
[<ffffffff8113fa30>] sys_open+0x20/0x30
[<ffffffff81035032>] system_call_fastpath+0x16/0x1b
It is trying to allocate a new inode chunk on disk, which happens to
be the one we just removed and staled. Now to find out why the pin
count on the buffer is wrong.
.....
Now it makes no sense - the buf item pin trace is there directly
directly before the above unlock stale trace. The buf item pinning
increments both the buffer pin count and the buf item refcount,
neith of which are reflected in the unlock stale trace. From the
trace analysis I did:
process
83 84 85 86 87
.....
get
trans_read
stale
format
pin
unlock
committed
unpin stale
free
trans_get
init
format
pin
item unlock
get
trans_read
unlock
get
trans_read
item unlock
**** pincount goes from 1 to 0 here without any unpin traces ****
get
trans_read
unlock
get
trans_read
item unlock
(repeat 1x)
get
trans_read
unlock
get
trans_read
stale
format
pin
**** no committed/unlock/free trace for this transaction ****
**** hold count goes from 2 to 1 without any rele traces ****
**** is a new buffer allocated here without the staled buffer being committed? ****
trans_get
init
format
pin
item unlock
get
trans_read
unlock
get
trans_read
item unlock
(repeat 9x)
get
trans_read
unlock
get
trans_read
stale
format
pin
**** pin count does not increment! ****
buf lock from xfs_buf_find => hangs
**** buffer that was found is locked, not pinned ****
Something very strange is happening, and to make matters worse I
cannot reproduce it with a debug kernel (ran for 3 hours without
failing). Hence it smells like a race condition somewhere.
I've reproduced it without delayed logging, so it is not directly
related to that functionality.
I've seen this warning:
Filesystem "ram0": inode 0x704680 background reclaim flush failed with 117
Which indicates we failed to mark an inode stale when freeing an
inode cluster, but I think I've fixed that and the problem still
shows up. It's posible the last version didn't fix it, but....
Now I've got the ag iterator rotor patch in place as well and
possibly a different version of the cluster free fix to what I
previously tested and it's now been running for almost half an hour.
I can't say yet whether I've fixed the bug of just changed the
timing enough to avoid it. I'll leave this test running over night
and redo individual patch testing tomorrow.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
From: Nick Piggin <hidden> Date: 2010-07-29 14:02:42
On Wed, Jul 28, 2010 at 11:17:44PM +1000, Dave Chinner wrote:
Something very strange is happening, and to make matters worse I
cannot reproduce it with a debug kernel (ran for 3 hours without
failing). Hence it smells like a race condition somewhere.
I've reproduced it without delayed logging, so it is not directly
related to that functionality.
I've seen this warning:
Filesystem "ram0": inode 0x704680 background reclaim flush failed with 117
Which indicates we failed to mark an inode stale when freeing an
inode cluster, but I think I've fixed that and the problem still
shows up. It's posible the last version didn't fix it, but....
I've seen that one a couple of times too. Keeps coming back each
time you echo 3 > /proc/sys/vm/drop_caches :)
Now I've got the ag iterator rotor patch in place as well and
possibly a different version of the cluster free fix to what I
previously tested and it's now been running for almost half an hour.
I can't say yet whether I've fixed the bug of just changed the
timing enough to avoid it. I'll leave this test running over night
and redo individual patch testing tomorrow.
I reproduced it with fs_stress now too. Any patches I could test
for you just let me know.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
I've made a similar setup, 2s8c machine, but using 2GB ramdisk instead
of a real disk (I don't have easy access to a good disk setup ATM, but
I guess we're more interested in code above the block layer anyway).
Made an XFS on /dev/ram0 with 16 ags, 64MB log, otherwise same config as
yours.
I found that performance is a little unstable, so I sync and echo 3 >
drop_caches between each run. When it starts reclaiming memory, things
get a bit more erratic (and XFS seemed to be almost livelocking for tens
of seconds in inode reclaim).
So about this XFS livelock type thingy. It looks like this, and happens
periodically while running the above fs_mark benchmark requiring reclaim
of inodes:
....
quoted
Nothing much happening except 100% system time for seconds at a time
(length of time varies). This is on a ramdisk, so it isn't waiting
for IO.
During this time, lots of things are contending on the lock:
60.37% fs_mark [kernel.kallsyms] [k] __write_lock_failed
4.30% kswapd0 [kernel.kallsyms] [k] __write_lock_failed
3.70% fs_mark [kernel.kallsyms] [k] try_wait_for_completion
3.59% fs_mark [kernel.kallsyms] [k] _raw_write_lock
3.46% kswapd1 [kernel.kallsyms] [k] __write_lock_failed
|
--- __write_lock_failed
|
|--99.92%-- xfs_inode_ag_walk
| xfs_inode_ag_iterator
| xfs_reclaim_inode_shrink
| shrink_slab
| shrink_zone
| balance_pgdat
| kswapd
| kthread
| kernel_thread_helper
--0.08%-- [...]
3.02% fs_mark [kernel.kallsyms] [k] _raw_spin_lock
1.82% fs_mark [kernel.kallsyms] [k] _xfs_buf_find
1.16% fs_mark [kernel.kallsyms] [k] memcpy
0.86% fs_mark [kernel.kallsyms] [k] _raw_spin_lock_irqsave
0.75% fs_mark [kernel.kallsyms] [k] xfs_log_commit_cil
|
--- xfs_log_commit_cil
_xfs_trans_commit
|
|--60.00%-- xfs_remove
| xfs_vn_unlink
| vfs_unlink
| do_unlinkat
| sys_unlink
I'm not sure if there was a long-running read locker in there causing
all the write lockers to fail, or if they are just running into one
another.
The longest hold is in the inode cluster writeback
(xfs_iflush_cluster), but if there is no IO then I don't see how
that would be a problem.
No I wasn't suggesting there was, just that there could have
been one that I didn't notice in profiles (ie. because it
had taken read lock rather than spinning on it).
I suspect that it might be caused by having several CPUs
all trying to run the shrinker at the same time and them all
starting at the same AG and therefore lockstepping and getting
nothing done because they are all scanning the same inodes.
I think that is the most likely answer, yes.
Maybe a start AG rotor for xfs_inode_ag_iterator() is needed to
avoid this lockstepping. I've attached a patch below to do this
- can you give it a try?
Cool yes I will. I could try it in combination with the batching
patch too. Thanks.
quoted
But anyway, I hacked the following patch which seemed to
improve that behaviour. I haven't run any throughput numbers on it yet,
but I could if you're interested (and it's not completely broken!)
Batching is certainly something that I have been considering, but
apart from the excessive scanning bug, the per-ag inode tree lookups
hve not featured prominently in any profiling I've done, so it
hasn't been a high priority.
You patch looks like it will work fine, but I think it can be made a
lot cleaner. I'll have a closer look at this once I get to the bottom of
the dbench hang you are seeing....
Well I'll see if I can measure any efficiency or lock contention
improvements with it and report back. Might have to wait till the
weekend.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs