rcu-walk and dcache scaling
Subsystems (58)
Nick Piggin
reviewerQuoted 7 lines · Dave Chinner
Quoted 6 lines · Nick Piggin
git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.gitvfs-scale-workingHere is an new set of vfs patches for review, not that there was much interest last time they were posted. It is structured like:
Quoted 8 lines
Quoted 5 lines
* preparation patches
* introduce new locks to take overdcache_lock, then remove it
* cleaning up and reworking things for new locks
* rcu-walk path walking
* start on some fine grained locking stepsJust got this set of traces doing an 8-way parallel remove of 50 million inodes at about 40M inodes unlinked:
Thanks for testing...
Quoted 41 lines
[ 5954.061633] BUG: sleeping function called from invalid context at arch/x86/mm/fault.c:1081
[ 5954.062466] in_atomic(): 0, irqs_disabled(): 1, pid: 2927, name: rm
[ 5954.063122] 3 locks held by rm/2927:
[ 5954.063476] #0: (&sb->s_type->i_mutex_key#12/1){+.+.+.}, at: [<ffffffff8116f5e1>] do_rmdir+0x81/0x130
[ 5954.064014] #1: (&sb->s_type->i_mutex_key#12){+.+.+.}, at: [<ffffffff8116d3a8>] vfs_rmdir+0x58/0xe0
[ 5954.064014] #2: (rcu_read_lock){.+.+..}, at: [<ffffffff811779c0>] shrink_dentry_list+0x0/0x430
[ 5954.064014] irq event stamp: 1484376719
[ 5954.064014] hardirqs last enabled at (1484376719): [<ffffffff810ebf07>] __call_rcu+0xd7/0x1a0
[ 5954.064014] hardirqs last disabled at (1484376718): [<ffffffff810ebe7a>] __call_rcu+0x4a/0x1a0
[ 5954.064014] softirqs last enabled at (1484376586): [<ffffffff8108b911>] __do_softirq+0x161/0x270
[ 5954.064014] softirqs last disabled at (1484376581): [<ffffffff8103af1c>] call_softirq+0x1c/0x50
[ 5954.064014] Pid: 2927, comm: rm Not tainted 2.6.37-rc4-dgc+ #794
[ 5954.064014] Call Trace:
[ 5954.064014] [<ffffffff810b95b0>] ? print_irqtrace_events+0xd0/0xe0
[ 5954.064014] [<ffffffff81076455>] __might_sleep+0xf5/0x130
[ 5954.064014] [<ffffffff81b1e603>] do_page_fault+0x103/0x4f0
[ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0
[ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0
[ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0
[ 5954.064014] [<ffffffff81b19b28>] ? trace_hardirqs_off_thunk+0x3a/0x3c
[ 5954.064014] [<ffffffff810b8e20>] ? usage_match+0x0/0x20
[ 5954.064014] [<ffffffff81b1af25>] page_fault+0x25/0x30
[ 5954.064014] [<ffffffff810b8e20>] ? usage_match+0x0/0x20
[ 5954.064014] [<ffffffff810ba1c8>] ? __bfs+0xc8/0x260
[ 5954.064014] [<ffffffff810ba123>] ? __bfs+0x23/0x260
[ 5954.064014] [<ffffffff810ba4d2>] find_usage_backwards+0x42/0x80
[ 5954.064014] [<ffffffff810bcec4>] check_usage_backwards+0x64/0xf0
[ 5954.064014] [<ffffffff8104796f>] ? save_stack_trace+0x2f/0x50
[ 5954.064014] [<ffffffff810bce60>] ? check_usage_backwards+0x0/0xf0
[ 5954.064014] [<ffffffff810bd9a9>] mark_lock+0x1a9/0x440
[ 5954.064014] [<ffffffff810be989>] __lock_acquire+0x5a9/0x14b0
[ 5954.064014] [<ffffffff810be716>] ? __lock_acquire+0x336/0x14b0
[ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0
[ 5954.064014] [<ffffffff810bf944>] lock_acquire+0xb4/0x140
[ 5954.064014] [<ffffffff81177a1c>] ? shrink_dentry_list+0x5c/0x430
[ 5954.064014] [<ffffffff81b19d86>] _raw_spin_lock+0x36/0x70
[ 5954.064014] [<ffffffff81177a1c>] ? shrink_dentry_list+0x5c/0x430
[ 5954.064014] [<ffffffff81177a1c>] shrink_dentry_list+0x5c/0x430
[ 5954.064014] [<ffffffff811779c0>] ? shrink_dentry_list+0x0/0x430
[ 5954.064014] [<ffffffff816b9c7e>] ? do_raw_spin_unlock+0x5e/0xb0
[ 5954.064014] [<ffffffff81177f2d>] __shrink_dcache_sb+0x13d/0x1c0Quoted 8 lines
[ 5954.064014] [<ffffffff811784bf>] shrink_dcache_parent+0x32f/0x390 [ 5954.064014] [<ffffffff8116d31d>] dentry_unhash+0x3d/0x70 [ 5954.064014] [<ffffffff8116d3b0>] vfs_rmdir+0x60/0xe0 [ 5954.064014] [<ffffffff8116f673>] do_rmdir+0x113/0x130 [ 5954.064014] [<ffffffff8103a03a>] ? sysret_check+0x2e/0x69 [ 5954.064014] [<ffffffff81b19ae9>] ? trace_hardirqs_on_thunk+0x3a/0x3f [ 5954.064014] [<ffffffff8116f6c5>] sys_unlinkat+0x35/0x40 [ 5954.064014] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1b
Seems that lockdep exploded.
Quoted 48 lines
[ 5954.092916] BUG: unable to handle kernel NULL pointer dereference at (null) [ 5954.093806] IP: [<ffffffff810ba1c8>] __bfs+0xc8/0x260 [ 5954.094331] PGD 1084e5067 PUD 102368067 PMD 0 [ 5954.094830] Oops: 0000 [#1] SMP [ 5954.095194] last sysfs file: /sys/devices/system/cpu/online [ 5954.095760] CPU 6 [ 5954.095954] Modules linked in: [ 5954.096319] [ 5954.096483] Pid: 2927, comm: rm Not tainted 2.6.37-rc4-dgc+ #794 /Bochs [ 5954.096665] RIP: 0010:[<ffffffff810ba1c8>] [<ffffffff810ba1c8>] __bfs+0xc8/0x260 [ 5954.096665] RSP: 0018:ffff8801175539a8 EFLAGS: 00010046 [ 5954.096665] RAX: ffffffff8267d980 RBX: ffffffff8267d980 RCX: ffff880117553a48 [ 5954.096665] RDX: ffff8801175539d0 RSI: 0000000000000000 RDI: ffff880117553a48 [ 5954.096665] RBP: ffff880117553a08 R08: 0000000000000000 R09: 0000000000000000 [ 5954.096665] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000 [ 5954.096665] R13: ffffffff810b8e20 R14: ffff880117553a90 R15: 0000000000000000 [ 5954.096665] FS: 00007f4594cf3700(0000) GS:ffff8800dfa00000(0000) knlGS:0000000000000000 [ 5954.096665] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 5954.096665] CR2: 00007f2f21e89c60 CR3: 0000000110b0f000 CR4: 00000000000006e0 [ 5954.096665] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 5954.096665] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 5954.096665] Process rm (pid: 2927, threadinfo ffff880117552000, task ffff88010ff10b00) [ 5954.096665] Stack: [ 5954.096665] ffffffff8267d868 00007fffa02d1428 ffff8800ffffffff ffff880100000000 [ 5954.096665] 000000000000b720 ffff880117553a48 ffffffff8267d868 ffff880117553a48 [ 5954.096665] 0000000000000000 ffff88010ff10b00 0000000000000000 ffffffff81dacba0 [ 5954.096665] Call Trace: [ 5954.096665] [<ffffffff810ba4d2>] find_usage_backwards+0x42/0x80 [ 5954.096665] [<ffffffff810bcec4>] check_usage_backwards+0x64/0xf0 [ 5954.096665] [<ffffffff8104796f>] ? save_stack_trace+0x2f/0x50 [ 5954.096665] [<ffffffff810bce60>] ? check_usage_backwards+0x0/0xf0 [ 5954.096665] [<ffffffff810bd9a9>] mark_lock+0x1a9/0x440 [ 5954.096665] [<ffffffff810be989>] __lock_acquire+0x5a9/0x14b0 [ 5954.096665] [<ffffffff810be716>] ? __lock_acquire+0x336/0x14b0 [ 5954.096665] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0 [ 5954.096665] [<ffffffff810bf944>] lock_acquire+0xb4/0x140 [ 5954.096665] [<ffffffff81177a1c>] ? shrink_dentry_list+0x5c/0x430 [ 5954.096665] [<ffffffff81b19d86>] _raw_spin_lock+0x36/0x70 [ 5954.096665] [<ffffffff81177a1c>] ? shrink_dentry_list+0x5c/0x430 [ 5954.096665] [<ffffffff81177a1c>] shrink_dentry_list+0x5c/0x430 [ 5954.096665] [<ffffffff811779c0>] ? shrink_dentry_list+0x0/0x430 [ 5954.096665] [<ffffffff816b9c7e>] ? do_raw_spin_unlock+0x5e/0xb0 [ 5954.096665] [<ffffffff81177f2d>] __shrink_dcache_sb+0x13d/0x1c0 [ 5954.096665] [<ffffffff811784bf>] shrink_dcache_parent+0x32f/0x390 [ 5954.096665] [<ffffffff8116d31d>] dentry_unhash+0x3d/0x70 [ 5954.096665] [<ffffffff8116d3b0>] vfs_rmdir+0x60/0xe0 [ 5954.096665] [<ffffffff8116f673>] do_rmdir+0x113/0x130 [ 5954.096665] [<ffffffff8103a03a>] ? sysret_check+0x2e/0x69
Quoted 8 lines
[ 5954.096665] [<ffffffff81b19ae9>] ? trace_hardirqs_on_thunk+0x3a/0x3f [ 5954.096665] [<ffffffff8116f6c5>] sys_unlinkat+0x35/0x40 [ 5954.096665] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1b [ 5954.096665] Code: 0a 89 05 dc 0f a8 01 48 8b 41 10 48 85 c0 0f 84 1f 01 00 00 48 8d 98 70 01 00 00 48 05 80 01 00 00 45 85 c0 48 0f 44 d8 4c 8b 3b <49> 8b 07 49 39 [ 5954.096665] RIP [<ffffffff810ba1c8>] __bfs+0xc8/0x260 [ 5954.096665] RSP <ffff8801175539a8> [ 5954.096665] CR2: 0000000000000000 [ 5954.127991] ---[ end trace 85a6727c2d4e3d90 ]---
So I vfs-scale-working branch may not be entirely in the clear, seeing as it touches
the code lower in the call chain. However I don't know what can cause lockdep to go off
the rails like this.
There is a sequence I used to hack around lockdep nesting restrictions, following this
pattern:
repeat:
spin_lock(&parent->d_lock);
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
/* do stuff */
spin_unlock(&parent->d_lock);
spin_release(&dentry->d_lock.dep_map, 1, _RET_IP_);
parent = dentry;
spin_acquire(&this_parent->d_lock.dep_map, 0, 1, _RET_IP_);
goto repeat;It's not directly in this call chain, but I wonder if it could have caused any problem?
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Nick Piggin
repeat:
spin_lock(&parent->d_lock); spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); /* do stuff */ spin_unlock(&parent->d_lock); spin_release(&dentry->d_lock.dep_map, 1, _RET_IP_); parent = dentry; spin_acquire(&this_parent->d_lock.dep_map, 0, 1, _RET_IP_); goto repeat;
shouldn't that be s/this_parent/parent/ ?
So what you're trying to do is:
A -> B -> C -> ...
lock A
lock B, nested
unlock A
flip B from nested to top
lock C, nested
unlock B
flip C from nested to top
lock ...
Anyway, the way to write that is something like:
lock_set_subclass(&detry->d_lock.dep_map, 0, _RET_IP_);
Which will reset the subclass of the held lock from DENTRY_D_LOCK_NESTED to 0.
This is also used in double_unlock_balance(), we go into double_lock_balance() with this_rq locked and want to lock busiest, because of the lock ordering we might need to unlock this_rq and lock busiest first, at which point this_rq is nested.
On unlock we thus need to map this_rq back to subclass 0 (which it had before double_lock_balance(), because otherwise subsequent lock operations will be done against the subclass and confuse things.
Nick Piggin
reviewerQuoted 12 lines · Peter Zijlstra
Quoted 10 lines · Nick Piggin
repeat:
spin_lock(&parent->d_lock);spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); /* do stuff */
spin_unlock(&parent->d_lock);spin_release(&dentry->d_lock.dep_map, 1, _RET_IP_); parent = dentry;spin_acquire(&this_parent->d_lock.dep_map, 0, 1, _RET_IP_); goto repeat;
Quoted 1 line
shouldn't that be s/this_parent/parent/ ?
Yes, typo in my pseudo code.
Quoted 13 lines
So what you're trying to do is:
A -> B -> C -> ...
lock A
lock B, nested
unlock A
flip B from nested to top
lock C, nested
unlock B
flip C from nested to top
lock ...
Quoted 6 lines
Anyway, the way to write that is something like:
lock_set_subclass(&detry->d_lock.dep_map, 0, _RET_IP_);
Which will reset the subclass of the held lock from
DENTRY_D_LOCK_NESTEDto 0.
OK, thanks. My version should not have caused any problems though, right? Any idea what might have caused Dave's crash?
Quoted 8 lines
This is also used in
double_unlock_balance(), we go intodouble_lock_balance()withthis_rqlocked and want to lock busiest, because of the lock ordering we might need to unlockthis_rqand lock busiest first, at which pointthis_rqis nested.On unlock we thus need to map
this_rqback to subclass 0 (which it had beforedouble_lock_balance(), because otherwise subsequent lock operations will be done against the subclass and confuse things.
Thanks,
Nick
Quoted 2 lines · Nick Piggin
OK, thanks. My version should not have caused any problems though, right?
I tihnk so, yes, altough looking at it again I wonder why you use spin_aquire(.trylock=1) -- but that too shouldn't cause anything like the explosion.
Quoted 1 line
Any idea what might have caused Dave's crash?
Not directly, no. Usually lockdep crashes indicate use after free like things, where we try to lock a lock that's been scribbled on. But that usually explodes a bit earlier.
You faulting in the middle of that breath-first-search does suggest some data corruption, but I'm not quite sure what kind, I can't remember ever having seem something like this before.
I've CC'ed Ming Lei who wrote the bfs search, maybe he's got an idea.
Copy of the splat:
---
Quoted 49 lines
[ 5954.061633] BUG: sleeping function called from invalid context at arch/x86/mm/fault.c:1081
[ 5954.062466] in_atomic(): 0, irqs_disabled(): 1, pid: 2927, name: rm
[ 5954.063122] 3 locks held by rm/2927:
[ 5954.063476] #0: (&sb->s_type->i_mutex_key#12/1){+.+.+.}, at: [<ffffffff8116f5e1>] do_rmdir+0x81/0x130
[ 5954.064014] #1: (&sb->s_type->i_mutex_key#12){+.+.+.}, at: [<ffffffff8116d3a8>] vfs_rmdir+0x58/0xe0
[ 5954.064014] #2: (rcu_read_lock){.+.+..}, at: [<ffffffff811779c0>] shrink_dentry_list+0x0/0x430
[ 5954.064014] irq event stamp: 1484376719
[ 5954.064014] hardirqs last enabled at (1484376719): [<ffffffff810ebf07>] __call_rcu+0xd7/0x1a0
[ 5954.064014] hardirqs last disabled at (1484376718): [<ffffffff810ebe7a>] __call_rcu+0x4a/0x1a0
[ 5954.064014] softirqs last enabled at (1484376586): [<ffffffff8108b911>] __do_softirq+0x161/0x270
[ 5954.064014] softirqs last disabled at (1484376581): [<ffffffff8103af1c>] call_softirq+0x1c/0x50
[ 5954.064014] Pid: 2927, comm: rm Not tainted 2.6.37-rc4-dgc+ #794
[ 5954.064014] Call Trace:
[ 5954.064014] [<ffffffff810b95b0>] ? print_irqtrace_events+0xd0/0xe0
[ 5954.064014] [<ffffffff81076455>] __might_sleep+0xf5/0x130
[ 5954.064014] [<ffffffff81b1e603>] do_page_fault+0x103/0x4f0
[ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0
[ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0
[ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0
[ 5954.064014] [<ffffffff81b19b28>] ? trace_hardirqs_off_thunk+0x3a/0x3c
[ 5954.064014] [<ffffffff810b8e20>] ? usage_match+0x0/0x20
[ 5954.064014] [<ffffffff81b1af25>] page_fault+0x25/0x30
[ 5954.064014] [<ffffffff810b8e20>] ? usage_match+0x0/0x20
[ 5954.064014] [<ffffffff810ba1c8>] ? __bfs+0xc8/0x260
[ 5954.064014] [<ffffffff810ba123>] ? __bfs+0x23/0x260
[ 5954.064014] [<ffffffff810ba4d2>] find_usage_backwards+0x42/0x80
[ 5954.064014] [<ffffffff810bcec4>] check_usage_backwards+0x64/0xf0
[ 5954.064014] [<ffffffff8104796f>] ? save_stack_trace+0x2f/0x50
[ 5954.064014] [<ffffffff810bce60>] ? check_usage_backwards+0x0/0xf0
[ 5954.064014] [<ffffffff810bd9a9>] mark_lock+0x1a9/0x440
[ 5954.064014] [<ffffffff810be989>] __lock_acquire+0x5a9/0x14b0
[ 5954.064014] [<ffffffff810be716>] ? __lock_acquire+0x336/0x14b0
[ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0
[ 5954.064014] [<ffffffff810bf944>] lock_acquire+0xb4/0x140
[ 5954.064014] [<ffffffff81177a1c>] ? shrink_dentry_list+0x5c/0x430
[ 5954.064014] [<ffffffff81b19d86>] _raw_spin_lock+0x36/0x70
[ 5954.064014] [<ffffffff81177a1c>] ? shrink_dentry_list+0x5c/0x430
[ 5954.064014] [<ffffffff81177a1c>] shrink_dentry_list+0x5c/0x430
[ 5954.064014] [<ffffffff811779c0>] ? shrink_dentry_list+0x0/0x430
[ 5954.064014] [<ffffffff816b9c7e>] ? do_raw_spin_unlock+0x5e/0xb0
[ 5954.064014] [<ffffffff81177f2d>] __shrink_dcache_sb+0x13d/0x1c0
[ 5954.064014] [<ffffffff811784bf>] shrink_dcache_parent+0x32f/0x390
[ 5954.064014] [<ffffffff8116d31d>] dentry_unhash+0x3d/0x70
[ 5954.064014] [<ffffffff8116d3b0>] vfs_rmdir+0x60/0xe0
[ 5954.064014] [<ffffffff8116f673>] do_rmdir+0x113/0x130
[ 5954.064014] [<ffffffff8103a03a>] ? sysret_check+0x2e/0x69
[ 5954.064014] [<ffffffff81b19ae9>] ? trace_hardirqs_on_thunk+0x3a/0x3f
[ 5954.064014] [<ffffffff8116f6c5>] sys_unlinkat+0x35/0x40
[ 5954.064014] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1bQuoted 11 lines · Nick Piggin
git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.gitvfs-scale-workingHere is an new set of vfs patches for review, not that there was much interest last time they were posted. It is structured like:
* preparation patches
* introduce new locks to take overdcache_lock, then remove it
* cleaning up and reworking things for new locks
* rcu-walk path walking
* start on some fine grained locking steps
Stress test doing:
single thread 50M inode create
single thread rm -rf
2-way 50M inode create
2-way rm -rf
4-way 50M inode create
4-way rm -rf
8-way 50M inode create
8-way rm -rf
8-way 250M inode create
8-way rm -rf
Failed about 5 minutes into the "4-way rm -rf" (~3 hours into the test) with a CPU stuck spinning on here:
[37372.084012] NMI backtrace for cpu 5 [37372.084012] CPU 5 [37372.084012] Modules linked in: [37372.084012] [37372.084012] Pid: 15214, comm: rm Not tainted 2.6.37-rc4-dgc+ #797 /Bochs [37372.084012] RIP: 0010:[<ffffffff810643c4>] [<ffffffff810643c4>] __ticket_spin_lock+0x14/0x20 [37372.084012] RSP: 0018:ffff880114643c98 EFLAGS: 00000213 [37372.084012] RAX: 0000000000008801 RBX: ffff8800687be6c0 RCX: ffff8800c4eb2688 [37372.084012] RDX: ffff880114643d38 RSI: ffff8800dfd4ea80 RDI: ffff880114643d14 [37372.084012] RBP: ffff880114643c98 R08: 0000000000000003 R09: 0000000000000000 [37372.084012] R10: 0000000000000000 R11: dead000000200200 R12: ffff880114643d14 [37372.084012] R13: ffff880114643cb8 R14: ffff880114643d38 R15: ffff8800687be71c [37372.084012] FS: 00007fd6d7c93700(0000) GS:ffff8800dfd40000(0000) knlGS:0000000000000000 [37372.084012] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [37372.084012] CR2: 0000000000bbd108 CR3: 0000000107146000 CR4: 00000000000006e0 [37372.084012] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [37372.084012] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [37372.084012] Process rm (pid: 15214, threadinfo ffff880114642000, task ffff88011b16f890) [37372.084012] Stack: [37372.084012] ffff880114643ca8 ffffffff81ad044e ffff880114643cf8 ffffffff81167ae7 [37372.084012] 0000000000000000 ffff880114643d38 000000000000000e ffff88011901d800 [37372.084012] ffff8800cdb7cf5c ffff88011901d8e0 0000000000000000 0000000000000000 [37372.084012] Call Trace: [37372.084012] [<ffffffff81ad044e>] _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff81167ae7>] shrink_dentry_list+0x47/0x370 [37372.084012] [<ffffffff81167f5e>] __shrink_dcache_sb+0x14e/0x1e0 [37372.084012] [<ffffffff81168456>] shrink_dcache_parent+0x276/0x2d0 [37372.084012] [<ffffffff81ad044e>] ? _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff8115daa2>] dentry_unhash+0x42/0x80 [37372.084012] [<ffffffff8115db48>] vfs_rmdir+0x68/0x100 [37372.084012] [<ffffffff8115fd93>] do_rmdir+0x113/0x130 [37372.084012] [<ffffffff8114f5ad>] ? filp_close+0x5d/0x90 [37372.084012] [<ffffffff8115fde5>] sys_unlinkat+0x35/0x40 [37372.084012] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1b [37372.084012] Code: c1 c1 41 06 81 e9 dd fe ff ff 90 90 90 90 90 90 90 90 90 90 90 90 90 55 b8 00 01 00 00 48 89 e5 f0 66 0f c1 07 38 e0 74 06 f3 90 <8a> 07 eb f6 c9 c3 66 0f 1f 44 00 00 55 48 89 e5 0f b7 07 38 e0 [37372.084012] Call Trace: [37372.084012] [<ffffffff81ad044e>] _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff81167ae7>] shrink_dentry_list+0x47/0x370 [37372.084012] [<ffffffff81167f5e>] __shrink_dcache_sb+0x14e/0x1e0 [37372.084012] [<ffffffff81168456>] shrink_dcache_parent+0x276/0x2d0 [37372.084012] [<ffffffff81ad044e>] ? _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff8115daa2>] dentry_unhash+0x42/0x80 [37372.084012] [<ffffffff8115db48>] vfs_rmdir+0x68/0x100 [37372.084012] [<ffffffff8115fd93>] do_rmdir+0x113/0x130 [37372.084012] [<ffffffff8114f5ad>] ? filp_close+0x5d/0x90 [37372.084012] [<ffffffff8115fde5>] sys_unlinkat+0x35/0x40 [37372.084012] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1b
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 01/46] Revert "fs: use RCU read side protection in d_validate"
In reply to Nick PigginQuoted 3 lines · Nick Piggin
This reverts commit
3825bdb7ed920845961f32f364454bee5f469abb.Patch is broken, you can't
dget()without holding any locks!
I believe you can - for the same reasons we can take a reference to an inode without holding the inode_lock. That is, as long as the caller already holds an active reference to the dentry, dget() can be used to take another reference without needing the dcache_lock.
Such usage appears to be described in the comment above dget() and there's a BUG_ON() in dget() to catch callers that don't already have an active reference. An example of a valid unlocked dget():d_alloc() does an unlocked dget() to take a reference to the parent dentry which we already are guaranteed to have a reference to.
As to d_validate() - it depends on the caller behaviour as to whether the unlocked dget() is valid or not. From a cursory check of the NCP and SMB readdir caches, both appear to hold an active reference to the dentry it is passing to d_validate(). If that is the case then there is nothing wrong with the way d_validate uses dget(). Can someone with more SMB/NCP expertise than me validate the use of cached dentries?
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Nick Piggin
reviewerQuoted 55 lines · Dave Chinner
Quoted 11 lines · Nick Piggin
git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.gitvfs-scale-workingHere is an new set of vfs patches for review, not that there was much interest last time they were posted. It is structured like:
* preparation patches
* introduce new locks to take overdcache_lock, then remove it
* cleaning up and reworking things for new locks
* rcu-walk path walking
* start on some fine grained locking stepsStress test doing:
single thread 50M inode create
single thread rm -rf
2-way 50M inode create
2-way rm -rf
4-way 50M inode create
4-way rm -rf
8-way 50M inode create
8-way rm -rf
8-way 250M inode create
8-way rm -rfFailed about 5 minutes into the "4-way rm -rf" (~3 hours into the test) with a CPU stuck spinning on here:
[37372.084012] NMI backtrace for cpu 5 [37372.084012] CPU 5 [37372.084012] Modules linked in: [37372.084012] [37372.084012] Pid: 15214, comm: rm Not tainted 2.6.37-rc4-dgc+ #797 /Bochs [37372.084012] RIP: 0010:[<ffffffff810643c4>] [<ffffffff810643c4>] __ticket_spin_lock+0x14/0x20 [37372.084012] RSP: 0018:ffff880114643c98 EFLAGS: 00000213 [37372.084012] RAX: 0000000000008801 RBX: ffff8800687be6c0 RCX: ffff8800c4eb2688 [37372.084012] RDX: ffff880114643d38 RSI: ffff8800dfd4ea80 RDI: ffff880114643d14 [37372.084012] RBP: ffff880114643c98 R08: 0000000000000003 R09: 0000000000000000 [37372.084012] R10: 0000000000000000 R11: dead000000200200 R12: ffff880114643d14 [37372.084012] R13: ffff880114643cb8 R14: ffff880114643d38 R15: ffff8800687be71c [37372.084012] FS: 00007fd6d7c93700(0000) GS:ffff8800dfd40000(0000) knlGS:0000000000000000 [37372.084012] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [37372.084012] CR2: 0000000000bbd108 CR3: 0000000107146000 CR4: 00000000000006e0 [37372.084012] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [37372.084012] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [37372.084012] Process rm (pid: 15214, threadinfo ffff880114642000, task ffff88011b16f890) [37372.084012] Stack: [37372.084012] ffff880114643ca8 ffffffff81ad044e ffff880114643cf8 ffffffff81167ae7 [37372.084012] 0000000000000000 ffff880114643d38 000000000000000e ffff88011901d800 [37372.084012] ffff8800cdb7cf5c ffff88011901d8e0 0000000000000000 0000000000000000 [37372.084012] Call Trace: [37372.084012] [<ffffffff81ad044e>] _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff81167ae7>] shrink_dentry_list+0x47/0x370 [37372.084012] [<ffffffff81167f5e>] __shrink_dcache_sb+0x14e/0x1e0
Quoted 8 lines
[37372.084012] [<ffffffff81168456>] shrink_dcache_parent+0x276/0x2d0 [37372.084012] [<ffffffff81ad044e>] ? _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff8115daa2>] dentry_unhash+0x42/0x80 [37372.084012] [<ffffffff8115db48>] vfs_rmdir+0x68/0x100 [37372.084012] [<ffffffff8115fd93>] do_rmdir+0x113/0x130 [37372.084012] [<ffffffff8114f5ad>] ? filp_close+0x5d/0x90 [37372.084012] [<ffffffff8115fde5>] sys_unlinkat+0x35/0x40 [37372.084012] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1b
OK good, with any luck, that's the same bug.
Is this XFS? Is there any concurrent activity happening on the same dentries? Ie. are the rm -rf threads running on the same directories, or is there any reclaim
happening in the background?
Thanks,
Nick
Re: [PATCH 02/46] fs: d_validate fixes
In reply to Nick PigginQuoted 6 lines · Nick Piggin
d_validatehas been broken for a long time.
kmem_ptr_validatedoes not guarantee that a pointer can be dereferenced if it can go away at any time. Evenrcu_read_lockdoesn't help, because the pointer might be queued in RCU callbacks but not executed yet.
Quoted 7 lines
So the parent cannot be checked, nor the name hashed. The dentry pointer can not be touched until it can be verified under lock. Hashing simply cannot be used.
Instead, verify the parent/child relationship by traversing parent's
d_childlist. It's slow, but only ncpfs and the destaged smbfs care about it, at this point.
I'd drop the previous revert patch and just convert the RCU hash traversal straight to the d_child traversal code you introduce here. This is a much better explanation of why the d_validate mechanism needs to be changed, and the revert is really an unnecessary extra step...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 110 lines · Nick Piggin
Quoted 41 lines · Dave Chinner
[ 5954.061633] BUG: sleeping function called from invalid context at arch/x86/mm/fault.c:1081 [ 5954.062466] in_atomic(): 0, irqs_disabled(): 1, pid: 2927, name: rm [ 5954.063122] 3 locks held by rm/2927: [ 5954.063476] #0: (&sb->s_type->i_mutex_key#12/1){+.+.+.}, at: [<ffffffff8116f5e1>] do_rmdir+0x81/0x130 [ 5954.064014] #1: (&sb->s_type->i_mutex_key#12){+.+.+.}, at: [<ffffffff8116d3a8>] vfs_rmdir+0x58/0xe0 [ 5954.064014] #2: (rcu_read_lock){.+.+..}, at: [<ffffffff811779c0>] shrink_dentry_list+0x0/0x430 [ 5954.064014] irq event stamp: 1484376719 [ 5954.064014] hardirqs last enabled at (1484376719): [<ffffffff810ebf07>] __call_rcu+0xd7/0x1a0 [ 5954.064014] hardirqs last disabled at (1484376718): [<ffffffff810ebe7a>] __call_rcu+0x4a/0x1a0 [ 5954.064014] softirqs last enabled at (1484376586): [<ffffffff8108b911>] __do_softirq+0x161/0x270 [ 5954.064014] softirqs last disabled at (1484376581): [<ffffffff8103af1c>] call_softirq+0x1c/0x50 [ 5954.064014] Pid: 2927, comm: rm Not tainted 2.6.37-rc4-dgc+ #794 [ 5954.064014] Call Trace: [ 5954.064014] [<ffffffff810b95b0>] ? print_irqtrace_events+0xd0/0xe0 [ 5954.064014] [<ffffffff81076455>] __might_sleep+0xf5/0x130 [ 5954.064014] [<ffffffff81b1e603>] do_page_fault+0x103/0x4f0 [ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0 [ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0 [ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0 [ 5954.064014] [<ffffffff81b19b28>] ? trace_hardirqs_off_thunk+0x3a/0x3c [ 5954.064014] [<ffffffff810b8e20>] ? usage_match+0x0/0x20 [ 5954.064014] [<ffffffff81b1af25>] page_fault+0x25/0x30 [ 5954.064014] [<ffffffff810b8e20>] ? usage_match+0x0/0x20 [ 5954.064014] [<ffffffff810ba1c8>] ? __bfs+0xc8/0x260 [ 5954.064014] [<ffffffff810ba123>] ? __bfs+0x23/0x260 [ 5954.064014] [<ffffffff810ba4d2>] find_usage_backwards+0x42/0x80 [ 5954.064014] [<ffffffff810bcec4>] check_usage_backwards+0x64/0xf0 [ 5954.064014] [<ffffffff8104796f>] ? save_stack_trace+0x2f/0x50 [ 5954.064014] [<ffffffff810bce60>] ? check_usage_backwards+0x0/0xf0 [ 5954.064014] [<ffffffff810bd9a9>] mark_lock+0x1a9/0x440 [ 5954.064014] [<ffffffff810be989>] __lock_acquire+0x5a9/0x14b0 [ 5954.064014] [<ffffffff810be716>] ? __lock_acquire+0x336/0x14b0 [ 5954.064014] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0 [ 5954.064014] [<ffffffff810bf944>] lock_acquire+0xb4/0x140 [ 5954.064014] [<ffffffff81177a1c>] ? shrink_dentry_list+0x5c/0x430 [ 5954.064014] [<ffffffff81b19d86>] _raw_spin_lock+0x36/0x70 [ 5954.064014] [<ffffffff81177a1c>] ? shrink_dentry_list+0x5c/0x430 [ 5954.064014] [<ffffffff81177a1c>] shrink_dentry_list+0x5c/0x430 [ 5954.064014] [<ffffffff811779c0>] ? shrink_dentry_list+0x0/0x430 [ 5954.064014] [<ffffffff816b9c7e>] ? do_raw_spin_unlock+0x5e/0xb0 [ 5954.064014] [<ffffffff81177f2d>] __shrink_dcache_sb+0x13d/0x1c0Quoted 8 lines
[ 5954.064014] [<ffffffff811784bf>] shrink_dcache_parent+0x32f/0x390 [ 5954.064014] [<ffffffff8116d31d>] dentry_unhash+0x3d/0x70 [ 5954.064014] [<ffffffff8116d3b0>] vfs_rmdir+0x60/0xe0 [ 5954.064014] [<ffffffff8116f673>] do_rmdir+0x113/0x130 [ 5954.064014] [<ffffffff8103a03a>] ? sysret_check+0x2e/0x69 [ 5954.064014] [<ffffffff81b19ae9>] ? trace_hardirqs_on_thunk+0x3a/0x3f [ 5954.064014] [<ffffffff8116f6c5>] sys_unlinkat+0x35/0x40 [ 5954.064014] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1bSeems that lockdep exploded.
Quoted 48 lines
[ 5954.092916] BUG: unable to handle kernel NULL pointer dereference at (null) [ 5954.093806] IP: [<ffffffff810ba1c8>] __bfs+0xc8/0x260 [ 5954.094331] PGD 1084e5067 PUD 102368067 PMD 0 [ 5954.094830] Oops: 0000 [#1] SMP [ 5954.095194] last sysfs file: /sys/devices/system/cpu/online [ 5954.095760] CPU 6 [ 5954.095954] Modules linked in: [ 5954.096319] [ 5954.096483] Pid: 2927, comm: rm Not tainted 2.6.37-rc4-dgc+ #794 /Bochs [ 5954.096665] RIP: 0010:[<ffffffff810ba1c8>] [<ffffffff810ba1c8>] __bfs+0xc8/0x260 [ 5954.096665] RSP: 0018:ffff8801175539a8 EFLAGS: 00010046 [ 5954.096665] RAX: ffffffff8267d980 RBX: ffffffff8267d980 RCX: ffff880117553a48 [ 5954.096665] RDX: ffff8801175539d0 RSI: 0000000000000000 RDI: ffff880117553a48 [ 5954.096665] RBP: ffff880117553a08 R08: 0000000000000000 R09: 0000000000000000 [ 5954.096665] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000 [ 5954.096665] R13: ffffffff810b8e20 R14: ffff880117553a90 R15: 0000000000000000 [ 5954.096665] FS: 00007f4594cf3700(0000) GS:ffff8800dfa00000(0000) knlGS:0000000000000000 [ 5954.096665] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 5954.096665] CR2: 00007f2f21e89c60 CR3: 0000000110b0f000 CR4: 00000000000006e0 [ 5954.096665] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 5954.096665] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 5954.096665] Process rm (pid: 2927, threadinfo ffff880117552000, task ffff88010ff10b00) [ 5954.096665] Stack: [ 5954.096665] ffffffff8267d868 00007fffa02d1428 ffff8800ffffffff ffff880100000000 [ 5954.096665] 000000000000b720 ffff880117553a48 ffffffff8267d868 ffff880117553a48 [ 5954.096665] 0000000000000000 ffff88010ff10b00 0000000000000000 ffffffff81dacba0 [ 5954.096665] Call Trace: [ 5954.096665] [<ffffffff810ba4d2>] find_usage_backwards+0x42/0x80 [ 5954.096665] [<ffffffff810bcec4>] check_usage_backwards+0x64/0xf0 [ 5954.096665] [<ffffffff8104796f>] ? save_stack_trace+0x2f/0x50 [ 5954.096665] [<ffffffff810bce60>] ? check_usage_backwards+0x0/0xf0 [ 5954.096665] [<ffffffff810bd9a9>] mark_lock+0x1a9/0x440 [ 5954.096665] [<ffffffff810be989>] __lock_acquire+0x5a9/0x14b0 [ 5954.096665] [<ffffffff810be716>] ? __lock_acquire+0x336/0x14b0 [ 5954.096665] [<ffffffff810645b8>] ? pvclock_clocksource_read+0x58/0xd0 [ 5954.096665] [<ffffffff810bf944>] lock_acquire+0xb4/0x140 [ 5954.096665] [<ffffffff81177a1c>] ? shrink_dentry_list+0x5c/0x430 [ 5954.096665] [<ffffffff81b19d86>] _raw_spin_lock+0x36/0x70 [ 5954.096665] [<ffffffff81177a1c>] ? shrink_dentry_list+0x5c/0x430 [ 5954.096665] [<ffffffff81177a1c>] shrink_dentry_list+0x5c/0x430 [ 5954.096665] [<ffffffff811779c0>] ? shrink_dentry_list+0x0/0x430 [ 5954.096665] [<ffffffff816b9c7e>] ? do_raw_spin_unlock+0x5e/0xb0 [ 5954.096665] [<ffffffff81177f2d>] __shrink_dcache_sb+0x13d/0x1c0 [ 5954.096665] [<ffffffff811784bf>] shrink_dcache_parent+0x32f/0x390 [ 5954.096665] [<ffffffff8116d31d>] dentry_unhash+0x3d/0x70 [ 5954.096665] [<ffffffff8116d3b0>] vfs_rmdir+0x60/0xe0 [ 5954.096665] [<ffffffff8116f673>] do_rmdir+0x113/0x130 [ 5954.096665] [<ffffffff8103a03a>] ? sysret_check+0x2e/0x69Quoted 8 lines
[ 5954.096665] [<ffffffff81b19ae9>] ? trace_hardirqs_on_thunk+0x3a/0x3f [ 5954.096665] [<ffffffff8116f6c5>] sys_unlinkat+0x35/0x40 [ 5954.096665] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1b [ 5954.096665] Code: 0a 89 05 dc 0f a8 01 48 8b 41 10 48 85 c0 0f 84 1f 01 00 00 48 8d 98 70 01 00 00 48 05 80 01 00 00 45 85 c0 48 0f 44 d8 4c 8b 3b <49> 8b 07 49 39 [ 5954.096665] RIP [<ffffffff810ba1c8>] __bfs+0xc8/0x260 [ 5954.096665] RSP <ffff8801175539a8> [ 5954.096665] CR2: 0000000000000000 [ 5954.127991] ---[ end trace 85a6727c2d4e3d90 ]---
Quoted 1 line
So vfs-scale-working branch may not be entirely in the clear, seeing
Ah, may have been a stupid little bug. The list entry check was being done and then the pointer reloaded to be used.
What does the asm for shrink_dentry_list look like (before this patch)?
Thanks,
Nick
fs/dcache.c +4 -4
@@ -657,10 +657,10 @@ static void shrink_dentry_list(struct listruct dentry *dentry;rcu_read_lock (); -while (!list_empty (list)) { - dentry = list_entry(list->prev, struct dentry, d_lru); - -/* Don't need RCU dereference because we recheck under lock */ +for (;;) { + dentry = list_entry_rcu(list->prev, struct dentry, d_lru); +if (&dentry->d_lru == list) +break ;spin_lock (&dentry->d_lock); if (dentry != list_entry(list->prev, struct dentry, d_lru)) {spin_unlock (&dentry->d_lock);
Quoted 65 lines · Nick Piggin
Quoted 55 lines · Dave Chinner
Quoted 11 lines · Nick Piggin
git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.gitvfs-scale-workingHere is an new set of vfs patches for review, not that there was much interest last time they were posted. It is structured like:
* preparation patches
* introduce new locks to take overdcache_lock, then remove it
* cleaning up and reworking things for new locks
* rcu-walk path walking
* start on some fine grained locking stepsStress test doing:
single thread 50M inode create
single thread rm -rf
2-way 50M inode create
2-way rm -rf
4-way 50M inode create
4-way rm -rf
8-way 50M inode create
8-way rm -rf
8-way 250M inode create
8-way rm -rfFailed about 5 minutes into the "4-way rm -rf" (~3 hours into the test) with a CPU stuck spinning on here:
[37372.084012] NMI backtrace for cpu 5 [37372.084012] CPU 5 [37372.084012] Modules linked in: [37372.084012] [37372.084012] Pid: 15214, comm: rm Not tainted 2.6.37-rc4-dgc+ #797 /Bochs [37372.084012] RIP: 0010:[<ffffffff810643c4>] [<ffffffff810643c4>] __ticket_spin_lock+0x14/0x20 [37372.084012] RSP: 0018:ffff880114643c98 EFLAGS: 00000213 [37372.084012] RAX: 0000000000008801 RBX: ffff8800687be6c0 RCX: ffff8800c4eb2688 [37372.084012] RDX: ffff880114643d38 RSI: ffff8800dfd4ea80 RDI: ffff880114643d14 [37372.084012] RBP: ffff880114643c98 R08: 0000000000000003 R09: 0000000000000000 [37372.084012] R10: 0000000000000000 R11: dead000000200200 R12: ffff880114643d14 [37372.084012] R13: ffff880114643cb8 R14: ffff880114643d38 R15: ffff8800687be71c [37372.084012] FS: 00007fd6d7c93700(0000) GS:ffff8800dfd40000(0000) knlGS:0000000000000000 [37372.084012] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [37372.084012] CR2: 0000000000bbd108 CR3: 0000000107146000 CR4: 00000000000006e0 [37372.084012] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [37372.084012] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [37372.084012] Process rm (pid: 15214, threadinfo ffff880114642000, task ffff88011b16f890) [37372.084012] Stack: [37372.084012] ffff880114643ca8 ffffffff81ad044e ffff880114643cf8 ffffffff81167ae7 [37372.084012] 0000000000000000 ffff880114643d38 000000000000000e ffff88011901d800 [37372.084012] ffff8800cdb7cf5c ffff88011901d8e0 0000000000000000 0000000000000000 [37372.084012] Call Trace: [37372.084012] [<ffffffff81ad044e>] _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff81167ae7>] shrink_dentry_list+0x47/0x370 [37372.084012] [<ffffffff81167f5e>] __shrink_dcache_sb+0x14e/0x1e0Quoted 8 lines
[37372.084012] [<ffffffff81168456>] shrink_dcache_parent+0x276/0x2d0 [37372.084012] [<ffffffff81ad044e>] ? _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff8115daa2>] dentry_unhash+0x42/0x80 [37372.084012] [<ffffffff8115db48>] vfs_rmdir+0x68/0x100 [37372.084012] [<ffffffff8115fd93>] do_rmdir+0x113/0x130 [37372.084012] [<ffffffff8114f5ad>] ? filp_close+0x5d/0x90 [37372.084012] [<ffffffff8115fde5>] sys_unlinkat+0x35/0x40 [37372.084012] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1b
Quoted 3 lines
OK good, with any luck, that's the same bug.
Is this XFS?
Yes.
Quoted 1 line
Is there any concurrent activity happening on the same dentries?
Not from an application perspective.
Quoted 1 line
Ie. are the rm -rf threads running on the same directories,
No, each thread operating on a different directory.
Quoted 1 line
or is there any reclaim happening in the background?
IIRC, kswapd was consuming about 5-10% of a CPU during parallel unlink tests. Mainly reclaiming XFS inodes, I think, but there may be dentry cache reclaim going as well.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 78 lines · Dave Chinner
Quoted 65 lines · Nick Piggin
Quoted 55 lines · Dave Chinner
Quoted 11 lines · Nick Piggin
git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.gitvfs-scale-workingHere is an new set of vfs patches for review, not that there was much interest last time they were posted. It is structured like:
* preparation patches
* introduce new locks to take overdcache_lock, then remove it
* cleaning up and reworking things for new locks
* rcu-walk path walking
* start on some fine grained locking stepsStress test doing:
single thread 50M inode create
single thread rm -rf
2-way 50M inode create
2-way rm -rf
4-way 50M inode create
4-way rm -rf
8-way 50M inode create
8-way rm -rf
8-way 250M inode create
8-way rm -rfFailed about 5 minutes into the "4-way rm -rf" (~3 hours into the test) with a CPU stuck spinning on here:
[37372.084012] NMI backtrace for cpu 5 [37372.084012] CPU 5 [37372.084012] Modules linked in: [37372.084012] [37372.084012] Pid: 15214, comm: rm Not tainted 2.6.37-rc4-dgc+ #797 /Bochs [37372.084012] RIP: 0010:[<ffffffff810643c4>] [<ffffffff810643c4>] __ticket_spin_lock+0x14/0x20 [37372.084012] RSP: 0018:ffff880114643c98 EFLAGS: 00000213 [37372.084012] RAX: 0000000000008801 RBX: ffff8800687be6c0 RCX: ffff8800c4eb2688 [37372.084012] RDX: ffff880114643d38 RSI: ffff8800dfd4ea80 RDI: ffff880114643d14 [37372.084012] RBP: ffff880114643c98 R08: 0000000000000003 R09: 0000000000000000 [37372.084012] R10: 0000000000000000 R11: dead000000200200 R12: ffff880114643d14 [37372.084012] R13: ffff880114643cb8 R14: ffff880114643d38 R15: ffff8800687be71c [37372.084012] FS: 00007fd6d7c93700(0000) GS:ffff8800dfd40000(0000) knlGS:0000000000000000 [37372.084012] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [37372.084012] CR2: 0000000000bbd108 CR3: 0000000107146000 CR4: 00000000000006e0 [37372.084012] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [37372.084012] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [37372.084012] Process rm (pid: 15214, threadinfo ffff880114642000, task ffff88011b16f890) [37372.084012] Stack: [37372.084012] ffff880114643ca8 ffffffff81ad044e ffff880114643cf8 ffffffff81167ae7 [37372.084012] 0000000000000000 ffff880114643d38 000000000000000e ffff88011901d800 [37372.084012] ffff8800cdb7cf5c ffff88011901d8e0 0000000000000000 0000000000000000 [37372.084012] Call Trace: [37372.084012] [<ffffffff81ad044e>] _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff81167ae7>] shrink_dentry_list+0x47/0x370 [37372.084012] [<ffffffff81167f5e>] __shrink_dcache_sb+0x14e/0x1e0Quoted 8 lines
[37372.084012] [<ffffffff81168456>] shrink_dcache_parent+0x276/0x2d0 [37372.084012] [<ffffffff81ad044e>] ? _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff8115daa2>] dentry_unhash+0x42/0x80 [37372.084012] [<ffffffff8115db48>] vfs_rmdir+0x68/0x100 [37372.084012] [<ffffffff8115fd93>] do_rmdir+0x113/0x130 [37372.084012] [<ffffffff8114f5ad>] ? filp_close+0x5d/0x90 [37372.084012] [<ffffffff8115fde5>] sys_unlinkat+0x35/0x40 [37372.084012] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1bQuoted 3 lines
OK good, with any luck, that's the same bug.
Is this XFS?
Yes.
Quoted 1 line
Is there any concurrent activity happening on the same dentries?
Not from an application perspective.
Quoted 1 line
Ie. are the rm -rf threads running on the same directories,
Quoted 7 lines
No, each thread operating on a different directory.
Quoted 1 line
or is there any reclaim happening in the background?
IIRC, kswapd was consuming about 5-10% of a CPU during parallel unlink tests. Mainly reclaiming XFS inodes, I think, but there may be dentry cache reclaim going as well.
Turns out that the kswapd peaks are upwards of 50% of a CPU for a few seconds, then idle for 10-15s. Typical perf top output of kswapd while it is active during unlinks is:
samples pcnt function DSO
_______ _____ ___________________________ _________________
17168.00 10.2% __call_rcu [kernel.kallsyms]
13223.00 7.8% kmem_cache_free [kernel.kallsyms]
12917.00 7.6% down_write [kernel.kallsyms]
12665.00 7.5% xfs_iunlock [kernel.kallsyms]
10493.00 6.2% xfs_reclaim_inode_grab [kernel.kallsyms]
9314.00 5.5% __lookup_tag [kernel.kallsyms]
9040.00 5.4% radix_tree_delete [kernel.kallsyms]
8694.00 5.1% is_bad_inode [kernel.kallsyms]
7639.00 4.5% __ticket_spin_lock [kernel.kallsyms]
6821.00 4.0% _raw_spin_unlock_irqrestore [kernel.kallsyms]
5484.00 3.2% __d_drop [kernel.kallsyms]
5114.00 3.0% xfs_reclaim_inode [kernel.kallsyms]
4626.00 2.7% __rcu_process_callbacks [kernel.kallsyms]
3556.00 2.1% up_write [kernel.kallsyms]
3206.00 1.9% _cond_resched [kernel.kallsyms]
3129.00 1.9% xfs_qm_dqdetach [kernel.kallsyms]
2327.00 1.4% radix_tree_tag_clear [kernel.kallsyms]
2327.00 1.4% call_rcu_sched [kernel.kallsyms]
2262.00 1.3% __ticket_spin_unlock [kernel.kallsyms]
2215.00 1.3% xfs_ilock [kernel.kallsyms]
2200.00 1.3% radix_tree_gang_lookup_tag [kernel.kallsyms]
1982.00 1.2% xfs_reclaim_inodes_ag [kernel.kallsyms]
1736.00 1.0% xfs_trans_unlocked_item [kernel.kallsyms]
1707.00 1.0% __ticket_spin_trylock [kernel.kallsyms]
1688.00 1.0% xfs_perag_get_tag [kernel.kallsyms]
1660.00 1.0% flat_send_IPI_mask [kernel.kallsyms]
1538.00 0.9% xfs_inode_item_destroy [kernel.kallsyms]
1312.00 0.8% __shrink_dcache_sb [kernel.kallsyms]
940.00 0.6% xfs_perag_put [kernel.kallsyms]So there is some dentry cache reclaim going on.
FWIW, it appears there is quite a lot of RCU freeing overhead (~15% more CPU time) in the work kswapd is doing during these unlinks, too. I just had a look at kswapd when a 8-way create is running - it's running at 50-60% of a cpu for seconds at a time. I caught this while it was doing pure XFS inode cache reclaim (~10s sample, kswapd reclaimed ~1M inodes):
samples pcnt function DSO
_______ _____ ___________________________ _________________
27171.00 9.0% __call_rcu [kernel.kallsyms]
21491.00 7.1% down_write [kernel.kallsyms]
20916.00 6.9% xfs_reclaim_inode [kernel.kallsyms]
20313.00 6.7% radix_tree_delete [kernel.kallsyms]
15828.00 5.3% kmem_cache_free [kernel.kallsyms]
15819.00 5.2% xfs_idestroy_fork [kernel.kallsyms]
14893.00 4.9% is_bad_inode [kernel.kallsyms]
14666.00 4.9% _raw_spin_unlock_irqrestore [kernel.kallsyms]
14191.00 4.7% xfs_reclaim_inode_grab [kernel.kallsyms]
14105.00 4.7% xfs_iunlock [kernel.kallsyms]
10916.00 3.6% __ticket_spin_lock [kernel.kallsyms]
10125.00 3.4% xfs_iflush_cluster [kernel.kallsyms]
8221.00 2.7% xfs_qm_dqdetach [kernel.kallsyms]
7639.00 2.5% xfs_trans_unlocked_item [kernel.kallsyms]
7028.00 2.3% xfs_synchronize_times [kernel.kallsyms]
6974.00 2.3% up_write [kernel.kallsyms]
5870.00 1.9% call_rcu_sched [kernel.kallsyms]
5634.00 1.9% _cond_resched [kernel.kallsyms]Which is showing a similar amount of RCU overhead as the unlink as above. And this while it was doing dentry cache reclaim (~10s sample):
35921.00 15.7% __d_drop [kernel.kallsyms]
30056.00 13.1% __ticket_spin_trylock [kernel.kallsyms]
29066.00 12.7% __ticket_spin_lock [kernel.kallsyms]
19043.00 8.3% __call_rcu [kernel.kallsyms]
10098.00 4.4% iput [kernel.kallsyms]
7013.00 3.1% __shrink_dcache_sb [kernel.kallsyms]
6774.00 3.0% __percpu_counter_add [kernel.kallsyms]
6708.00 2.9% radix_tree_tag_set [kernel.kallsyms]
5362.00 2.3% xfs_inactive [kernel.kallsyms]
5130.00 2.2% __ticket_spin_unlock [kernel.kallsyms]
4884.00 2.1% call_rcu_sched [kernel.kallsyms]
4621.00 2.0% dentry_lru_del [kernel.kallsyms]
3735.00 1.6% bit_waitqueue [kernel.kallsyms]
3727.00 1.6% dentry_iput [kernel.kallsyms]
3473.00 1.5% shrink_icache_memory [kernel.kallsyms]
3279.00 1.4% kfree [kernel.kallsyms]
3101.00 1.4% xfs_perag_get [kernel.kallsyms]
2516.00 1.1% kmem_cache_free [kernel.kallsyms]
2272.00 1.0% shrink_dentry_list [kernel.kallsyms]I've never really seen any signficant dentry cache reclaim overhead in profiles of these workloads before, so this was a bit of a surprise....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 02/46] fs: d_validate fixes
In reply to Dave ChinnerQuoted 15 lines · Dave Chinner
Quoted 6 lines · Nick Piggin
d_validatehas been broken for a long time.
kmem_ptr_validatedoes not guarantee that a pointer can be dereferenced if it can go away at any time. Evenrcu_read_lockdoesn't help, because the pointer might be queued in RCU callbacks but not executed yet.Quoted 7 lines
So the parent cannot be checked, nor the name hashed. The dentry pointer can not be touched until it can be verified under lock. Hashing simply cannot be used.
Instead, verify the parent/child relationship by traversing parent's
d_childlist. It's slow, but only ncpfs and the destaged smbfs care about it, at this point.
Quoted 5 lines
I'd drop the previous revert patch and just convert the RCU hash traversal straight to the
d_childtraversal code you introduce here. This is a much better explanation of why thed_validatemechanism needs to be changed, and the revert is really an unnecessary extra step...
Has to be backported, though. Patch that is to be reverted obviously adds more brokenness and is a good example that you cannot dget() under rcu read protection even if the rest of the surrounding function is bugfree. I wouldn't have thought it's a big deal.
Quoted 73 lines · Dave Chinner
Quoted 72 lines · Dave Chinner
Quoted 65 lines · Nick Piggin
Quoted 55 lines · Dave Chinner
Quoted 11 lines · Nick Piggin
git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.gitvfs-scale-workingHere is an new set of vfs patches for review, not that there was much interest last time they were posted. It is structured like:
* preparation patches
* introduce new locks to take overdcache_lock, then remove it
* cleaning up and reworking things for new locks
* rcu-walk path walking
* start on some fine grained locking stepsStress test doing:
single thread 50M inode create
single thread rm -rf
2-way 50M inode create
2-way rm -rf
4-way 50M inode create
4-way rm -rf
8-way 50M inode create
8-way rm -rf
8-way 250M inode create
8-way rm -rfFailed about 5 minutes into the "4-way rm -rf" (~3 hours into the test) with a CPU stuck spinning on here:
[37372.084012] NMI backtrace for cpu 5 [37372.084012] CPU 5 [37372.084012] Modules linked in: [37372.084012] [37372.084012] Pid: 15214, comm: rm Not tainted 2.6.37-rc4-dgc+ #797 /Bochs [37372.084012] RIP: 0010:[<ffffffff810643c4>] [<ffffffff810643c4>] __ticket_spin_lock+0x14/0x20 [37372.084012] RSP: 0018:ffff880114643c98 EFLAGS: 00000213 [37372.084012] RAX: 0000000000008801 RBX: ffff8800687be6c0 RCX: ffff8800c4eb2688 [37372.084012] RDX: ffff880114643d38 RSI: ffff8800dfd4ea80 RDI: ffff880114643d14 [37372.084012] RBP: ffff880114643c98 R08: 0000000000000003 R09: 0000000000000000 [37372.084012] R10: 0000000000000000 R11: dead000000200200 R12: ffff880114643d14 [37372.084012] R13: ffff880114643cb8 R14: ffff880114643d38 R15: ffff8800687be71c [37372.084012] FS: 00007fd6d7c93700(0000) GS:ffff8800dfd40000(0000) knlGS:0000000000000000 [37372.084012] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [37372.084012] CR2: 0000000000bbd108 CR3: 0000000107146000 CR4: 00000000000006e0 [37372.084012] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [37372.084012] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [37372.084012] Process rm (pid: 15214, threadinfo ffff880114642000, task ffff88011b16f890) [37372.084012] Stack: [37372.084012] ffff880114643ca8 ffffffff81ad044e ffff880114643cf8 ffffffff81167ae7 [37372.084012] 0000000000000000 ffff880114643d38 000000000000000e ffff88011901d800 [37372.084012] ffff8800cdb7cf5c ffff88011901d8e0 0000000000000000 0000000000000000 [37372.084012] Call Trace: [37372.084012] [<ffffffff81ad044e>] _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff81167ae7>] shrink_dentry_list+0x47/0x370 [37372.084012] [<ffffffff81167f5e>] __shrink_dcache_sb+0x14e/0x1e0Quoted 8 lines
[37372.084012] [<ffffffff81168456>] shrink_dcache_parent+0x276/0x2d0 [37372.084012] [<ffffffff81ad044e>] ? _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff8115daa2>] dentry_unhash+0x42/0x80 [37372.084012] [<ffffffff8115db48>] vfs_rmdir+0x68/0x100 [37372.084012] [<ffffffff8115fd93>] do_rmdir+0x113/0x130 [37372.084012] [<ffffffff8114f5ad>] ? filp_close+0x5d/0x90 [37372.084012] [<ffffffff8115fde5>] sys_unlinkat+0x35/0x40 [37372.084012] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1bQuoted 3 lines
OK good, with any luck, that's the same bug.
Is this XFS?
Yes.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Is there any concurrent activity happening on the same dentries?
Not from an application perspective.
Quoted 1 line
Ie. are the rm -rf threads running on the same directories,
No, each thread operating on a different directory.
This is probably fixed by the same patch as the lockdep splat trace.
Quoted 96 lines
Quoted 5 lines
Quoted 1 line
or is there any reclaim happening in the background?
IIRC, kswapd was consuming about 5-10% of a CPU during parallel unlink tests. Mainly reclaiming XFS inodes, I think, but there may be dentry cache reclaim going as well.
Turns out that the kswapd peaks are upwards of 50% of a CPU for a few seconds, then idle for 10-15s. Typical perf top output of kswapd while it is active during unlinks is:
samples pcnt function DSO _______ _____ ___________________________ _________________ 17168.00 10.2% __call_rcu [kernel.kallsyms] 13223.00 7.8% kmem_cache_free [kernel.kallsyms] 12917.00 7.6% down_write [kernel.kallsyms] 12665.00 7.5% xfs_iunlock [kernel.kallsyms] 10493.00 6.2% xfs_reclaim_inode_grab [kernel.kallsyms] 9314.00 5.5% __lookup_tag [kernel.kallsyms] 9040.00 5.4% radix_tree_delete [kernel.kallsyms] 8694.00 5.1% is_bad_inode [kernel.kallsyms] 7639.00 4.5% __ticket_spin_lock [kernel.kallsyms] 6821.00 4.0% _raw_spin_unlock_irqrestore [kernel.kallsyms] 5484.00 3.2% __d_drop [kernel.kallsyms] 5114.00 3.0% xfs_reclaim_inode [kernel.kallsyms] 4626.00 2.7% __rcu_process_callbacks [kernel.kallsyms] 3556.00 2.1% up_write [kernel.kallsyms] 3206.00 1.9% _cond_resched [kernel.kallsyms] 3129.00 1.9% xfs_qm_dqdetach [kernel.kallsyms] 2327.00 1.4% radix_tree_tag_clear [kernel.kallsyms] 2327.00 1.4% call_rcu_sched [kernel.kallsyms] 2262.00 1.3% __ticket_spin_unlock [kernel.kallsyms] 2215.00 1.3% xfs_ilock [kernel.kallsyms] 2200.00 1.3% radix_tree_gang_lookup_tag [kernel.kallsyms] 1982.00 1.2% xfs_reclaim_inodes_ag [kernel.kallsyms] 1736.00 1.0% xfs_trans_unlocked_item [kernel.kallsyms] 1707.00 1.0% __ticket_spin_trylock [kernel.kallsyms] 1688.00 1.0% xfs_perag_get_tag [kernel.kallsyms] 1660.00 1.0% flat_send_IPI_mask [kernel.kallsyms] 1538.00 0.9% xfs_inode_item_destroy [kernel.kallsyms] 1312.00 0.8% __shrink_dcache_sb [kernel.kallsyms] 940.00 0.6% xfs_perag_put [kernel.kallsyms]So there is some dentry cache reclaim going on.
FWIW, it appears there is quite a lot of RCU freeing overhead (~15% more CPU time) in the work kswapd is doing during these unlinks, too. I just had a look at kswapd when a 8-way create is running - it's running at 50-60% of a cpu for seconds at a time. I caught this while it was doing pure XFS inode cache reclaim (~10s sample, kswapd reclaimed ~1M inodes):
samples pcnt function DSO _______ _____ ___________________________ _________________ 27171.00 9.0% __call_rcu [kernel.kallsyms] 21491.00 7.1% down_write [kernel.kallsyms] 20916.00 6.9% xfs_reclaim_inode [kernel.kallsyms] 20313.00 6.7% radix_tree_delete [kernel.kallsyms] 15828.00 5.3% kmem_cache_free [kernel.kallsyms] 15819.00 5.2% xfs_idestroy_fork [kernel.kallsyms] 14893.00 4.9% is_bad_inode [kernel.kallsyms] 14666.00 4.9% _raw_spin_unlock_irqrestore [kernel.kallsyms] 14191.00 4.7% xfs_reclaim_inode_grab [kernel.kallsyms] 14105.00 4.7% xfs_iunlock [kernel.kallsyms] 10916.00 3.6% __ticket_spin_lock [kernel.kallsyms] 10125.00 3.4% xfs_iflush_cluster [kernel.kallsyms] 8221.00 2.7% xfs_qm_dqdetach [kernel.kallsyms] 7639.00 2.5% xfs_trans_unlocked_item [kernel.kallsyms] 7028.00 2.3% xfs_synchronize_times [kernel.kallsyms] 6974.00 2.3% up_write [kernel.kallsyms] 5870.00 1.9% call_rcu_sched [kernel.kallsyms] 5634.00 1.9% _cond_resched [kernel.kallsyms]Which is showing a similar amount of RCU overhead as the unlink as above. And this while it was doing dentry cache reclaim (~10s sample):
35921.00 15.7% __d_drop [kernel.kallsyms] 30056.00 13.1% __ticket_spin_trylock [kernel.kallsyms] 29066.00 12.7% __ticket_spin_lock [kernel.kallsyms] 19043.00 8.3% __call_rcu [kernel.kallsyms] 10098.00 4.4% iput [kernel.kallsyms] 7013.00 3.1% __shrink_dcache_sb [kernel.kallsyms] 6774.00 3.0% __percpu_counter_add [kernel.kallsyms] 6708.00 2.9% radix_tree_tag_set [kernel.kallsyms] 5362.00 2.3% xfs_inactive [kernel.kallsyms] 5130.00 2.2% __ticket_spin_unlock [kernel.kallsyms] 4884.00 2.1% call_rcu_sched [kernel.kallsyms] 4621.00 2.0% dentry_lru_del [kernel.kallsyms] 3735.00 1.6% bit_waitqueue [kernel.kallsyms] 3727.00 1.6% dentry_iput [kernel.kallsyms] 3473.00 1.5% shrink_icache_memory [kernel.kallsyms] 3279.00 1.4% kfree [kernel.kallsyms] 3101.00 1.4% xfs_perag_get [kernel.kallsyms] 2516.00 1.1% kmem_cache_free [kernel.kallsyms] 2272.00 1.0% shrink_dentry_list [kernel.kallsyms]
Quoted 3 lines
I've never really seen any signficant dentry cache reclaim overhead in profiles of these workloads before, so this was a bit of a surprise....
call_rcu shouldn't be doing much, except for disabling irqs and linking the object into the list. I have a patch somewhere to reduce the irq disable overhead a bit, but it really shouldn't be doing a lot of work.
Sometimes you find that touching the rcu head field needs to get a cacheline exclusive, so a bit of work gets transferred there....
But it may also be something going a bit wrong in RCU. I blew it up once already, after the files_lock splitup that enabled all CPUs to create and destroy files :)
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/46] Revert "fs: use RCU read side protection in d_validate"
In reply to Dave ChinnerQuoted 11 lines · Dave Chinner
Quoted 3 lines · Nick Piggin
This reverts commit
3825bdb7ed920845961f32f364454bee5f469abb.Patch is broken, you can't
dget()without holding any locks!I believe you can - for the same reasons we can take a reference to an inode without holding the
inode_lock. That is, as long as the caller already holds an active reference to the dentry,dget()can be used to take another reference without needing thedcache_lock.
Quoted 5 lines
Such usage appears to be described in the comment above
dget()and there's aBUG_ON()indget()to catch callers that don't already have an active reference. An example of a valid unlockeddget():d_alloc()does an unlockeddget()to take a reference to the parent dentry whichn we already are guaranteed to have a reference to.
Of course you can dget if you already have a reference :)
Quoted 4 lines
As to
d_validate()- it depends on the caller behaviour as to whether the unlockeddget()is valid or not. From a cursory check of the NCP and SMB readdir caches, both appear to hold an active reference to the dentry it is passing tod_validate().
I don't see where? Can you point to where the refcount is taken? AFAIKS it drops the reference 3 lines after it puts the pointer into cache.
Quoted 4 lines
If that is
the case then there is nothing wrong with the wayd_validateusesdget(). Can someone with more SMB/NCP expertise than me validate the use of cached dentries?
Then why would it have to use d_validate if it has a reference? That is supposed to be for an "untrusted" pointer (which is why it had all the crazy checks that it's in kmem and in the right slab etc).
Re: [PATCH 01/46] Revert "fs: use RCU read side protection in d_validate"
Quoted 12 lines · Nick Piggin
Quoted 11 lines · Dave Chinner
Quoted 3 lines · Nick Piggin
This reverts commit
3825bdb7ed920845961f32f364454bee5f469abb.Patch is broken, you can't
dget()without holding any locks!I believe you can - for the same reasons we can take a reference to an inode without holding the
inode_lock. That is, as long as the caller already holds an active reference to the dentry,dget()can be used to take another reference without needing thedcache_lock.
Quoted 7 lines
Quoted 5 lines
Such usage appears to be described in the comment above
dget()and there's aBUG_ON()indget()to catch callers that don't already have an active reference. An example of a valid unlockeddget():d_alloc()does an unlockeddget()to take a reference to the parent dentry whichn we already are guaranteed to have a reference to.Of course you can dget if you already have a reference :)
Right, so the commit message is wrong. Can you update it to tell us why dget() can't be used there - the commit message from the second patch explained it far better....
Quoted 8 lines
Quoted 4 lines
As to
d_validate()- it depends on the caller behaviour as to whether the unlockeddget()is valid or not. From a cursory check of the NCP and SMB readdir caches, both appear to hold an active reference to the dentry it is passing tod_validate().I don't see where? Can you point to where the refcount is taken? AFAIKS it drops the reference 3 lines after it puts the pointer into cache.
Yeah, you're right, I missed that one - I spent more tiem checking the validation part of the code than the initial insertion. Hence my request:
Quoted 9 lines
Quoted 4 lines
If that is
the case then there is nothing wrong with the wayd_validateusesdget(). Can someone with more SMB/NCP expertise than me validate the use of cached dentries?Then why would it have to use
d_validateif it has a reference? That is supposed to be for an "untrusted" pointer (which is why it had all the crazy checks that it's in kmem and in the right slab etc).
Code changes. It may not be doing what it was originally needed/intended to be doing - I don't need to waste time on code archeology and second guessing when there are others around that can tell me this off the top oftheir head. ;)
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 02/46] fs: d_validate fixes
In reply to Nick PigginQuoted 16 lines · Nick Piggin
Quoted 15 lines · Dave Chinner
Quoted 13 lines · Nick Piggin
d_validatehas been broken for a long time.
kmem_ptr_validatedoes not guarantee that a pointer can be dereferenced if it can go away at any time. Evenrcu_read_lockdoesn't help, because the pointer might be queued in RCU callbacks but not executed yet.So the parent cannot be checked, nor the name hashed. The dentry pointer can not be touched until it can be verified under lock. Hashing simply cannot be used.
Instead, verify the parent/child relationship by traversing parent's
d_childlist. It's slow, but only ncpfs and the destaged smbfs care about it, at this point.
Quoted 7 lines
Quoted 5 lines
I'd drop the previous revert patch and just convert the RCU hash traversal straight to the
d_childtraversal code you introduce here. This is a much better explanation of why thed_validatemechanism needs to be changed, and the revert is really an unnecessary extra step...Has to be backported, though.
Backported where? The d_validate() change only got included in .37-rc1.
Quoted 4 lines
Patch that is to be reverted obviously
adds more brokenness and is a good example that you cannotdget()under rcu read protection even if the rest of the surrounding function is bugfree. I wouldn't have thought it's a big deal.
Reverting something broken to something already broken just to fix to the less broken version seems like an unnecessary step. Just fix the brokenneѕs in a single patch - no need to indirect the real fix through a revert. One less patch to worry about.
Cheers,
Dave.
Signature · 6 lines
Dave Chinner [email protected] -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/46] Revert "fs: use RCU read side protection in d_validate"
In reply to Dave ChinnerQuoted 19 lines · Dave Chinner
Quoted 18 lines · Nick Piggin
Quoted 16 lines · Dave Chinner
Quoted 3 lines · Nick Piggin
This reverts commit
3825bdb7ed920845961f32f364454bee5f469abb.Patch is broken, you can't
dget()without holding any locks!I believe you can - for the same reasons we can take a reference to an inode without holding the
inode_lock. That is, as long as the caller already holds an active reference to the dentry,dget()can be used to take another reference without needing thedcache_lock.Such usage appears to be described in the comment above
dget()and there's aBUG_ON()indget()to catch callers that don't already have an active reference. An example of a valid unlockeddget():d_alloc()does an unlockeddget()to take a reference to the parent dentry whichn we already are guaranteed to have a reference to.
Quoted 5 lines
Quoted 1 line
Of course you can dget if you already have a reference :)
Right, so the commit message is wrong. Can you update it to tell us why
dget()can't be used there - the commit message from the second patch explained it far better....
I suppose if you're not reading it in the context of d_validate, then yes. And as an historical record, I'll clarify.
Obviously if we do have a reference, then we can take another, and if we don't, then we need more than RCU because RCU only provides persistence guarantee for the memory, not any persistence or validity guarantee for the object.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
As to
d_validate()- it depends on the caller behaviour as to whether the unlockeddget()is valid or not. From a cursory check of the NCP and SMB readdir caches, both appear to hold an active reference to the dentry it is passing tod_validate().
Quoted 7 lines
Quoted 3 lines
I don't see where? Can you point to where the refcount is taken? AFAIKS it drops the reference 3 lines after it puts the pointer into cache.
Yeah, you're right, I missed that one - I spent more tiem checking the validation part of the code than the initial insertion. Hence my request:
Yes, I'm pretty sure it doesn't have any references.
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
If that is
the case then there is nothing wrong with the wayd_validateusesdget(). Can someone with more SMB/NCP expertise than me validate the use of cached dentries?Then why would it have to use
d_validateif it has a reference? That is supposed to be for an "untrusted" pointer (which is why it had all the crazy checks that it's in kmem and in the right slab etc).
Quoted 4 lines
Code changes. It may not be doing what it was originally needed/intended to be doing - I don't need to waste time on code archeology and second guessing when there are others around that can tell me this off the top oftheir head. ;)
Well the d_validate API is meant to provide that, so it's broken whether or not its callers use it correctly. It's also exported to external modules...
Yes we should remove smbfs and rip the cache out of ncpfs and remove d_validate entirely when possible (or, provide a more reasonable API and caching library entirely in the dcache code that a filesystem might use). But this is the right first step.
Re: [PATCH 02/46] fs: d_validate fixes
In reply to Dave ChinnerQuoted 23 lines · Dave Chinner
Quoted 22 lines · Nick Piggin
Quoted 20 lines · Dave Chinner
Quoted 6 lines · Nick Piggin
d_validatehas been broken for a long time.
kmem_ptr_validatedoes not guarantee that a pointer can be dereferenced if it can go away at any time. Evenrcu_read_lockdoesn't help, because the pointer might be queued in RCU callbacks but not executed yet.Quoted 7 lines
So the parent cannot be checked, nor the name hashed. The dentry pointer can not be touched until it can be verified under lock. Hashing simply cannot be used.
Instead, verify the parent/child relationship by traversing parent's
d_childlist. It's slow, but only ncpfs and the destaged smbfs care about it, at this point.I'd drop the previous revert patch and just convert the RCU hash traversal straight to the
d_childtraversal code you introduce here. This is a much better explanation of why thed_validatemechanism needs to be changed, and the revert is really an unnecessary extra step...
Quoted 3 lines
Quoted 1 line
Has to be backported, though.
Backported where? The
d_validate()change only got included in .37-rc1.
Backported to stable/distro kernels I suppose. I'm not sure what your point is?
Quoted 9 lines
Quoted 4 lines
Patch that is to be reverted obviously
adds more brokenness and is a good example that you cannotdget()under rcu read protection even if the rest of the surrounding function is bugfree. I wouldn't have thought it's a big deal.Reverting something broken to something already broken just to fix to the less broken version seems like an unnecessary step. Just fix the brokenneѕs in a single patch - no need to indirect the real fix through a revert. One less patch to worry about.
OK but I disagree. Firstly, reverting that patch gives a good record of that particular pattern of bug (that Christoph and Al both missed). With more RCU going into the vfs, people need to be pretty clear about the pitfalls.
Secondly, as I said, reverting means that I can use exact same patch for upstream and stable kernels.
And finally, it gives better bisectability. If somebody hits a bug in my patch, I would rather have them bisect into the well-worn (if buggy) version of the code than bisect into a different type of brokenness.
It isn't indirecting the real fix through a revert, they are broken in different ways. My fix is for the bug that it doesn't guarantee the persistence of *memory* we are using, and the revert is for the bug that it doesn't guarantee the persistence/validity of the *object*, and which is actually more likely to be a problem if you think about it, because the window is much larger.
Git has no problem with lots of patches, so I don't see any advantage to doing one patch, and you lose the advantages above.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/46] Revert "fs: use RCU read side protection in d_validate"
In reply to Nick PigginQuoted 11 lines · Nick Piggin
Quoted 4 lines
Code changes. It may not be doing what it was originally needed/intended to be doing - I don't need to waste time on code archeology and second guessing when there are others around that can tell me this off the top oftheir head. ;)
Well the
d_validateAPI is meant to provide that, so it's broken whether or not its callers use it correctly. It's also exported to external modules...Yes we should remove smbfs and rip the cache out of ncpfs and remove
d_validateentirely when possible (or, provide a more
The reason why I don't remove the caching crap entirely is because it is not a trivial change to properly remove it, and I don't have the time or inclination to do it properly and have it tested when it's easy to provide a correct, simple, and back compatible API.
The patch Christoph posted for smbfs and ncpfs just hacks out where the dentry is used from the cache, but leaves a lot of cache infrastructure there to rot.
Quoted 2 lines
reasonable API and caching library entirely in the dcache code that a filesystem might use). But this is the right first step.
For the record, if anyone cares, the sanest and simplest way to do this would be to store the dentry's hash along with its pointer, and have interfaces to allocate, destroy, insert, and delete from cache, and lookup based on a supplied compare function. (but obviously we shouldn't bother unless some good numbers turn up)
Re: [PATCH 11/46] fs: dcache scale hash
In reply to Nick PigginQuoted 16 lines · Nick Piggin
Add a new lock,
dcache_hash_lock, to protect the dcache hash table from concurrent modification.d_hashis also protected byd_lock.Signed-off-by Nick Piggin <[email protected]>--- fs/dcache.c | 38 +++++++++++++++++++++++++++----------- include/linux/dcache.h | 3 +++ 2 files changed, 30 insertions(+), 11 deletions(-)fs/dcache.c +0
-0@@ -35,12 +35,27 @@#include <linux/hardirq.h> #include "internal.h"
fs/dcache.c line 46
Quoted 10 lines
fs/dcache.c +9
-0+/* +* Usage: +* dcache_hash_lock protects dcache hash table +* +* Ordering: +* dcache_lock +* dentry->d_lock +* dcache_hash_lock +*
What locking is used to keep DCACHE_UNHASHED/d_unhashed() in check with the whether the dentry is on the hash list or not? It looks to me that to make any hash modification, you have to hold both the dentry->d_lock and the dcache_hash_lock to keep them in step. If this is correct, can you add this to the comments above?
fs/dcache.c line 50
Quoted 4 lines
fs/dcache.c +4
-0+* if (dentry1 < dentry2) +* dentry1->d_lock +* dentry2->d_lock +*/
Perhaps the places where we need to lock two dentries should use a wrapper like we do for other objects. Such as:
void dentry_dlock_two(struct dentry *d1, struct dentry *d2)
{
if (d1 < d2) {
spin_lock(&d1->d_lock);
spin_lock_nested(&d2->d_lock, DENTRY_D_LOCK_NESTED);
} else {
spin_lock(&d2->d_lock);
spin_lock_nested(&d1->d_lock, DENTRY_D_LOCK_NESTED);
}
}fs/dcache.c void d_rehash(struct dentry * entry) · line 1606
Quoted 10 lines
fs/dcache.c +2
-0@@ -1581,7 +1598,9 @@ void d_rehash(struct dentry * entry) {spin_lock (&dcache_lock);spin_lock (&entry->d_lock); +spin_lock (&dcache_hash_lock);_d_rehash (entry); +spin_unlock (&dcache_hash_lock);spin_unlock (&entry->d_lock);spin_unlock (&dcache_lock); }
Shouldn't we really kill _d_rehash() by replacing all the callers with direct calls to __d_rehash() first? There doesn't seem to be much sense to keep both methods around....
Quoted 52 lines
fs/dcache.c +7
-10@@ -1661,8 +1680,6 @@ static void switch_names(struct dentry *dentry, struct dentry *target)*/ static void d_move_locked (struct dentry * dentry,struct dentry * target) { -struct hlist_head *list; -if (!dentry->d_inode)printk (KERN_WARNING "VFS: moving negative dcache entry\n" );@@ -1679,14 +1696,11 @@ static void d_move_locked(struct dentry * dentry, struct dentry * target) }/* Move the dentry to the target hash queue, if on different bucket */ -if (d_unhashed (dentry)) - goto already_unhashed; - -hlist_del_rcu (&dentry->d_hash); - -already_unhashed: - list =d_hash (target->d_parent, target->d_name.hash); -__d_rehash (dentry, list); +spin_lock (&dcache_hash_lock); +if (!d_unhashed (dentry)) +hlist_del_rcu (&dentry->d_hash); +__d_rehash (dentry,d_hash (target->d_parent, target->d_name.hash)); +spin_unlock (&dcache_hash_lock);/* Unhash the target: dput() will then get rid of it */ __d_drop (target);@@ -1883,7 +1897,9 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode) found_lock:spin_lock (&actual->d_lock); found: +spin_lock (&dcache_hash_lock);_d_rehash (actual); +spin_unlock (&dcache_hash_lock);spin_unlock (&actual->d_lock);spin_unlock (&dcache_lock); out_nolock:include/linux/dcache.h +1
-0@@ -181,6 +181,7 @@ struct dentry_operations {#define DCACHE_CANT_MOUNT 0x0100 +extern spinlock_t dcache_hash_lock;extern spinlock_t dcache_lock;extern seqlock_t rename_lock;
include/linux/dcache.h static inline void __d_drop(struct dentry *dentry) · line 212
Quoted 8 lines
include/linux/dcache.h +2
-0@@ -204,7 +205,9 @@ static inline void __d_drop(struct dentry *dentry) {if (!(dentry->d_flags &DCACHE_UNHASHED )) { dentry->d_flags |=DCACHE_UNHASHED ; +spin_lock (&dcache_hash_lock);hlist_del_rcu (&dentry->d_hash); +spin_unlock (&dcache_hash_lock); } }
Un-inline __d_drop so you don't need to make the dcache_hash_lock visible outside of fs/dcache.c. That happens later in the series anyway, so may as well do it now...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 11/46] fs: dcache scale hash
Quoted 18 lines · Dave Chinner
Quoted 17 lines · Nick Piggin
Add a new lock,
dcache_hash_lock, to protect the dcache hash table from concurrent modification.d_hashis also protected byd_lock.Signed-off-by Nick Piggin <[email protected]>--- fs/dcache.c | 38 +++++++++++++++++++++++++++----------- include/linux/dcache.h | 3 +++ 2 files changed, 30 insertions(+), 11 deletions(-)fs/dcache.c +0
-0@@ -35,12 +35,27 @@#include <linux/hardirq.h> #include "internal.h"
Quoted 15 lines
fs/dcache.c line 46
Quoted 9 lines
fs/dcache.c +9
-0+/* +* Usage: +* dcache_hash_lock protects dcache hash table +* +* Ordering: +* dcache_lock +* dentry->d_lock +* dcache_hash_lock +* What locking is used to keep DCACHE_UNHASHED/d_unhashed() in check with the whether the dentry is on the hash list or not? It looks to me that to make any hash modification, you have to hold both the
dentry->d_lockand thedcache_hash_lockto keep them in step. If this is correct, can you add this to the comments above?
No, dcache_lock still does that. d_unhashed is protected with d_lock a few patches later, which adds to the comment.
Quoted 9 lines
fs/dcache.c line 50
Quoted 4 lines
fs/dcache.c +4
-0+* if (dentry1 < dentry2) +* dentry1->d_lock +* dentry2->d_lock +*/ Perhaps the places where we need to lock two dentries should use a wrapper like we do for other objects. Such as:
void
dentry_dlock_two(struct dentry *d1, struct dentry *d2)
Quoted 9 lines
{
if (d1 < d2) {
spin_lock(&d1->d_lock);
spin_lock_nested(&d2->d_lock, DENTRY_D_LOCK_NESTED);
} else {
spin_lock(&d2->d_lock);
spin_lock_nested(&d1->d_lock, DENTRY_D_LOCK_NESTED);
}
}It only happens once in rename, so I don't think it's useful. Nothing outside core code should be locking 2 unrelated dentries.
Quoted 6 lines
Quoted 6 lines
fs/dcache.c +1
-0@@ -1581,7 +1598,9 @@ void d_rehash(struct dentry * entry) {spin_lock (&dcache_lock);spin_lock (&entry->d_lock); +spin_lock (&dcache_hash_lock);_d_rehash (entry);
Quoted 8 lines
fs/dcache.c void d_rehash(struct dentry * entry) · line 1606
Quoted 4 lines
fs/dcache.c +1
-0+spin_unlock (&dcache_hash_lock);spin_unlock (&entry->d_lock);spin_unlock (&dcache_lock); }Shouldn't we really kill
_d_rehash()by replacing all the callers with direct calls to__d_rehash()first? There doesn't seem to be much sense to keep both methods around....
No. Several filesystems are using it, and it's an exported symbol. I'm focusing on changed to locking, and keeping APIs the same, where possible. I don't want just more and more depencendies on pushing through filesystem changes before this series.
Like I said, there are infinite cleanups or improvements you can make. It does not particularly matter that they happen before or after the scaling work, except if there are classes of APIs that the new locking model can no longer support.
Quoted 51 lines
Quoted 51 lines
fs/dcache.c +7
-10@@ -1661,8 +1680,6 @@ static void switch_names(struct dentry *dentry, struct dentry *target)*/ static void d_move_locked (struct dentry * dentry,struct dentry * target) { -struct hlist_head *list; -if (!dentry->d_inode)printk (KERN_WARNING "VFS: moving negative dcache entry\n" );@@ -1679,14 +1696,11 @@ static void d_move_locked(struct dentry * dentry, struct dentry * target) }/* Move the dentry to the target hash queue, if on different bucket */ -if (d_unhashed (dentry)) - goto already_unhashed; - -hlist_del_rcu (&dentry->d_hash); - -already_unhashed: - list =d_hash (target->d_parent, target->d_name.hash); -__d_rehash (dentry, list); +spin_lock (&dcache_hash_lock); +if (!d_unhashed (dentry)) +hlist_del_rcu (&dentry->d_hash); +__d_rehash (dentry,d_hash (target->d_parent, target->d_name.hash)); +spin_unlock (&dcache_hash_lock);/* Unhash the target: dput() will then get rid of it */ __d_drop (target);@@ -1883,7 +1897,9 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode) found_lock:spin_lock (&actual->d_lock); found: +spin_lock (&dcache_hash_lock);_d_rehash (actual); +spin_unlock (&dcache_hash_lock);spin_unlock (&actual->d_lock);spin_unlock (&dcache_lock); out_nolock:include/linux/dcache.h +1
-0@@ -181,6 +181,7 @@ struct dentry_operations {#define DCACHE_CANT_MOUNT 0x0100 +extern spinlock_t dcache_hash_lock;extern spinlock_t dcache_lock;extern seqlock_t rename_lock;
Quoted 13 lines
include/linux/dcache.h static inline void __d_drop(struct dentry *dentry) · line 212
Quoted 9 lines
include/linux/dcache.h +2
-0@@ -204,7 +205,9 @@ static inline void __d_drop(struct dentry *dentry) {if (!(dentry->d_flags &DCACHE_UNHASHED )) { dentry->d_flags |=DCACHE_UNHASHED ; +spin_lock (&dcache_hash_lock);hlist_del_rcu (&dentry->d_hash); +spin_unlock (&dcache_hash_lock); } }Un-inline
__d_dropso you don't need to make thedcache_hash_lockvisible outside offs/dcache.c. That happens later in the series anyway, so may as well do it now...
Yeah that makes sense.
Thanks,
Nick
Re: [PATCH 12/46] fs: dcache scale lru
In reply to Nick PigginQuoted 13 lines · Nick Piggin
Add a new lock,
dcache_lru_lock, to protect the dcache LRU list from concurrent modification.d_lruis also protected byd_lock.Signed-off-by Nick Piggin <[email protected]>--- fs/dcache.c | 112 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 84 insertions(+), 28 deletions(-)fs/dcache.c +0
-0
fs/dcache.c line 45
Quoted 10 lines
fs/dcache.c +6
-1@@ -37,11 +37,19 @@/* * Usage: -* dcache_hash_lock protects dcache hash table +* dcache_hash_lock protects: +* - the dcache hash table +* dcache_lru_lock protects: +* - the dcache lru lists and counters +* d_lock protects: +* - d_flags
Which bit of d_flags does it protect? Why in this patch and not in the hash scaling patch with needs DCACHE_UNHASHED to be in sync with the whether it is in the hash list?
fs/dcache.c line 47
Quoted 2 lines
fs/dcache.c +2
-0+* - d_name +* - d_lru
Why is the d_lock required to protect d_lru? I can't see any reason in this patch that requires d_lock to protect anything that dcache_lru_lock does not protect....
Quoted 19 lines
fs/dcache.c +7
-0/** @@ -186,6 +206,8 @@ static void dentry_lru_move_tail(struct dentry *dentry)* The dentry must already be unhashed and removed from the LRU. * * If this is the root of the dentry tree, return NULL. +* +* dcache_lock and d_lock must be held by caller, are dropped by d_kill. */ static struct dentry *d_kill (struct dentry *dentry) __releases(dentry->d_lock)@@ -341,10 +363,19 @@ int d_invalidate(struct dentry * dentry)EXPORT_SYMBOL (d_invalidate);/* This should be called _only_ with dcache_lock held */ +static inline struct dentry *__dget_locked_dlock (struct dentry *dentry) +{ +atomic_inc (&dentry->d_count); +dentry_lru_del (dentry); +return dentry;
fs/dcache.c int d_invalidate(struct dentry * dentry) · line 380
Quoted 10 lines
fs/dcache.c +4
-0+} +static inline struct dentry *__dget_locked (struct dentry *dentry) {atomic_inc (&dentry->d_count); +spin_lock (&dentry->d_lock);dentry_lru_del (dentry); +spin_unlock (&dentry->d_lock);return dentry; }
Why do we need to call dentry_lru_del() in __dget_* functions? The shrinkers already handle lazy deletion just fine, and this just seems like a method for bouncing the dcache_lru_lock around.
The new lazy inode lru code which was modelled on the dcache code does not remove inodes from the LRU when taking new references to an inode and it seems to function just fine, so I'm thinking that we should be making the dcache LRU even more lazy by removing these calls to dentry_lru_del() here.
I think this is important as as lockstat is telling me the dcache_lru_lock is the most heavily contended lock in the system in my testing....
fs/dcache.c static void shrink_dentry_list(struct list_head *list) · line 514
Quoted 12 lines
fs/dcache.c +7
-1@@ -474,21 +505,31 @@ static void shrink_dentry_list(struct list_head *list)while (!list_empty (list)) { dentry = list_entry(list->prev, struct dentry, d_lru); -dentry_lru_del (dentry); + +if (!spin_trylock (&dentry->d_lock)) { +spin_unlock (&dcache_lru_lock); +cpu_relax (); +spin_lock (&dcache_lru_lock); +continue ; + }
Wouldn't it be better to move the entry to the tail of the list here so we don't get stuck spinning on the same dentry for a length of time?
Quoted 6 lines
fs/dcache.c +2
-0@@ -509,32 +550,36 @@ static void __shrink_dcache_sb(struct super_block *sb, int *count, int flags)int cnt = *count;spin_lock (&dcache_lock); +relock: +spin_lock (&dcache_lru_lock);
fs/dcache.c static void __shrink_dcache_sb(struct super_block *sb, int *count, int flags) · line 564
Quoted 10 lines
fs/dcache.c +5
-0while (!list_empty (&sb->s_dentry_lru)) { dentry =list_entry (sb->s_dentry_lru.prev, struct dentry, d_lru);BUG_ON (dentry->d_sb != sb); +if (!spin_trylock (&dentry->d_lock)) { +spin_unlock (&dcache_lru_lock); +cpu_relax (); + goto relock; + }
Same again - if the dentry is locked, then it is likely to be newly referenced so move it to the tail of the list and continue....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 11/46] fs: dcache scale hash
In reply to Nick PigginQuoted 35 lines · Nick Piggin
Quoted 18 lines · Dave Chinner
Quoted 17 lines · Nick Piggin
Add a new lock,
dcache_hash_lock, to protect the dcache hash table from concurrent modification.d_hashis also protected byd_lock.Signed-off-by Nick Piggin <[email protected]>--- fs/dcache.c | 38 +++++++++++++++++++++++++++----------- include/linux/dcache.h | 3 +++ 2 files changed, 30 insertions(+), 11 deletions(-)fs/dcache.c +0
-0@@ -35,12 +35,27 @@#include <linux/hardirq.h> #include "internal.h" Quoted 15 lines
fs/dcache.c line 46
Quoted 9 lines
fs/dcache.c +9
-0+/* +* Usage: +* dcache_hash_lock protects dcache hash table +* +* Ordering: +* dcache_lock +* dentry->d_lock +* dcache_hash_lock +* What locking is used to keep DCACHE_UNHASHED/d_unhashed() in check with the whether the dentry is on the hash list or not? It looks to me that to make any hash modification, you have to hold both the
dentry->d_lockand thedcache_hash_lockto keep them in step. If this is correct, can you add this to the comments above?
Quoted 2 lines
No,
dcache_lockstill does that.d_unhashedis protected withd_locka few patches later, which adds to the comment.
d_unhashed() is just a flag bit in ->d_flags, which is apparently protected by ->d_lock in the next the LRU patch. I say apparently because that patch doesn't appear to protect anything to do with d_flags. I'm struggling to work out what is being protected in each patch because it is not clearexactly what is being done.
It makes much more sense to me to start by making all access to d_flags atomic (i.e. protected by ->d_lock) in a separate patch than to do it hodge-podge across multiple patches as you currently are. Its hard to follow when things that are intimately related are separated by mutliple patches doing different things...
Quoted 19 lines
Quoted 9 lines
fs/dcache.c line 50
Quoted 4 lines
fs/dcache.c +4
-0+* if (dentry1 < dentry2) +* dentry1->d_lock +* dentry2->d_lock +*/ Perhaps the places where we need to lock two dentries should use a wrapper like we do for other objects. Such as:
void
dentry_dlock_two(struct dentry *d1, struct dentry *d2)Quoted 9 lines
{ if (d1 < d2) { spin_lock(&d1->d_lock); spin_lock_nested(&d2->d_lock, DENTRY_D_LOCK_NESTED); } else { spin_lock(&d2->d_lock); spin_lock_nested(&d1->d_lock, DENTRY_D_LOCK_NESTED); } }
Quoted 1 line
It only happens once in rename, so I don't think it's useful.
It is self documenting code, which does have value...
Quoted 1 line
Nothing outside core code should be locking 2 unrelated dentries.
So it is static.
Quoted 17 lines
Quoted 16 lines
fs/dcache.c void d_rehash(struct dentry * entry) · line 1606
Quoted 12 lines
fs/dcache.c +2
-0@@ -1581,7 +1598,9 @@ void d_rehash(struct dentry * entry) {spin_lock (&dcache_lock);spin_lock (&entry->d_lock); +spin_lock (&dcache_hash_lock);_d_rehash (entry); +spin_unlock (&dcache_hash_lock);spin_unlock (&entry->d_lock);spin_unlock (&dcache_lock); }Shouldn't we really kill
_d_rehash()by replacing all the callers with direct calls to__d_rehash()first? There doesn't seem to be much sense to keep both methods around....
Quoted 1 line
No. Several filesystems are using it, and it's an exported symbol.
That's __d_rehash().
_d_rehash() (single underscore) is static and only called by d_rehash() and d_materialise_unique() And is one line of code calling __d_rehash(). Kill it, please.
Quoted 9 lines
I'm
focusing on changed to locking, and keeping APIs the same, where possible. I don't want just more and more depencendies on pushing through filesystem changes before this series.Like I said, there are infinite cleanups or improvements you can make. It does not particularly matter that they happen before or after the scaling work, except if there are classes of APIs that the new locking model can no longer support.
We do plenty of cleanups when changing code when the result gives us simpler and easier to understand code. It's a trivial change that, IMO, makes the code more consistent and easier to follow.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Nick Piggin
reviewerRe: [PATCH 12/46] fs: dcache scale lru
In reply to Dave ChinnerDamn, forgot cc, sorry.
Quoted 15 lines · Dave Chinner
Quoted 14 lines · Nick Piggin
Add a new lock,
dcache_lru_lock, to protect the dcache LRU list from concurrent modification.d_lruis also protected byd_lock.Signed-off-by Nick Piggin <[email protected]>--- fs/dcache.c | 112 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 84 insertions(+), 28 deletions(-)fs/dcache.c +0
-0@@ -37,11 +37,19 @@
Quoted 11 lines
fs/dcache.c line 45
Quoted 9 lines
fs/dcache.c +6
-1/* * Usage: -* dcache_hash_lock protects dcache hash table +* dcache_hash_lock protects: +* - the dcache hash table +* dcache_lru_lock protects: +* - the dcache lru lists and counters +* d_lock protects: +* - d_flags Which bit of
d_flagsdoes it protect?
All of them.
Quoted 3 lines
Why in this patch and not in
the hash scaling patch with needsDCACHE_UNHASHEDto be in sync with the whether it is in the hash list?
It's unrelated to this patch (same as d_name, below).
Quoted 6 lines
fs/dcache.c line 47
Quoted 2 lines
fs/dcache.c +2
-0+* - d_name +* - d_lru Why is the
d_lockrequired to protectd_lru? I can't see any reason in this patch that requiresd_lockto protect anything thatdcache_lru_lockdoes not protect....
It's used in future patches.
Quoted 25 lines
Quoted 25 lines
fs/dcache.c +10
-0/** @@ -186,6 +206,8 @@ static void dentry_lru_move_tail(struct dentry *dentry)* The dentry must already be unhashed and removed from the LRU. * * If this is the root of the dentry tree, return NULL. +* +* dcache_lock and d_lock must be held by caller, are dropped by d_kill. */ static struct dentry *d_kill (struct dentry *dentry) __releases(dentry->d_lock)@@ -341,10 +363,19 @@ int d_invalidate(struct dentry * dentry)EXPORT_SYMBOL (d_invalidate);/* This should be called _only_ with dcache_lock held */ +static inline struct dentry *__dget_locked_dlock (struct dentry *dentry) +{ +atomic_inc (&dentry->d_count); +dentry_lru_del (dentry); +return dentry; +} +static inline struct dentry *__dget_locked (struct dentry *dentry) {atomic_inc (&dentry->d_count); +spin_lock (&dentry->d_lock);
Quoted 8 lines
fs/dcache.c int d_invalidate(struct dentry * dentry) · line 380
Quoted 4 lines
fs/dcache.c +1
-0dentry_lru_del (dentry); +spin_unlock (&dentry->d_lock);return dentry; }Why do we need to call
dentry_lru_del()in __dget_* functions? The shrinkers already handle lazy deletion just fine, and this just seems like a method for bouncing thedcache_lru_lockaround.
This is how the code works before the locking series. The intention is that places which already hold dcache_lock for other reasons can take the dentry off the list cheaply.
I am avoiding where possible in making functional changes along with locking changes (like I have said many times). After dcache_lock goes away, there are patches to make it more lazy.
Quoted 4 lines
The new lazy inode lru code which was modelled on the dcache code does not remove inodes from the LRU when taking new references to an inode and it seems to function just fine,
I know, didn't I implement it? :)
Quoted 3 lines
so I'm thinking that we
should be making the dcache LRU even more lazy by removing these calls todentry_lru_del()here.
Not in this patch, but later yes.
Quoted 7 lines
I think this is important as as lockstat is telling me the
dcache_lru_lockis the most heavily contended lock in the system in my testing....Quoted 2 lines
fs/dcache.c +0
-0@@ -474,21 +505,31 @@ static void shrink_dentry_list(struct list_head *list)
Quoted 14 lines
fs/dcache.c static void shrink_dentry_list(struct list_head *list) · line 514
Quoted 10 lines
fs/dcache.c +7
-1while (!list_empty (list)) { dentry = list_entry(list->prev, struct dentry, d_lru); -dentry_lru_del (dentry); + +if (!spin_trylock (&dentry->d_lock)) { +spin_unlock (&dcache_lru_lock); +cpu_relax (); +spin_lock (&dcache_lru_lock); +continue ; + }Wouldn't it be better to move the entry to the tail of the list here so we don't get stuck spinning on the same dentry for a length of time?
Again, I'm avoiding functional changes in this part of the series. It makes things slightly more clunky in intermediate stages, but makes verification and bisecting much easier.
This particular one gets done completely without lru lock in future patch.
Quoted 11 lines
Quoted 11 lines
fs/dcache.c +2
-0@@ -509,32 +550,36 @@ static void __shrink_dcache_sb(struct super_block *sb, int *count, int flags)int cnt = *count;spin_lock (&dcache_lock); +relock: +spin_lock (&dcache_lru_lock);while (!list_empty (&sb->s_dentry_lru)) { dentry =list_entry (sb->s_dentry_lru.prev, struct dentry, d_lru);BUG_ON (dentry->d_sb != sb);
Quoted 8 lines
fs/dcache.c static void __shrink_dcache_sb(struct super_block *sb, int *count, int flags) · line 564
Quoted 5 lines
fs/dcache.c +5
-0+if (!spin_trylock (&dentry->d_lock)) { +spin_unlock (&dcache_lru_lock); +cpu_relax (); + goto relock; + }Same again - if the dentry is locked, then it is likely to be newly referenced so move it to the tail of the list and continue....
Not this patch.
Thanks,
Nick
Nick Piggin
reviewerRe: [PATCH 11/46] fs: dcache scale hash
In reply to Dave ChinnerQuoted 36 lines · Dave Chinner
Quoted 35 lines · Nick Piggin
Quoted 33 lines · Dave Chinner
Quoted 16 lines · Nick Piggin
Add a new lock,
dcache_hash_lock, to protect the dcache hash table from concurrent modification.d_hashis also protected byd_lock.Signed-off-by Nick Piggin <[email protected]>---
fs/dcache.c | 38 +++++++++++++++++++++++++++-----------include/linux/dcache.h| 3 +++2 files changed, 30 insertions(+), 11 deletions(-)fs/dcache.c +0
-0@@ -35,12 +35,27 @@ #include <linux/hardirq.h> #include "internal.h"fs/dcache.c line 46
Quoted 10 lines
fs/dcache.c +9
-0+/* +* Usage: +* dcache_hash_lock protects dcache hash table +* +* Ordering: +* dcache_lock +* dentry->d_lock +* dcache_hash_lock +* What locking is used to keep DCACHE_UNHASHED/d_unhashed() in check with the whether the dentry is on the hash list or not? It looks to me that to make any hash modification, you have to hold both the
dentry->d_lockand thedcache_hash_lockto keep them in step. If this is correct, can you add this to the comments above?
Quoted 5 lines
Quoted 2 lines
No,
dcache_lockstill does that.d_unhashedis protected withd_locka few patches later, which adds to the comment.
d_unhashed()is just a flag bit in ->d_flags, which is apparently protected by ->d_lock in the next the LRU patch.
No, d_flags in upstream kernel is protected by d_lock (and also you can't protected one bit in a word with a lock but not another).
Quoted 4 lines
I say apparently
because that patch doesn't appear to protect anything to do withd_flags. I'm struggling to work out what is being protected in each patch because it is not clearexactly what is being done.
Well hopefully the code and changelog is more clear. The lockorder doc changes probably aren't a good source for a running commentary. Not that it's wrong, it just may have a few nits like this where an existing lock order or role is commented in another patch. Meh.
Quoted 5 lines
It makes much more sense to me to start by making all access to
d_flagsatomic (i.e. protected by ->d_lock) in a separate patch than to do it hodge-podge across multiple patches as you currently are. Its hard to follow when things that are intimately related are separated by mutliple patches doing different things...
It might be easier to follow if you know d_flags is already protected by d_lock.
The d_unhashed patch uses d_lock to keep _both_ the d_flags and the hash list membership status in sync. It does not make the d_flags itself atomic.
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
fs/dcache.c line 50
Quoted 4 lines
fs/dcache.c +4
-0+* if (dentry1 < dentry2) +* dentry1->d_lock +* dentry2->d_lock +*/ Perhaps the places where we need to lock two dentries should use a wrapper like we do for other objects. Such as:
void
dentry_dlock_two(struct dentry *d1, struct dentry *d2){
if (d1 < d2) {
spin_lock(&d1->d_lock);spin_lock_nested(&d2->d_lock, DENTRY_D_LOCK_NESTED); } else {
spin_lock(&d2->d_lock);spin_lock_nested(&d1->d_lock, DENTRY_D_LOCK_NESTED); }
}
Quoted 7 lines
Quoted 1 line
It only happens once in rename, so I don't think it's useful.
It is self documenting code, which does have value...
Quoted 1 line
Nothing outside core code should be locking 2 unrelated dentries.
So it is static.
Anyway, cleanup. It can equally well be done before or after, and seeing as we're being nice and not breaking my tree with minutiae, can you base it on top please?
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
fs/dcache.c void d_rehash(struct dentry * entry) · line 1606
Quoted 10 lines
fs/dcache.c +2
-0@@ -1581,7 +1598,9 @@ void d_rehash(struct dentry * entry) { spin_lock(&dcache_lock); spin_lock(&entry->d_lock); +spin_lock (&dcache_hash_lock); _d_rehash(entry); +spin_unlock (&dcache_hash_lock); spin_unlock(&entry->d_lock); spin_unlock(&dcache_lock); }Shouldn't we really kill
_d_rehash()by replacing all the callers with direct calls to__d_rehash()first? There doesn't seem to be much sense to keep both methods around....
Quoted 3 lines
Quoted 1 line
No. Several filesystems are using it, and it's an exported symbol.
That's
__d_rehash().
Oh I beg your pardon.
Quoted 3 lines
_d_rehash()(single underscore) is static and only called byd_rehash()andd_materialise_unique()And is one line of code calling__d_rehash(). Kill it, please.
That doesn't belong in this patch either, it's shuffling. Anyway I like _d_rehash, so I'm certainly not going to send a patch to kill it.
Quoted 5 lines
Quoted 5 lines
I'm
focusing on changed to locking, and keeping APIs the same, where possible. I don't want just more and more depencendies on pushing through filesystem changes before this series.
Quoted 8 lines
Quoted 4 lines
Like I said, there are infinite cleanups or improvements you can make. It does not particularly matter that they happen before or after the scaling work, except if there are classes of APIs that the new locking model can no longer support.
We do plenty of cleanups when changing code when the result gives us simpler and easier to understand code. It's a trivial change that, IMO, makes the code more consistent and easier to follow.
Unrelated "cleanups" in the same patch as non trivial locking change is stupid.
Necessary changes to prevent bad ugliness resulting, or preventing repeated steps for the particular changes, etc. of course. Killing un related functions no.
Re: [PATCH 11/46] fs: dcache scale hash
Quoted 11 lines · Nick Piggin
Quoted 8 lines
Quoted 4 lines
Like I said, there are infinite cleanups or improvements you can make. It does not particularly matter that they happen before or after the scaling work, except if there are classes of APIs that the new locking model can no longer support.
We do plenty of cleanups when changing code when the result gives us simpler and easier to understand code. It's a trivial change that, IMO, makes the code more consistent and easier to follow.
Unrelated "cleanups" in the same patch as non trivial locking change is stupid.
So put it in another prepartory patch. It makes the locking changes easier to understand...
Quoted 3 lines
Necessary changes to prevent bad ugliness resulting, or preventing repeated steps for the particular changes, etc. of course. Killing un related functions no.
Ok, I get the picture. You don't want a code review, you want a rubber stamp. Find someone else to get it from.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 11/46] fs: dcache scale hash
Quoted 10 lines · Dave Chinner
Quoted 9 lines · Nick Piggin
Quoted 8 lines
Quoted 4 lines
Like I said, there are infinite cleanups or improvements you can make. It does not particularly matter that they happen before or after the scaling work, except if there are classes of APIs that the new locking model can no longer support.
We do plenty of cleanups when changing code when the result gives us simpler and easier to understand code. It's a trivial change that, IMO, makes the code more consistent and easier to follow.
Quoted 5 lines
Quoted 2 lines
Unrelated "cleanups" in the same patch as non trivial locking change is stupid.
So put it in another prepartory patch. It makes the locking changes easier to understand...
I didn't change that, though, the ordering of locking unrelated dentries and the code is already in rename code and is not touched during this patch set.
Quoted 6 lines
Quoted 3 lines
Necessary changes to prevent bad ugliness resulting, or preventing repeated steps for the particular changes, etc. of course. Killing un related functions no.
Ok, I get the picture. You don't want a code review, you want a rubber stamp. Find someone else to get it from.
Of course I want code review. I am not going to just do everything you say that I don't agree with, but I will explain why every time (as I have done to all your points).
I would prefer more in-depth review than from someone who doesn't know d_lock protects d_flags, but any and all help is welcome. Even minor nitpicking or cleanups are welcome if they are relevant to the patches.
Thanks,
Nick
PS. don't accuse me of not wanting a code review, because you're just projecting. To paraphrase you:
I don't have to justify myself to you, nick, only the maintainers, so I'm not answering.
In response to my questions.
Re: [PATCH 11/46] fs: dcache scale hash
Quoted 6 lines · Nick Piggin
Quoted 5 lines · Dave Chinner
Quoted 3 lines · Nick Piggin
Necessary changes to prevent bad ugliness resulting, or preventing repeated steps for the particular changes, etc. of course. Killing un related functions no.
Quoted 6 lines
Quoted 2 lines
Ok, I get the picture. You don't want a code review, you want a rubber stamp. Find someone else to get it from.
Of course I want code review. I am not going to just do everything you say that I don't agree with, but I will explain why every time (as I have done to all your points).
Which generally comes down to "I disagree with you". That's hard to argue against because you aren't willing to compromise.
So, to address your next comment, I'll restate what I was proposing. That is, to ensure all the d_flags accesses protected by d_lock as an initial patch rather than cleaning it up in an ad-hoc fashion later on, such as this later patch in your series:
[PATCH 14/46] fs: dcache scale d_unhashed
which has the description:
Protect d_unhashed(dentry) condition with d_lock.
which illustrates my point that not all accesses to d_flags are currently protected by d_lock as you are asserting. Hence:
Quoted 2 lines
I would prefer more in-depth review than from someone who doesn't know
d_lockprotectsd_flags,
Your implication about my competence is incorrect and entirely inappropriate. Ad hominen attacks don't improve your argument or encourage other people to review your code.
Quoted 2 lines
but any and all help is welcome. Even minor
nitpicking or cleanups are welcome if they are relevant to the patches.
If _you_ decide they are relevant.
Nick, in the past couple of months you've burnt everyone who has tried to review your changes in any meaningful way. Nobody wants to engage with you because you've aggressively disagreed with every significant change that has been requested. You have shown no desire to compromise, instead you argue that you are right until you've had the last word, and you have frequently resorted to condesending and disrespectful attacks on reviewers. You would do well to keep that in mind next time you wonder why nobody is stepping up to review your code.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 181 lines · Nick Piggin
Quoted 73 lines · Dave Chinner
Quoted 72 lines · Dave Chinner
Quoted 65 lines · Nick Piggin
Quoted 55 lines · Dave Chinner
Quoted 11 lines · Nick Piggin
git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.gitvfs-scale-workingHere is an new set of vfs patches for review, not that there was much interest last time they were posted. It is structured like:
* preparation patches
* introduce new locks to take overdcache_lock, then remove it
* cleaning up and reworking things for new locks
* rcu-walk path walking
* start on some fine grained locking stepsStress test doing:
single thread 50M inode create
single thread rm -rf
2-way 50M inode create
2-way rm -rf
4-way 50M inode create
4-way rm -rf
8-way 50M inode create
8-way rm -rf
8-way 250M inode create
8-way rm -rfFailed about 5 minutes into the "4-way rm -rf" (~3 hours into the test) with a CPU stuck spinning on here:
[37372.084012] NMI backtrace for cpu 5 [37372.084012] CPU 5 [37372.084012] Modules linked in: [37372.084012] [37372.084012] Pid: 15214, comm: rm Not tainted 2.6.37-rc4-dgc+ #797 /Bochs [37372.084012] RIP: 0010:[<ffffffff810643c4>] [<ffffffff810643c4>] __ticket_spin_lock+0x14/0x20 [37372.084012] RSP: 0018:ffff880114643c98 EFLAGS: 00000213 [37372.084012] RAX: 0000000000008801 RBX: ffff8800687be6c0 RCX: ffff8800c4eb2688 [37372.084012] RDX: ffff880114643d38 RSI: ffff8800dfd4ea80 RDI: ffff880114643d14 [37372.084012] RBP: ffff880114643c98 R08: 0000000000000003 R09: 0000000000000000 [37372.084012] R10: 0000000000000000 R11: dead000000200200 R12: ffff880114643d14 [37372.084012] R13: ffff880114643cb8 R14: ffff880114643d38 R15: ffff8800687be71c [37372.084012] FS: 00007fd6d7c93700(0000) GS:ffff8800dfd40000(0000) knlGS:0000000000000000 [37372.084012] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [37372.084012] CR2: 0000000000bbd108 CR3: 0000000107146000 CR4: 00000000000006e0 [37372.084012] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [37372.084012] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [37372.084012] Process rm (pid: 15214, threadinfo ffff880114642000, task ffff88011b16f890) [37372.084012] Stack: [37372.084012] ffff880114643ca8 ffffffff81ad044e ffff880114643cf8 ffffffff81167ae7 [37372.084012] 0000000000000000 ffff880114643d38 000000000000000e ffff88011901d800 [37372.084012] ffff8800cdb7cf5c ffff88011901d8e0 0000000000000000 0000000000000000 [37372.084012] Call Trace: [37372.084012] [<ffffffff81ad044e>] _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff81167ae7>] shrink_dentry_list+0x47/0x370 [37372.084012] [<ffffffff81167f5e>] __shrink_dcache_sb+0x14e/0x1e0Quoted 8 lines
[37372.084012] [<ffffffff81168456>] shrink_dcache_parent+0x276/0x2d0 [37372.084012] [<ffffffff81ad044e>] ? _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff8115daa2>] dentry_unhash+0x42/0x80 [37372.084012] [<ffffffff8115db48>] vfs_rmdir+0x68/0x100 [37372.084012] [<ffffffff8115fd93>] do_rmdir+0x113/0x130 [37372.084012] [<ffffffff8114f5ad>] ? filp_close+0x5d/0x90 [37372.084012] [<ffffffff8115fde5>] sys_unlinkat+0x35/0x40 [37372.084012] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1bQuoted 3 lines
OK good, with any luck, that's the same bug.
Is this XFS?
Yes.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Is there any concurrent activity happening on the same dentries?
Not from an application perspective.
Quoted 1 line
Ie. are the rm -rf threads running on the same directories,
No, each thread operating on a different directory.
This is probably fixed by the same patch as the lockdep splat trace.
Quoted 96 lines
Quoted 5 lines
Quoted 1 line
or is there any reclaim happening in the background?
IIRC, kswapd was consuming about 5-10% of a CPU during parallel unlink tests. Mainly reclaiming XFS inodes, I think, but there may be dentry cache reclaim going as well.
Turns out that the kswapd peaks are upwards of 50% of a CPU for a few seconds, then idle for 10-15s. Typical perf top output of kswapd while it is active during unlinks is:
samples pcnt function DSO _______ _____ ___________________________ _________________ 17168.00 10.2% __call_rcu [kernel.kallsyms] 13223.00 7.8% kmem_cache_free [kernel.kallsyms] 12917.00 7.6% down_write [kernel.kallsyms] 12665.00 7.5% xfs_iunlock [kernel.kallsyms] 10493.00 6.2% xfs_reclaim_inode_grab [kernel.kallsyms] 9314.00 5.5% __lookup_tag [kernel.kallsyms] 9040.00 5.4% radix_tree_delete [kernel.kallsyms] 8694.00 5.1% is_bad_inode [kernel.kallsyms] 7639.00 4.5% __ticket_spin_lock [kernel.kallsyms] 6821.00 4.0% _raw_spin_unlock_irqrestore [kernel.kallsyms] 5484.00 3.2% __d_drop [kernel.kallsyms] 5114.00 3.0% xfs_reclaim_inode [kernel.kallsyms] 4626.00 2.7% __rcu_process_callbacks [kernel.kallsyms] 3556.00 2.1% up_write [kernel.kallsyms] 3206.00 1.9% _cond_resched [kernel.kallsyms] 3129.00 1.9% xfs_qm_dqdetach [kernel.kallsyms] 2327.00 1.4% radix_tree_tag_clear [kernel.kallsyms] 2327.00 1.4% call_rcu_sched [kernel.kallsyms] 2262.00 1.3% __ticket_spin_unlock [kernel.kallsyms] 2215.00 1.3% xfs_ilock [kernel.kallsyms] 2200.00 1.3% radix_tree_gang_lookup_tag [kernel.kallsyms] 1982.00 1.2% xfs_reclaim_inodes_ag [kernel.kallsyms] 1736.00 1.0% xfs_trans_unlocked_item [kernel.kallsyms] 1707.00 1.0% __ticket_spin_trylock [kernel.kallsyms] 1688.00 1.0% xfs_perag_get_tag [kernel.kallsyms] 1660.00 1.0% flat_send_IPI_mask [kernel.kallsyms] 1538.00 0.9% xfs_inode_item_destroy [kernel.kallsyms] 1312.00 0.8% __shrink_dcache_sb [kernel.kallsyms] 940.00 0.6% xfs_perag_put [kernel.kallsyms]So there is some dentry cache reclaim going on.
FWIW, it appears there is quite a lot of RCU freeing overhead (~15% more CPU time) in the work kswapd is doing during these unlinks, too. I just had a look at kswapd when a 8-way create is running - it's running at 50-60% of a cpu for seconds at a time. I caught this while it was doing pure XFS inode cache reclaim (~10s sample, kswapd reclaimed ~1M inodes):
samples pcnt function DSO _______ _____ ___________________________ _________________ 27171.00 9.0% __call_rcu [kernel.kallsyms] 21491.00 7.1% down_write [kernel.kallsyms] 20916.00 6.9% xfs_reclaim_inode [kernel.kallsyms] 20313.00 6.7% radix_tree_delete [kernel.kallsyms] 15828.00 5.3% kmem_cache_free [kernel.kallsyms] 15819.00 5.2% xfs_idestroy_fork [kernel.kallsyms] 14893.00 4.9% is_bad_inode [kernel.kallsyms] 14666.00 4.9% _raw_spin_unlock_irqrestore [kernel.kallsyms] 14191.00 4.7% xfs_reclaim_inode_grab [kernel.kallsyms] 14105.00 4.7% xfs_iunlock [kernel.kallsyms] 10916.00 3.6% __ticket_spin_lock [kernel.kallsyms] 10125.00 3.4% xfs_iflush_cluster [kernel.kallsyms] 8221.00 2.7% xfs_qm_dqdetach [kernel.kallsyms] 7639.00 2.5% xfs_trans_unlocked_item [kernel.kallsyms] 7028.00 2.3% xfs_synchronize_times [kernel.kallsyms] 6974.00 2.3% up_write [kernel.kallsyms] 5870.00 1.9% call_rcu_sched [kernel.kallsyms] 5634.00 1.9% _cond_resched [kernel.kallsyms]Which is showing a similar amount of RCU overhead as the unlink as above. And this while it was doing dentry cache reclaim (~10s sample):
35921.00 15.7% __d_drop [kernel.kallsyms] 30056.00 13.1% __ticket_spin_trylock [kernel.kallsyms] 29066.00 12.7% __ticket_spin_lock [kernel.kallsyms] 19043.00 8.3% __call_rcu [kernel.kallsyms] 10098.00 4.4% iput [kernel.kallsyms] 7013.00 3.1% __shrink_dcache_sb [kernel.kallsyms] 6774.00 3.0% __percpu_counter_add [kernel.kallsyms] 6708.00 2.9% radix_tree_tag_set [kernel.kallsyms] 5362.00 2.3% xfs_inactive [kernel.kallsyms] 5130.00 2.2% __ticket_spin_unlock [kernel.kallsyms] 4884.00 2.1% call_rcu_sched [kernel.kallsyms] 4621.00 2.0% dentry_lru_del [kernel.kallsyms] 3735.00 1.6% bit_waitqueue [kernel.kallsyms] 3727.00 1.6% dentry_iput [kernel.kallsyms] 3473.00 1.5% shrink_icache_memory [kernel.kallsyms] 3279.00 1.4% kfree [kernel.kallsyms] 3101.00 1.4% xfs_perag_get [kernel.kallsyms] 2516.00 1.1% kmem_cache_free [kernel.kallsyms] 2272.00 1.0% shrink_dentry_list [kernel.kallsyms]
Quoted 7 lines
Quoted 3 lines
I've never really seen any signficant dentry cache reclaim overhead in profiles of these workloads before, so this was a bit of a surprise....
call_rcushouldn't be doing much, except for disabling irqs and linking the object into the list. I have a patch somewhere to reduce the irq disable overhead a bit, but it really shouldn't be doing a lot of work.
Could you please enable CONFIG_RCU_TRACE, mount debugfs somewhere, and look at rcu/rcudata? There will be a "ql=" number printed for each CPU, and if that number is too large, __call_rcu() does take what it considers to be corrective action, which can incur some overhead.
If this is the problem, then increasing the value of the qhimark module parameter might help.
If this is not the problem, I could make a patch that disables some of __call_rcu()'s grace-period acceleration code if you are willing to try it out.
Quoted 6 lines
Sometimes you find that touching the rcu head field needs to get a cacheline exclusive, so a bit of work gets transferred there....
But it may also be something going a bit wrong in RCU. I blew it up once already, after the
files_locksplitup that enabled all CPUs to create and destroy files :)
I would certainly like the opportunity to fix any bugs that might be in RCU... ;-)
Thanx, Paul
Quoted 195 lines · Paul E. McKenney
Quoted 181 lines · Nick Piggin
Quoted 73 lines · Dave Chinner
Quoted 72 lines · Dave Chinner
Quoted 65 lines · Nick Piggin
Quoted 55 lines · Dave Chinner
Quoted 11 lines · Nick Piggin
git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin.gitvfs-scale-workingHere is an new set of vfs patches for review, not that there was much interest last time they were posted. It is structured like:
* preparation patches
* introduce new locks to take overdcache_lock, then remove it
* cleaning up and reworking things for new locks
* rcu-walk path walking
* start on some fine grained locking stepsStress test doing:
single thread 50M inode create
single thread rm -rf
2-way 50M inode create
2-way rm -rf
4-way 50M inode create
4-way rm -rf
8-way 50M inode create
8-way rm -rf
8-way 250M inode create
8-way rm -rfFailed about 5 minutes into the "4-way rm -rf" (~3 hours into the test) with a CPU stuck spinning on here:
[37372.084012] NMI backtrace for cpu 5 [37372.084012] CPU 5 [37372.084012] Modules linked in: [37372.084012] [37372.084012] Pid: 15214, comm: rm Not tainted 2.6.37-rc4-dgc+ #797 /Bochs [37372.084012] RIP: 0010:[<ffffffff810643c4>] [<ffffffff810643c4>] __ticket_spin_lock+0x14/0x20 [37372.084012] RSP: 0018:ffff880114643c98 EFLAGS: 00000213 [37372.084012] RAX: 0000000000008801 RBX: ffff8800687be6c0 RCX: ffff8800c4eb2688 [37372.084012] RDX: ffff880114643d38 RSI: ffff8800dfd4ea80 RDI: ffff880114643d14 [37372.084012] RBP: ffff880114643c98 R08: 0000000000000003 R09: 0000000000000000 [37372.084012] R10: 0000000000000000 R11: dead000000200200 R12: ffff880114643d14 [37372.084012] R13: ffff880114643cb8 R14: ffff880114643d38 R15: ffff8800687be71c [37372.084012] FS: 00007fd6d7c93700(0000) GS:ffff8800dfd40000(0000) knlGS:0000000000000000 [37372.084012] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [37372.084012] CR2: 0000000000bbd108 CR3: 0000000107146000 CR4: 00000000000006e0 [37372.084012] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [37372.084012] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [37372.084012] Process rm (pid: 15214, threadinfo ffff880114642000, task ffff88011b16f890) [37372.084012] Stack: [37372.084012] ffff880114643ca8 ffffffff81ad044e ffff880114643cf8 ffffffff81167ae7 [37372.084012] 0000000000000000 ffff880114643d38 000000000000000e ffff88011901d800 [37372.084012] ffff8800cdb7cf5c ffff88011901d8e0 0000000000000000 0000000000000000 [37372.084012] Call Trace: [37372.084012] [<ffffffff81ad044e>] _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff81167ae7>] shrink_dentry_list+0x47/0x370 [37372.084012] [<ffffffff81167f5e>] __shrink_dcache_sb+0x14e/0x1e0Quoted 8 lines
[37372.084012] [<ffffffff81168456>] shrink_dcache_parent+0x276/0x2d0 [37372.084012] [<ffffffff81ad044e>] ? _raw_spin_lock+0xe/0x20 [37372.084012] [<ffffffff8115daa2>] dentry_unhash+0x42/0x80 [37372.084012] [<ffffffff8115db48>] vfs_rmdir+0x68/0x100 [37372.084012] [<ffffffff8115fd93>] do_rmdir+0x113/0x130 [37372.084012] [<ffffffff8114f5ad>] ? filp_close+0x5d/0x90 [37372.084012] [<ffffffff8115fde5>] sys_unlinkat+0x35/0x40 [37372.084012] [<ffffffff8103a002>] system_call_fastpath+0x16/0x1bQuoted 3 lines
OK good, with any luck, that's the same bug.
Is this XFS?
Yes.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Is there any concurrent activity happening on the same dentries?
Not from an application perspective.
Quoted 1 line
Ie. are the rm -rf threads running on the same directories,
No, each thread operating on a different directory.
This is probably fixed by the same patch as the lockdep splat trace.
Quoted 96 lines
Quoted 5 lines
Quoted 1 line
or is there any reclaim happening in the background?
IIRC, kswapd was consuming about 5-10% of a CPU during parallel unlink tests. Mainly reclaiming XFS inodes, I think, but there may be dentry cache reclaim going as well.
Turns out that the kswapd peaks are upwards of 50% of a CPU for a few seconds, then idle for 10-15s. Typical perf top output of kswapd while it is active during unlinks is:
samples pcnt function DSO _______ _____ ___________________________ _________________ 17168.00 10.2% __call_rcu [kernel.kallsyms] 13223.00 7.8% kmem_cache_free [kernel.kallsyms] 12917.00 7.6% down_write [kernel.kallsyms] 12665.00 7.5% xfs_iunlock [kernel.kallsyms] 10493.00 6.2% xfs_reclaim_inode_grab [kernel.kallsyms] 9314.00 5.5% __lookup_tag [kernel.kallsyms] 9040.00 5.4% radix_tree_delete [kernel.kallsyms] 8694.00 5.1% is_bad_inode [kernel.kallsyms] 7639.00 4.5% __ticket_spin_lock [kernel.kallsyms] 6821.00 4.0% _raw_spin_unlock_irqrestore [kernel.kallsyms] 5484.00 3.2% __d_drop [kernel.kallsyms] 5114.00 3.0% xfs_reclaim_inode [kernel.kallsyms] 4626.00 2.7% __rcu_process_callbacks [kernel.kallsyms] 3556.00 2.1% up_write [kernel.kallsyms] 3206.00 1.9% _cond_resched [kernel.kallsyms] 3129.00 1.9% xfs_qm_dqdetach [kernel.kallsyms] 2327.00 1.4% radix_tree_tag_clear [kernel.kallsyms] 2327.00 1.4% call_rcu_sched [kernel.kallsyms] 2262.00 1.3% __ticket_spin_unlock [kernel.kallsyms] 2215.00 1.3% xfs_ilock [kernel.kallsyms] 2200.00 1.3% radix_tree_gang_lookup_tag [kernel.kallsyms] 1982.00 1.2% xfs_reclaim_inodes_ag [kernel.kallsyms] 1736.00 1.0% xfs_trans_unlocked_item [kernel.kallsyms] 1707.00 1.0% __ticket_spin_trylock [kernel.kallsyms] 1688.00 1.0% xfs_perag_get_tag [kernel.kallsyms] 1660.00 1.0% flat_send_IPI_mask [kernel.kallsyms] 1538.00 0.9% xfs_inode_item_destroy [kernel.kallsyms] 1312.00 0.8% __shrink_dcache_sb [kernel.kallsyms] 940.00 0.6% xfs_perag_put [kernel.kallsyms]So there is some dentry cache reclaim going on.
FWIW, it appears there is quite a lot of RCU freeing overhead (~15% more CPU time) in the work kswapd is doing during these unlinks, too. I just had a look at kswapd when a 8-way create is running - it's running at 50-60% of a cpu for seconds at a time. I caught this while it was doing pure XFS inode cache reclaim (~10s sample, kswapd reclaimed ~1M inodes):
samples pcnt function DSO _______ _____ ___________________________ _________________ 27171.00 9.0% __call_rcu [kernel.kallsyms] 21491.00 7.1% down_write [kernel.kallsyms] 20916.00 6.9% xfs_reclaim_inode [kernel.kallsyms] 20313.00 6.7% radix_tree_delete [kernel.kallsyms] 15828.00 5.3% kmem_cache_free [kernel.kallsyms] 15819.00 5.2% xfs_idestroy_fork [kernel.kallsyms] 14893.00 4.9% is_bad_inode [kernel.kallsyms] 14666.00 4.9% _raw_spin_unlock_irqrestore [kernel.kallsyms] 14191.00 4.7% xfs_reclaim_inode_grab [kernel.kallsyms] 14105.00 4.7% xfs_iunlock [kernel.kallsyms] 10916.00 3.6% __ticket_spin_lock [kernel.kallsyms] 10125.00 3.4% xfs_iflush_cluster [kernel.kallsyms] 8221.00 2.7% xfs_qm_dqdetach [kernel.kallsyms] 7639.00 2.5% xfs_trans_unlocked_item [kernel.kallsyms] 7028.00 2.3% xfs_synchronize_times [kernel.kallsyms] 6974.00 2.3% up_write [kernel.kallsyms] 5870.00 1.9% call_rcu_sched [kernel.kallsyms] 5634.00 1.9% _cond_resched [kernel.kallsyms]Which is showing a similar amount of RCU overhead as the unlink as above. And this while it was doing dentry cache reclaim (~10s sample):
35921.00 15.7% __d_drop [kernel.kallsyms] 30056.00 13.1% __ticket_spin_trylock [kernel.kallsyms] 29066.00 12.7% __ticket_spin_lock [kernel.kallsyms] 19043.00 8.3% __call_rcu [kernel.kallsyms] 10098.00 4.4% iput [kernel.kallsyms] 7013.00 3.1% __shrink_dcache_sb [kernel.kallsyms] 6774.00 3.0% __percpu_counter_add [kernel.kallsyms] 6708.00 2.9% radix_tree_tag_set [kernel.kallsyms] 5362.00 2.3% xfs_inactive [kernel.kallsyms] 5130.00 2.2% __ticket_spin_unlock [kernel.kallsyms] 4884.00 2.1% call_rcu_sched [kernel.kallsyms] 4621.00 2.0% dentry_lru_del [kernel.kallsyms] 3735.00 1.6% bit_waitqueue [kernel.kallsyms] 3727.00 1.6% dentry_iput [kernel.kallsyms] 3473.00 1.5% shrink_icache_memory [kernel.kallsyms] 3279.00 1.4% kfree [kernel.kallsyms] 3101.00 1.4% xfs_perag_get [kernel.kallsyms] 2516.00 1.1% kmem_cache_free [kernel.kallsyms] 2272.00 1.0% shrink_dentry_list [kernel.kallsyms]Quoted 7 lines
Quoted 3 lines
I've never really seen any signficant dentry cache reclaim overhead in profiles of these workloads before, so this was a bit of a surprise....
call_rcushouldn't be doing much, except for disabling irqs and linking the object into the list. I have a patch somewhere to reduce the irq disable overhead a bit, but it really shouldn't be doing a lot of work.Could you please enable
CONFIG_RCU_TRACE, mount debugfs somewhere, and look at rcu/rcudata? There will be a "ql=" number printed for each CPU, and if that number is too large,__call_rcu()does take what it considers to be corrective action, which can incur some overhead.
Quoted 6 lines
If this is the problem, then increasing the value of the qhimark module parameter might help.
If this is not the problem, I could make a patch that disables some of __call_rcu()'s grace-period acceleration code if you are willing to try it out.
Another thing that might help is to reduce the value of CONFIG_RCU_FANOUT to something like 16. If this does help, then there is a reasonably straightforward change I can make to RCU.
Thanx, Paul
Quoted 11 lines
Quoted 6 lines
Sometimes you find that touching the rcu head field needs to get a cacheline exclusive, so a bit of work gets transferred there....
But it may also be something going a bit wrong in RCU. I blew it up once already, after the
files_locksplitup that enabled all CPUs to create and destroy files :)I would certainly like the opportunity to fix any bugs that might be in RCU... ;-)
Thanx, Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 11/46] fs: dcache scale hash
In reply to Dave ChinnerQuoted 10 lines · Dave Chinner
Quoted 9 lines · Nick Piggin
Quoted 7 lines · Dave Chinner
Quoted 3 lines · Nick Piggin
Necessary changes to prevent bad ugliness resulting, or preventing repeated steps for the particular changes, etc. of course. Killing un related functions no.
Ok, I get the picture. You don't want a code review, you want a rubber stamp. Find someone else to get it from.
Quoted 6 lines
Quoted 3 lines
Of course I want code review. I am not going to just do everything you say that I don't agree with, but I will explain why every time (as I have done to all your points).
Which generally comes down to "I disagree with you". That's hard to argue against because you aren't willing to compromise.
I have been trying to explain my reasoning. For example, the suggestion to change _d_rehash and to put by-address ordering of locking 2 dentries in its own function I simply said that I don't want to pull in such changes because they're not related or really touched by the patches.
I think that's reasonable, and so if I have a reasonable objection to a minor issue, then I think we should get past it.
Quoted 5 lines
So, to address your next comment, I'll restate what I was proposing. That is, to ensure all the
d_flagsaccesses protected byd_lockas an initial patch rather than cleaning it up in an ad-hoc fashion later on, such as this later patch in your series:
Quoted 8 lines
[PATCH 14/46] fs: dcache scale
d_unhashedwhich has the description:
Protect
d_unhashed(dentry)condition withd_lock.which illustrates my point that not all accesses to
d_flagsare currently protected byd_lockas you are asserting. Hence:
It depends what you mean by accesses to d_flags.
No, not all of them are, because there are in fact some cases where d_flags is read without any locking, when races don't matter or aren't applicable.
But all writes to d_flags, in code where the dentry is live and there can be concurrent writes to d_flags *are* protected by d_lock.
d_unhashed() is defined to:
Returns true if the dentry passed is not currently hashed.
So what I have called the d_unhashed condition, I mean the combination of DCACHE_UNHASHED and dentry membership on the hash list.
I'll improve that changelog because now you've brought it to my attention I agree it's not very good.
Quoted 4 lines
Quoted 2 lines
I would prefer more in-depth review than from someone who doesn't know
d_lockprotectsd_flags,Your implication about my competence is incorrect and entirely
Well you said that my patch adds d_flags protection in bits and pieces in a random manner. d_flags is already protected by d_lock upstream which I explained (nicely).
Quoted 2 lines
inappropriate. Ad hominen attacks don't improve your argument or encourage other people to review your code.
Well you keep escalating it too, like you swore at me when I try several times to explain an issue.
http://marc.info/?l=linux-fsdevel&m=129193745921777&w=2
Quoted 4 lines
Quoted 2 lines
but any and all help is welcome. Even minor
nitpicking or cleanups are welcome if they are relevant to the patches.If _you_ decide they are relevant.
There is give an take.
Quoted 9 lines
Nick, in the past couple of months you've burnt everyone who has tried to review your changes in any meaningful way. Nobody wants to engage with you because you've aggressively disagreed with every significant change that has been requested. You have shown no desire to compromise, instead you argue that you are right until you've had the last word, and you have frequently resorted to condesending and disrespectful attacks on reviewers. You would do well to keep that in mind next time you wonder why nobody is stepping up to review your code.
This is exactly what you and Christoph did, to me, actually. And you're wrong, nobody was reviewing my code long before that little episode. I certainly did compromise with Al, regarding the merging of the inode lock stuff, and although I disagreed with some parts, I said OK fine.
You can't seem to concede a single time that I am right or have a valid point. The best you can possibly manage to to go silent (and then maybe bring it up again a few weeks later). This is perhaps why I appear so insolent, because when I disagree with you, I'm wrong so my reasoning must be irrelevant. It just keeps happening (recently again with the vfs percpu counters thread).
So as far as I can see, there never was a bridge there to begin with. I wish we could work together because I don't in fact question your competence or intelligence, but it seems you do mine.
Re: [PATCH 11/46] fs: dcache scale hash
In reply to Dave ChinnerQuoted 6 lines · Dave Chinner
Quoted 2 lines
I would prefer more in-depth review than from someone who doesn't know
d_lockprotectsd_flags,Your implication about my competence is incorrect and entirely inappropriate. Ad hominen attacks don't improve your argument or encourage other people to review your code.
I'll also just add that if you don't like ad-hominen attacks, you shouldn't have made implications about my integrity and honesty by accusing me of wanting a rubber stamp, rather than a real review. Which was before I suggested that you were confused about d_flags locking, you'll note.
Re: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
In reply to Nick PigginQuoted 18 lines · Nick Piggin
The remaining usages for
dcache_lockis to allow atomic, multi-step read-side operations over the directory tree by excluding modifications to the tree. Also, to walk in theleaf->rootdirection in the tree where we don't have a naturald_lockordering.This could be accomplished by taking every
d_lock, but this would mean a huge number of locks and actually gets very tricky.Solve this instead by using the rename seqlock for multi-step read-side operations, retry in case of a rename so we don't walk up the wrong parent. Concurrent dentry insertions are not serialised against. Concurrent deletes are tricky when walking up the directory: our parent might have been deleted when dropping locks so also need to check and retry for that.
We can also use the rename lock in cases where livelock is a worry (and it is introduced in subsequent patch).
Signed-off-by Nick Piggin <[email protected]>
..
fs/dcache.c static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent) · line 244
Quoted 8 lines
fs/dcache.c +1
-0@@ -237,6 +238,7 @@ static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent) __releases(dcache_inode_lock) __releases(dcache_lock) { + dentry->d_parent = NULL; list_del(&dentry->d_u.d_child); if (parent) spin_unlock(&parent->d_lock);
There's an issue with ceph as it references the dentry->d_parent(->d_inode) at dentry_release(), so setting dentry->d_parent to NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.
Yehuda
Nick Piggin
reviewerRe: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
Quoted 29 lines · Yehuda Sadeh Weinraub
Quoted 18 lines · Nick Piggin
The remaining usages for
dcache_lockis to allow atomic, multi-step read-side operations over the directory tree by excluding modifications to the tree. Also, to walk in theleaf->rootdirection in the tree where we don't have a naturald_lockordering.This could be accomplished by taking every
d_lock, but this would mean a huge number of locks and actually gets very tricky.Solve this instead by using the rename seqlock for multi-step read-side operations, retry in case of a rename so we don't walk up the wrong parent. Concurrent dentry insertions are not serialised against. Concurrent deletes are tricky when walking up the directory: our parent might have been deleted when dropping locks so also need to check and retry for that.
We can also use the rename lock in cases where livelock is a worry (and it is introduced in subsequent patch).
Signed-off-by Nick Piggin <[email protected]>..
fs/dcache.c static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent) · line 244
Quoted 8 lines
fs/dcache.c +1
-0@@ -237,6 +238,7 @@ static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent) __releases(dcache_inode_lock) __releases(dcache_lock) { + dentry->d_parent = NULL; list_del(&dentry->d_u.d_child); if (parent) spin_unlock(&parent->d_lock);
Quoted 8 lines
There's an issue with ceph as it references the
dentry->d_parent(->d_inode)atdentry_release(), so settingdentry->d_parentto NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.
Hmm, I'll have to think about it. Probably we can check for d_count == 0 rather than parent != NULL I think?
Re: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
Quoted 11 lines · Nick Piggin
On Wed, Jan 19, 2011 at 9:32 AM, Yehuda Sadeh Weinraub
Quoted 8 lines
There's an issue with ceph as it references the
dentry->d_parent(->d_inode)atdentry_release(), so settingdentry->d_parentto NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.
Quoted 3 lines
Hmm, I'll have to think about it. Probably we can check for
d_count== 0 rather than parent != NULL I think?
That'll solve ceph's problem, don't know about how'd affect other stuff. We'll need to know whether this is the solution, or whether we'd need to introduce some other band aid fix.
Thanks,
Yehuda
Nick Piggin
reviewerRe: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
Quoted 12 lines · Yehuda Sadeh Weinraub
Quoted 11 lines · Nick Piggin
On Wed, Jan 19, 2011 at 9:32 AM, Yehuda Sadeh Weinraub
Quoted 8 lines
There's an issue with ceph as it references the
dentry->d_parent(->d_inode)atdentry_release(), so settingdentry->d_parentto NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.
Quoted 7 lines
Quoted 3 lines
Hmm, I'll have to think about it. Probably we can check for
d_count== 0 rather than parent != NULL I think?That'll solve ceph's problem, don't know about how'd affect other stuff. We'll need to know whether this is the solution, or whether we'd need to introduce some other band aid fix.
No I think it will work fine. Basically we just need to know whether we have been deleted, and if so then we restart rather than walking back up the parent.
I'll send a patch in a few days. For the meantime, it's a rathe small window for ceph to worry about. So we'll have something before -rc2 which should be OK.
Re: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
Quoted 22 lines · Nick Piggin
Quoted 12 lines · Yehuda Sadeh Weinraub
Quoted 11 lines · Nick Piggin
On Wed, Jan 19, 2011 at 9:32 AM, Yehuda Sadeh Weinraub
Quoted 8 lines
There's an issue with ceph as it references the
dentry->d_parent(->d_inode)atdentry_release(), so settingdentry->d_parentto NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.Quoted 7 lines
Quoted 3 lines
Hmm, I'll have to think about it. Probably we can check for
d_count== 0 rather than parent != NULL I think?That'll solve ceph's problem, don't know about how'd affect other stuff. We'll need to know whether this is the solution, or whether we'd need to introduce some other band aid fix.
Quoted 8 lines
No I think it will work fine. Basically we just need to know whether we have been deleted, and if so then we restart rather than walking back up the parent.
I'll send a patch in a few days. For the meantime, it's a rathe small window for ceph to worry about. So we'll have something before -rc2 which should be OK.
I guess that it's a bit late for -rc2, should we assume that it'll be on -rc3?
Thanks,
Yehuda
Nick Piggin
reviewerRe: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
Quoted 27 lines · Yehuda Sadeh Weinraub
Quoted 26 lines · Nick Piggin
Quoted 12 lines · Yehuda Sadeh Weinraub
Quoted 11 lines · Nick Piggin
On Wed, Jan 19, 2011 at 9:32 AM, Yehuda Sadeh Weinraub
Quoted 8 lines
There's an issue with ceph as it references the
dentry->d_parent(->d_inode)atdentry_release(), so settingdentry->d_parentto NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.Quoted 7 lines
Quoted 3 lines
Hmm, I'll have to think about it. Probably we can check for
d_count== 0 rather than parent != NULL I think?That'll solve ceph's problem, don't know about how'd affect other stuff. We'll need to know whether this is the solution, or whether we'd need to introduce some other band aid fix.
No I think it will work fine. Basically we just need to know whether we have been deleted, and if so then we restart rather than walking back up the parent.
Quoted 6 lines
Quoted 4 lines
I'll send a patch in a few days. For the meantime, it's a rathe small window for ceph to worry about. So we'll have something before -rc2 which should be OK.
I guess that it's a bit late for -rc2, should we assume that it'll be on -rc3?
Yeah, I'm sorry I've been travelling and a bit disconnected.
NFS folk are having a similar problem and looks like similar proposed fix will do it.
http://marc.info/?l=linux-fsdevel&m=129599823927039&w=2
So I think it is the best way to go to restore behaviour back to what filesystems already expect, to avoid more surprises in future.
Thanks,
Nick
Re: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
Quoted 38 lines · Nick Piggin
Quoted 27 lines · Yehuda Sadeh Weinraub
Quoted 26 lines · Nick Piggin
Quoted 12 lines · Yehuda Sadeh Weinraub
Quoted 11 lines · Nick Piggin
On Wed, Jan 19, 2011 at 9:32 AM, Yehuda Sadeh Weinraub
Quoted 8 lines
There's an issue with ceph as it references the
dentry->d_parent(->d_inode)atdentry_release(), so settingdentry->d_parentto NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.Quoted 7 lines
Quoted 3 lines
Hmm, I'll have to think about it. Probably we can check for
d_count== 0 rather than parent != NULL I think?That'll solve ceph's problem, don't know about how'd affect other stuff. We'll need to know whether this is the solution, or whether we'd need to introduce some other band aid fix.
No I think it will work fine. Basically we just need to know whether we have been deleted, and if so then we restart rather than walking back up the parent.
Quoted 6 lines
Quoted 4 lines
I'll send a patch in a few days. For the meantime, it's a rathe small window for ceph to worry about. So we'll have something before -rc2 which should be OK.
I guess that it's a bit late for -rc2, should we assume that it'll be on -rc3?
Yeah, I'm sorry I've been travelling and a bit disconnected.
Quoted 7 lines
NFS folk are having a similar problem and looks like similar proposed fix will do it.
http://marc.info/?l=linux-fsdevel&m=129599823927039&w=2
So I think it is the best way to go to restore behaviour back to what filesystems already expect, to avoid more surprises in future.
I think the following BUG indicates I'm hitting this problem? All I have to do to cause it is unlink a file.
My ceph client kernel is 8dbdea8444 (master branch) from
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
+ e41cdbb6c5 (master branch) + a3f5274e53 (unstable branch) from git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.git
Are there any patches available for this I can test?
Thanks -- Jim
[ 1471.018973] BUG: unable to handle kernel NULL pointer dereference at 0000000000000030 [ 1471.019909] IP: [<ffffffffa0748275>] ceph_dentry_release+0x31/0x148 [ceph] [ 1471.019909] PGD 121fb9067 PUD 120520067 PMD 0 [ 1471.019909] Oops: 0000 [#1] SMP [ 1471.019909] last sysfs file: /sys/block/md0/range [ 1471.019909] CPU 1 [ 1471.019909] Modules linked in: ceph libceph ipt_MASQUERADE iptable_nat nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_state nf_conntrack ipt_REJECT xt_tcpudp iptable_filter ip_tables x_tables bridge stp i2c_dev i2c_core ext3 jbd be2iscsi iscsi_boot_sysfs iscsi] [ 1471.019909] [ 1471.019909] Pid: 20, comm: kworker/1:1 Not tainted 2.6.38-rc3-00247-g4a9cd22 #13 0UR033/PowerEdge 1950 [ 1471.019909] RIP: 0010:[<ffffffffa0748275>] [<ffffffffa0748275>] ceph_dentry_release+0x31/0x148 [ceph] [ 1471.019909] RSP: 0018:ffff88012b09ba20 EFLAGS: 00010286 [ 1471.019909] RAX: 0000000000000000 RBX: ffff880129e3f0c0 RCX: ffff88011d448280 [ 1471.019909] RDX: 000000000000cbc0 RSI: 0000000000000001 RDI: ffff880129e3f0c0 [ 1471.019909] RBP: ffff88012b09ba60 R08: 0000000000000000 R09: ffff88012b09b9e0 [ 1471.019909] R10: 000001000000fa40 R11: ffff88012b09ba20 R12: ffff88011d448840 [ 1471.019909] R13: 0000000000000000 R14: ffff880129e3f0c0 R15: ffff88011d416000 [ 1471.019909] FS: 0000000000000000(0000) GS:ffff8800cfc40000(0000) knlGS:0000000000000000 [ 1471.019909] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 1471.019909] CR2: 0000000000000030 CR3: 0000000128a1b000 CR4: 00000000000006e0 [ 1471.019909] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1471.019909] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 1471.019909] Process kworker/1:1 (pid: 20, threadinfo ffff88012b09a000, task ffff88012b0a8000) [ 1471.019909] Stack: [ 1471.019909] ffff88011d448840 ffff880128f89800 fffffffffffffffe ffff880129e3f0c0 [ 1471.019909] ffff88011d448840 ffff880129fa70c0 0000000000000001 ffff880120f86000 [ 1471.019909] ffff88012b09ba80 ffffffff81104007 ffff880129e3f0c0 ffff880129fa70c0 [ 1471.019909] Call Trace: [ 1471.019909] [<ffffffff81104007>] d_free+0x37/0x5c [ 1471.019909] [<ffffffff811048d4>] dentry_kill+0x11a/0x126 [ 1471.019909] [<ffffffff8110523d>] dput+0xbc/0xc9 [ 1471.019909] [<ffffffffa076099c>] ceph_mdsc_release_request+0xa9/0x117 [ceph] [ 1471.019909] [<ffffffffa07608f3>] ? ceph_mdsc_release_request+0x0/0x117 [ceph] [ 1471.019909] [<ffffffff811ab542>] kref_put+0x43/0x4f [ 1471.019909] [<ffffffffa075bab9>] ceph_mdsc_put_request+0x1c/0x1e [ceph] [ 1471.019909] [<ffffffffa075fc26>] dispatch+0xbdc/0x1282 [ceph] [ 1471.019909] [<ffffffff81192c70>] ? chksum_update+0x15/0x1d [ 1471.019909] [<ffffffff8118cf30>] ? crypto_shash_update+0x1f/0x21 [ 1471.019909] [<ffffffff812cf943>] ? kernel_recvmsg+0x3a/0x46 [ 1471.019909] [<ffffffffa0704c69>] ? ceph_tcp_recvmsg+0x4e/0x5b [libceph] [ 1471.019909] [<ffffffffa07066ce>] try_read+0x1363/0x1508 [libceph] [ 1471.019909] [<ffffffff81030af3>] ? should_resched+0xe/0x2f [ 1471.019909] [<ffffffffa0707318>] con_work+0xec/0x1426 [libceph] [ 1471.019909] [<ffffffff81030adb>] ? need_resched+0x23/0x2d [ 1471.019909] [<ffffffff8136f43a>] ? schedule+0x68d/0x6a7 [ 1471.019909] [<ffffffff8104e9d5>] ? add_timer+0x1c/0x1e [ 1471.019909] [<ffffffff81058341>] ? queue_delayed_work_on+0xde/0xf2 [ 1471.019909] [<ffffffff81056dc5>] process_one_work+0x16e/0x26a [ 1471.019909] [<ffffffffa070722c>] ? con_work+0x0/0x1426 [libceph] [ 1471.019909] [<ffffffff8105852d>] ? worker_thread+0x0/0x183 [ 1471.019909] [<ffffffff810585f0>] worker_thread+0xc3/0x183 [ 1471.019909] [<ffffffff8105be62>] kthread+0x72/0x7a [ 1471.019909] [<ffffffff81003914>] kernel_thread_helper+0x4/0x10 [ 1471.019909] [<ffffffff8105bdf0>] ? kthread+0x0/0x7a [ 1471.019909] [<ffffffff81003910>] ? kernel_thread_helper+0x0/0x10 [ 1471.019909] Code: 41 56 41 55 41 54 53 48 83 ec 18 0f 1f 44 00 00 48 8b 47 18 45 31 ed 4c 8b 7f 78 49 89 fe 48 c7 45 d0 fe ff ff ff 48 39 c7 74 14 <4c> 8b 68 30 4d 85 ed 74 0b 49 8b 85 08 fd ff ff 48 89 45 d0 80 [ 1471.019909] RIP [<ffffffffa0748275>] ceph_dentry_release+0x31/0x148 [ceph] [ 1471.019909] RSP <ffff88012b09ba20> [ 1471.019909] CR2: 0000000000000030 [ 1471.455942] ---[ end trace 782e52b3ca82de3c ]--- [ 1471.460581] BUG: unable to handle kernel paging request at fffffffffffffff8 [ 1471.461551] IP: [<ffffffff8105bb0e>] kthread_data+0x10/0x16 [ 1471.461551] PGD 1805067 PUD 1806067 PMD 0 [ 1471.461551] Oops: 0000 [#2] SMP [ 1471.461551] last sysfs file: /sys/block/md0/range [ 1471.461551] CPU 1 [ 1471.461551] Modules linked in: ceph libceph ipt_MASQUERADE iptable_nat nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_state nf_conntrack ipt_REJECT xt_tcpudp iptable_filter ip_tables x_tables bridge stp i2c_dev i2c_core ext3 jbd be2iscsi iscsi_boot_sysfs iscsi] [ 1471.461551] [ 1471.461551] Pid: 20, comm: kworker/1:1 Tainted: G D 2.6.38-rc3-00247-g4a9cd22 #13 0UR033/PowerEdge 1950 [ 1471.461551] RIP: 0010:[<ffffffff8105bb0e>] [<ffffffff8105bb0e>] kthread_data+0x10/0x16 [ 1471.461551] RSP: 0018:ffff88012b09b5b8 EFLAGS: 00010092 [ 1471.461551] RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffff88012b0a8000 [ 1471.461551] RDX: 000000000000cbc0 RSI: 0000000000000001 RDI: ffff88012b0a8000 [ 1471.461551] RBP: ffff88012b09b5b8 R08: ffff8800cfc54f40 R09: dead000000200200 [ 1471.461551] R10: dead000000200200 R11: 0000000000000002 R12: 00007ffffffff000 [ 1471.461551] R13: 0000000000000001 R14: ffff8800cfc51cc0 R15: 0000000000000001 [ 1471.461551] FS: 0000000000000000(0000) GS:ffff8800cfc40000(0000) knlGS:0000000000000000 [ 1471.461551] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 1471.461551] CR2: fffffffffffffff8 CR3: 0000000128a1b000 CR4: 00000000000006e0 [ 1471.461551] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1471.461551] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 1471.461551] Process kworker/1:1 (pid: 20, threadinfo ffff88012b09a000, task ffff88012b0a8000) [ 1471.461551] Stack: [ 1471.461551] ffff88012b09b5e8 ffffffff810583d7 ffff88012b09b5f8 0000000000000001 [ 1471.461551] 00007ffffffff000 0000000000011cc0 ffff88012b09b6f8 ffffffff8136ef22 [ 1471.461551] ffff88012b09b618 ffff88012b0a8000 ffff88012b6b0850 ffff88012b0a83a0 [ 1471.461551] Call Trace: [ 1471.461551] [<ffffffff810583d7>] wq_worker_sleeping+0x1a/0x87 [ 1471.461551] [<ffffffff8136ef22>] schedule+0x175/0x6a7 [ 1471.461551] [<ffffffff8108b8d0>] ? call_rcu_sched+0x15/0x17 [ 1471.461551] [<ffffffff810e8b0e>] ? __slab_free+0x52/0xe9 [ 1471.461551] [<ffffffff8108b8d0>] ? call_rcu_sched+0x15/0x17 [ 1471.461551] [<ffffffff810443f2>] ? release_task+0x32b/0x343 [ 1471.461551] [<ffffffff810601df>] ? switch_task_namespaces+0x1d/0x51 [ 1471.461551] [<ffffffff810456cf>] do_exit+0x678/0x692 [ 1471.461551] [<ffffffff81371b59>] oops_end+0xb7/0xbf [ 1471.461551] [<ffffffff81026de1>] no_context+0x1fa/0x209 [ 1471.461551] [<ffffffff81027076>] __bad_area_nosemaphore+0x187/0x1aa [ 1471.461551] [<ffffffff810b517d>] ? __pagevec_free+0x70/0x8c [ 1471.461551] [<ffffffff810b8ab2>] ? hpage_nr_pages+0x1a/0x2c [ 1471.461551] [<ffffffff81027123>] bad_area_nosemaphore+0x13/0x18 [ 1471.461551] [<ffffffff81373aa5>] do_page_fault+0x175/0x325 [ 1471.461551] [<ffffffff810afe20>] ? find_get_pages+0x44/0xbb [ 1471.461551] [<ffffffffa075070b>] ? list_add+0x11/0x13 [ceph] [ 1471.461551] [<ffffffffa0753773>] ? ceph_put_cap+0xf6/0x12d [ceph] [ 1471.461551] [<ffffffff810b9611>] ? pagevec_lookup+0x24/0x2d [ 1471.461551] [<ffffffff813710df>] page_fault+0x1f/0x30 [ 1471.461551] [<ffffffffa0748275>] ? ceph_dentry_release+0x31/0x148 [ceph] [ 1471.461551] [<ffffffff81104007>] d_free+0x37/0x5c [ 1471.461551] [<ffffffff811048d4>] dentry_kill+0x11a/0x126 [ 1471.461551] [<ffffffff8110523d>] dput+0xbc/0xc9 [ 1471.461551] [<ffffffffa076099c>] ceph_mdsc_release_request+0xa9/0x117 [ceph] [ 1471.461551] [<ffffffffa07608f3>] ? ceph_mdsc_release_request+0x0/0x117 [ceph] [ 1471.461551] [<ffffffff811ab542>] kref_put+0x43/0x4f [ 1471.461551] [<ffffffffa075bab9>] ceph_mdsc_put_request+0x1c/0x1e [ceph] [ 1471.461551] [<ffffffffa075fc26>] dispatch+0xbdc/0x1282 [ceph] [ 1471.461551] [<ffffffff81192c70>] ? chksum_update+0x15/0x1d [ 1471.461551] [<ffffffff8118cf30>] ? crypto_shash_update+0x1f/0x21 [ 1471.461551] [<ffffffff812cf943>] ? kernel_recvmsg+0x3a/0x46 [ 1471.461551] [<ffffffffa0704c69>] ? ceph_tcp_recvmsg+0x4e/0x5b [libceph] [ 1471.461551] [<ffffffffa07066ce>] try_read+0x1363/0x1508 [libceph] [ 1471.461551] [<ffffffff81030af3>] ? should_resched+0xe/0x2f [ 1471.461551] [<ffffffffa0707318>] con_work+0xec/0x1426 [libceph] [ 1471.461551] [<ffffffff81030adb>] ? need_resched+0x23/0x2d [ 1471.461551] [<ffffffff8136f43a>] ? schedule+0x68d/0x6a7 [ 1471.461551] [<ffffffff8104e9d5>] ? add_timer+0x1c/0x1e [ 1471.461551] [<ffffffff81058341>] ? queue_delayed_work_on+0xde/0xf2 [ 1471.461551] [<ffffffff81056dc5>] process_one_work+0x16e/0x26a [ 1471.461551] [<ffffffffa070722c>] ? con_work+0x0/0x1426 [libceph] [ 1471.461551] [<ffffffff8105852d>] ? worker_thread+0x0/0x183 [ 1471.461551] [<ffffffff810585f0>] worker_thread+0xc3/0x183 [ 1471.461551] [<ffffffff8105be62>] kthread+0x72/0x7a [ 1471.461551] [<ffffffff81003914>] kernel_thread_helper+0x4/0x10 [ 1471.461551] [<ffffffff8105bdf0>] ? kthread+0x0/0x7a [ 1471.461551] [<ffffffff81003910>] ? kernel_thread_helper+0x0/0x10 [ 1471.461551] Code: e5 0f 1f 44 00 00 65 48 8b 04 25 80 b5 00 00 48 8b 80 48 03 00 00 8b 40 f0 c9 c3 55 48 89 e5 0f 1f 44 00 00 48 8b 87 48 03 00 00 <48> 8b 40 f8 c9 c3 55 48 89 e5 0f 1f 44 00 00 48 8d 47 08 c7 07 [ 1471.461551] RIP [<ffffffff8105bb0e>] kthread_data+0x10/0x16 [ 1471.461551] RSP <ffff88012b09b5b8> [ 1471.461551] CR2: fffffffffffffff8 [ 1471.461551] ---[ end trace 782e52b3ca82de3d ]--- [ 1471.461551] Fixing recursive fault but reboot is needed!
Quoted 8 lines
Thanks,
Nick
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
Quoted 51 lines · Jim Schutt
Quoted 38 lines · Nick Piggin
Quoted 27 lines · Yehuda Sadeh Weinraub
Quoted 26 lines · Nick Piggin
Quoted 12 lines · Yehuda Sadeh Weinraub
Quoted 11 lines · Nick Piggin
On Wed, Jan 19, 2011 at 9:32 AM, Yehuda Sadeh Weinraub
Quoted 8 lines
There's an issue with ceph as it references the
dentry->d_parent(->d_inode)atdentry_release(), so settingdentry->d_parentto NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.Quoted 7 lines
Quoted 3 lines
Hmm, I'll have to think about it. Probably we can check for
d_count== 0 rather than parent != NULL I think?That'll solve ceph's problem, don't know about how'd affect other stuff. We'll need to know whether this is the solution, or whether we'd need to introduce some other band aid fix.
No I think it will work fine. Basically we just need to know whether we have been deleted, and if so then we restart rather than walking back up the parent.
Quoted 6 lines
Quoted 4 lines
I'll send a patch in a few days. For the meantime, it's a rathe small window for ceph to worry about. So we'll have something before -rc2 which should be OK.
I guess that it's a bit late for -rc2, should we assume that it'll be on -rc3?
Yeah, I'm sorry I've been travelling and a bit disconnected.
Quoted 7 lines
NFS folk are having a similar problem and looks like similar proposed fix will do it.
http://marc.info/?l=linux-fsdevel&m=129599823927039&w=2
So I think it is the best way to go to restore behaviour back to what filesystems already expect, to avoid more surprises in future.
I think the following BUG indicates I'm hitting this problem? All I have to do to cause it is unlink a file.
Quoted 9 lines
My ceph client kernel is
8dbdea8444(master branch) from
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
+e41cdbb6c5(master branch) +a3f5274e53(unstable branch) fromgit://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.gitAre there any patches available for this I can test?
Thanks -- Jim
It does look like this specific problem.
You can try cherry-pick commit 9c3db35 off the ceph git. It is just a temporary workaround, and it wasn't tested too much. Hopefully Nick will push his fix soon so that it wouldn't be needed.
Thanks,
Yehuda
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
Quoted 59 lines · Yehuda Sadeh Weinraub
Quoted 58 lines · Jim Schutt
Quoted 38 lines · Nick Piggin
Quoted 27 lines · Yehuda Sadeh Weinraub
Quoted 26 lines · Nick Piggin
Quoted 12 lines · Yehuda Sadeh Weinraub
Quoted 11 lines · Nick Piggin
On Wed, Jan 19, 2011 at 9:32 AM, Yehuda Sadeh Weinraub
Quoted 8 lines
There's an issue with ceph as it references the
dentry->d_parent(->d_inode)atdentry_release(), so settingdentry->d_parentto NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.Quoted 7 lines
Quoted 3 lines
Hmm, I'll have to think about it. Probably we can check for
d_count== 0 rather than parent != NULL I think?That'll solve ceph's problem, don't know about how'd affect other stuff. We'll need to know whether this is the solution, or whether we'd need to introduce some other band aid fix.
No I think it will work fine. Basically we just need to know whether we have been deleted, and if so then we restart rather than walking back up the parent.
Quoted 6 lines
Quoted 4 lines
I'll send a patch in a few days. For the meantime, it's a rathe small window for ceph to worry about. So we'll have something before -rc2 which should be OK.
I guess that it's a bit late for -rc2, should we assume that it'll be on -rc3?
Yeah, I'm sorry I've been travelling and a bit disconnected.
Quoted 7 lines
NFS folk are having a similar problem and looks like similar proposed fix will do it.
http://marc.info/?l=linux-fsdevel&m=129599823927039&w=2
So I think it is the best way to go to restore behaviour back to what filesystems already expect, to avoid more surprises in future.
I think the following BUG indicates I'm hitting this problem? All I have to do to cause it is unlink a file.
My ceph client kernel is
8dbdea8444(master branch) from
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
+e41cdbb6c5(master branch) +a3f5274e53(unstable branch) fromgit://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.gitAre there any patches available for this I can test?
Quoted 7 lines
Quoted 2 lines
Thanks -- Jim
It does look like this specific problem.
You can try cherry-pick commit 9c3db35 off the ceph git. It is just a temporary workaround, and it wasn't tested too much. Hopefully Nick will push his fix soon so that it wouldn't be needed.
That commit doesn't seem to be in
git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.git
Maybe there's another tree I should be looking at?
Thanks -- Jim
Quoted 8 lines
Thanks,
Yehuda
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
Quoted 7 lines · Jim Schutt
Quoted 4 lines · Yehuda Sadeh Weinraub
It does look like this specific problem.
You can try cherry-pick commit 9c3db35 off the ceph git. It is just a temporary workaround, and it wasn't tested too much. Hopefully Nick will push his fix soon so that it wouldn't be needed.
Quoted 6 lines
That commit doesn't seem to be in
git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.gitMaybe there's another tree I should be looking at?
Thanks -- Jim
Yep:
ceph.newdream.net:/git/ceph-client.git
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
In reply to Yehuda Sadeh WeinraubQuoted 59 lines · Yehuda Sadeh Weinraub
Quoted 58 lines · Jim Schutt
Quoted 38 lines · Nick Piggin
Quoted 27 lines · Yehuda Sadeh Weinraub
Quoted 26 lines · Nick Piggin
Quoted 12 lines · Yehuda Sadeh Weinraub
Quoted 11 lines · Nick Piggin
On Wed, Jan 19, 2011 at 9:32 AM, Yehuda Sadeh Weinraub
Quoted 8 lines
There's an issue with ceph as it references the
dentry->d_parent(->d_inode)atdentry_release(), so settingdentry->d_parentto NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.Quoted 7 lines
Quoted 3 lines
Hmm, I'll have to think about it. Probably we can check for
d_count== 0 rather than parent != NULL I think?That'll solve ceph's problem, don't know about how'd affect other stuff. We'll need to know whether this is the solution, or whether we'd need to introduce some other band aid fix.
No I think it will work fine. Basically we just need to know whether we have been deleted, and if so then we restart rather than walking back up the parent.
Quoted 6 lines
Quoted 4 lines
I'll send a patch in a few days. For the meantime, it's a rathe small window for ceph to worry about. So we'll have something before -rc2 which should be OK.
I guess that it's a bit late for -rc2, should we assume that it'll be on -rc3?
Yeah, I'm sorry I've been travelling and a bit disconnected.
Quoted 7 lines
NFS folk are having a similar problem and looks like similar proposed fix will do it.
http://marc.info/?l=linux-fsdevel&m=129599823927039&w=2
So I think it is the best way to go to restore behaviour back to what filesystems already expect, to avoid more surprises in future.
I think the following BUG indicates I'm hitting this problem? All I have to do to cause it is unlink a file.
My ceph client kernel is
8dbdea8444(master branch) from
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
+e41cdbb6c5(master branch) +a3f5274e53(unstable branch) fromgit://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.gitAre there any patches available for this I can test?
Quoted 7 lines
Quoted 2 lines
Thanks -- Jim
It does look like this specific problem.
You can try cherry-pick commit 9c3db35 off the ceph git. It is just a temporary workaround, and it wasn't tested too much. Hopefully Nick will push his fix soon so that it wouldn't be needed.
That commit fixes my unlink issue, thanks.
I'm happy to use it while things get resolved.
-- Jim
Quoted 8 lines
Thanks,
Yehuda
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 17/46] fs: Use rename lock and RCU for multi-step operations
In reply to Nick PigginQuoted 38 lines · Nick Piggin
Quoted 27 lines · Yehuda Sadeh Weinraub
Quoted 26 lines · Nick Piggin
Quoted 12 lines · Yehuda Sadeh Weinraub
Quoted 11 lines · Nick Piggin
On Wed, Jan 19, 2011 at 9:32 AM, Yehuda Sadeh Weinraub
Quoted 8 lines
There's an issue with ceph as it references the
dentry->d_parent(->d_inode)atdentry_release(), so settingdentry->d_parentto NULL here doesn't work with ceph. Though there is some workaround for it, we would like to be sure that this one is really required so that we don't exacerbate the ugliness. The workaround is to keep a pointer to the parent inode in the private dentry structure, which will be referenced only at the .release() callback. This is clearly not ideal.Quoted 7 lines
Quoted 3 lines
Hmm, I'll have to think about it. Probably we can check for
d_count== 0 rather than parent != NULL I think?That'll solve ceph's problem, don't know about how'd affect other stuff. We'll need to know whether this is the solution, or whether we'd need to introduce some other band aid fix.
No I think it will work fine. Basically we just need to know whether we have been deleted, and if so then we restart rather than walking back up the parent.
Quoted 6 lines
Quoted 4 lines
I'll send a patch in a few days. For the meantime, it's a rathe small window for ceph to worry about. So we'll have something before -rc2 which should be OK.
I guess that it's a bit late for -rc2, should we assume that it'll be on -rc3?
Yeah, I'm sorry I've been travelling and a bit disconnected.
Quoted 8 lines
NFS folk are having a similar problem and looks like similar proposed fix will do it.
http://marc.info/?l=linux-fsdevel&m=129599823927039&w=2
So I think it is the best way to go to restore behaviour back to what filesystems already expect, to avoid more surprises in future.
Hi Nick,
-rc4 is out and that issue is still broken. Do you have that patch
ready or should we push our workaround?
Thanks,
Yehuda