Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromtorvalds/linux

Commitcf40bd1

Browse files
Nick PigginIngo Molnar
Nick Piggin
authored and
Ingo Molnar
committed
lockdep: annotate reclaim context (__GFP_NOFS)
Here is another version, with the incremental patch rolled up, andadded reclaim context annotation to kswapd, and allocation tracingto slab allocators (which may only ever reach the page allocatorin rare cases, so it is good to put annotations here too).Haven't tested this version as such, but it should be getting closerto merge worthy ;)--After noticing some code in mm/filemap.c accidentally perform a __GFP_FSallocation when it should not have been, I thought it might be a good idea totry to catch this kind of thing with lockdep.I coded up a little idea that seems to work. Unfortunately the system has toactually be in __GFP_FS page reclaim, then take the lock, before it will markit. But at least that might still be some orders of magnitude more common(and more debuggable) than an actual deadlock condition, so we have someimprovement I hope (the concept is no less complete than discovery of a lock'sinterrupt contexts).I guess we could even do the same thing with __GFP_IO (normal reclaim), andeven GFP_NOIO locks too... but filesystems will have the most locks and fiddlycode paths, so let's start there and see how it goes.It *seems* to work. I did a quick test.=================================[ INFO: inconsistent lock state ]2.6.28-rc6-00007-ged31348-dirtytorvalds#26---------------------------------inconsistent {in-reclaim-W} -> {ov-reclaim-W} usage.modprobe/8526 [HC0[0]:SC0[0]:HE1:SE1] takes: (testlock){--..}, at: [<ffffffffa0020055>] brd_init+0x55/0x216 [brd]{in-reclaim-W} state was registered at: [<ffffffff80267bdb>] __lock_acquire+0x75b/0x1a60 [<ffffffff80268f71>] lock_acquire+0x91/0xc0 [<ffffffff8070f0e1>] mutex_lock_nested+0xb1/0x310 [<ffffffffa002002b>] brd_init+0x2b/0x216 [brd] [<ffffffff8020903b>] _stext+0x3b/0x170 [<ffffffff80272ebf>] sys_init_module+0xaf/0x1e0 [<ffffffff8020c3fb>] system_call_fastpath+0x16/0x1b [<ffffffffffffffff>] 0xffffffffffffffffirq event stamp: 3929hardirqs last enabled at (3929): [<ffffffff8070f2b5>] mutex_lock_nested+0x285/0x310hardirqs last disabled at (3928): [<ffffffff8070f089>] mutex_lock_nested+0x59/0x310softirqs last enabled at (3732): [<ffffffff8061f623>] sk_filter+0x83/0xe0softirqs last disabled at (3730): [<ffffffff8061f5b6>] sk_filter+0x16/0xe0other info that might help us debug this:1 lock held by modprobe/8526: #0: (testlock){--..}, at: [<ffffffffa0020055>] brd_init+0x55/0x216 [brd]stack backtrace:Pid: 8526, comm: modprobe Not tainted 2.6.28-rc6-00007-ged31348-dirtytorvalds#26Call Trace: [<ffffffff80265483>] print_usage_bug+0x193/0x1d0 [<ffffffff80266530>] mark_lock+0xaf0/0xca0 [<ffffffff80266735>] mark_held_locks+0x55/0xc0 [<ffffffffa0020000>] ? brd_init+0x0/0x216 [brd] [<ffffffff802667ca>] trace_reclaim_fs+0x2a/0x60 [<ffffffff80285005>] __alloc_pages_internal+0x475/0x580 [<ffffffff8070f29e>] ? mutex_lock_nested+0x26e/0x310 [<ffffffffa0020000>] ? brd_init+0x0/0x216 [brd] [<ffffffffa002006a>] brd_init+0x6a/0x216 [brd] [<ffffffffa0020000>] ? brd_init+0x0/0x216 [brd] [<ffffffff8020903b>] _stext+0x3b/0x170 [<ffffffff8070f8b9>] ? mutex_unlock+0x9/0x10 [<ffffffff8070f83d>] ? __mutex_unlock_slowpath+0x10d/0x180 [<ffffffff802669ec>] ? trace_hardirqs_on_caller+0x12c/0x190 [<ffffffff80272ebf>] sys_init_module+0xaf/0x1e0 [<ffffffff8020c3fb>] system_call_fastpath+0x16/0x1bSigned-off-by: Nick Piggin <npiggin@suse.de>Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent6f2b9b9 commitcf40bd1

File tree

10 files changed

+254
-17
lines changed

10 files changed

+254
-17
lines changed

‎include/linux/lockdep.h‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ enum lock_usage_bit
2727
LOCK_USED=0,
2828
LOCK_USED_IN_HARDIRQ,
2929
LOCK_USED_IN_SOFTIRQ,
30+
LOCK_USED_IN_RECLAIM_FS,
3031
LOCK_ENABLED_SOFTIRQS,
3132
LOCK_ENABLED_HARDIRQS,
33+
LOCK_HELD_OVER_RECLAIM_FS,
3234
LOCK_USED_IN_HARDIRQ_READ,
3335
LOCK_USED_IN_SOFTIRQ_READ,
36+
LOCK_USED_IN_RECLAIM_FS_READ,
3437
LOCK_ENABLED_SOFTIRQS_READ,
3538
LOCK_ENABLED_HARDIRQS_READ,
39+
LOCK_HELD_OVER_RECLAIM_FS_READ,
3640
LOCK_USAGE_STATES
3741
};
3842

@@ -42,16 +46,20 @@ enum lock_usage_bit
4246
#defineLOCKF_USED(1 << LOCK_USED)
4347
#defineLOCKF_USED_IN_HARDIRQ(1 << LOCK_USED_IN_HARDIRQ)
4448
#defineLOCKF_USED_IN_SOFTIRQ(1 << LOCK_USED_IN_SOFTIRQ)
49+
#defineLOCKF_USED_IN_RECLAIM_FS(1 << LOCK_USED_IN_RECLAIM_FS)
4550
#defineLOCKF_ENABLED_HARDIRQS(1 << LOCK_ENABLED_HARDIRQS)
4651
#defineLOCKF_ENABLED_SOFTIRQS(1 << LOCK_ENABLED_SOFTIRQS)
52+
#defineLOCKF_HELD_OVER_RECLAIM_FS(1 << LOCK_HELD_OVER_RECLAIM_FS)
4753

4854
#defineLOCKF_ENABLED_IRQS (LOCKF_ENABLED_HARDIRQS | LOCKF_ENABLED_SOFTIRQS)
4955
#defineLOCKF_USED_IN_IRQ (LOCKF_USED_IN_HARDIRQ | LOCKF_USED_IN_SOFTIRQ)
5056

5157
#defineLOCKF_USED_IN_HARDIRQ_READ(1 << LOCK_USED_IN_HARDIRQ_READ)
5258
#defineLOCKF_USED_IN_SOFTIRQ_READ(1 << LOCK_USED_IN_SOFTIRQ_READ)
59+
#defineLOCKF_USED_IN_RECLAIM_FS_READ(1 << LOCK_USED_IN_RECLAIM_FS_READ)
5360
#defineLOCKF_ENABLED_HARDIRQS_READ(1 << LOCK_ENABLED_HARDIRQS_READ)
5461
#defineLOCKF_ENABLED_SOFTIRQS_READ(1 << LOCK_ENABLED_SOFTIRQS_READ)
62+
#defineLOCKF_HELD_OVER_RECLAIM_FS_READ(1 << LOCK_HELD_OVER_RECLAIM_FS_READ)
5563

5664
#defineLOCKF_ENABLED_IRQS_READ \
5765
(LOCKF_ENABLED_HARDIRQS_READ | LOCKF_ENABLED_SOFTIRQS_READ)
@@ -324,7 +332,11 @@ static inline void lock_set_subclass(struct lockdep_map *lock,
324332
lock_set_class(lock,lock->name,lock->key,subclass,ip);
325333
}
326334

327-
# defineINIT_LOCKDEP.lockdep_recursion = 0,
335+
externvoidlockdep_set_current_reclaim_state(gfp_tgfp_mask);
336+
externvoidlockdep_clear_current_reclaim_state(void);
337+
externvoidlockdep_trace_alloc(gfp_tmask);
338+
339+
# defineINIT_LOCKDEP.lockdep_recursion = 0, .lockdep_reclaim_gfp = 0,
328340

329341
#definelockdep_depth(tsk)(debug_locks ? (tsk)->lockdep_depth : 0)
330342

@@ -342,6 +354,9 @@ static inline void lockdep_on(void)
342354
# definelock_release(l,n,i)do { } while (0)
343355
# definelock_set_class(l,n,k,s,i)do { } while (0)
344356
# definelock_set_subclass(l,s,i)do { } while (0)
357+
# definelockdep_set_current_reclaim_state(g)do { } while (0)
358+
# definelockdep_clear_current_reclaim_state()do { } while (0)
359+
# definelockdep_trace_alloc(g)do { } while (0)
345360
# definelockdep_init()do { } while (0)
346361
# definelockdep_info()do { } while (0)
347362
# definelockdep_init_map(lock,name,key,sub) \

‎include/linux/sched.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ struct task_struct {
13131313
intlockdep_depth;
13141314
unsignedintlockdep_recursion;
13151315
structheld_lockheld_locks[MAX_LOCK_DEPTH];
1316+
gfp_tlockdep_reclaim_gfp;
13161317
#endif
13171318

13181319
/* journalling filesystem info */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp