<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/kernel/lockdep.c, branch v2.6.27.14</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>lockdep: fix invalid list_del_rcu in zap_class</title>
<updated>2008-08-27T06:40:36+00:00</updated>
<author>
<name>Zhu Yi</name>
<email>yi.zhu@intel.com</email>
</author>
<published>2008-08-27T06:33:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=74870172824a78640ec4f03058d9bd35dfa08618'/>
<id>74870172824a78640ec4f03058d9bd35dfa08618</id>
<content type='text'>
The problem is found during iwlagn driver testing on
v2.6.27-rc4-176-gb8e6c91 kernel, but it turns out to be a lockdep bug.
In our testing, we frequently load and unload the iwlagn driver
(&gt;50 times). Then the MAX_STACK_TRACE_ENTRIES is reached (expected
behaviour?). The error message with the call trace is as below.

BUG: MAX_STACK_TRACE_ENTRIES too low!
turning off the locking correctness validator.
Pid: 4895, comm: iwlagn Not tainted 2.6.27-rc4 #13

Call Trace:
 [&lt;ffffffff81014aa1&gt;] save_stack_trace+0x22/0x3e
 [&lt;ffffffff8105390a&gt;] save_trace+0x8b/0x91
 [&lt;ffffffff81054e60&gt;] mark_lock+0x1b0/0x8fa
 [&lt;ffffffff81056f71&gt;] __lock_acquire+0x5b9/0x716
 [&lt;ffffffffa00d818a&gt;] ieee80211_sta_work+0x0/0x6ea [mac80211]
 [&lt;ffffffff81057120&gt;] lock_acquire+0x52/0x6b
 [&lt;ffffffff81045f0e&gt;] run_workqueue+0x97/0x1ed
 [&lt;ffffffff81045f5e&gt;] run_workqueue+0xe7/0x1ed
 [&lt;ffffffff81045f0e&gt;] run_workqueue+0x97/0x1ed
 [&lt;ffffffff81046ae4&gt;] worker_thread+0xd8/0xe3
 [&lt;ffffffff81049503&gt;] autoremove_wake_function+0x0/0x2e
 [&lt;ffffffff81046a0c&gt;] worker_thread+0x0/0xe3
 [&lt;ffffffff810493ec&gt;] kthread+0x47/0x73
 [&lt;ffffffff8128e3ab&gt;] trace_hardirqs_on_thunk+0x3a/0x3f
 [&lt;ffffffff8100cea9&gt;] child_rip+0xa/0x11
 [&lt;ffffffff8100c4df&gt;] restore_args+0x0/0x30
 [&lt;ffffffff810316e1&gt;] finish_task_switch+0x0/0xcc
 [&lt;ffffffff810493a5&gt;] kthread+0x0/0x73
 [&lt;ffffffff8100ce9f&gt;] child_rip+0x0/0x11

Although the above is harmless, when the ilwagn module is removed
later lockdep will trigger a kernel oops as below.

BUG: unable to handle kernel NULL pointer dereference at
0000000000000008
IP: [&lt;ffffffff810531e1&gt;] zap_class+0x24/0x82
PGD 73128067 PUD 7448c067 PMD 0
Oops: 0002 [1] SMP
CPU 0
Modules linked in: rfcomm l2cap bluetooth autofs4 sunrpc
nf_conntrack_ipv6 xt_state nf_conntrack xt_tcpudp ip6t_ipv6header
ip6t_REJECT ip6table_filter ip6_tables x_tables ipv6 cpufreq_ondemand
acpi_cpufreq dm_mirror dm_log dm_multipath dm_mod snd_hda_intel sr_mod
snd_seq_dummy snd_seq_oss snd_seq_midi_event battery snd_seq
snd_seq_device cdrom button snd_pcm_oss snd_mixer_oss snd_pcm
snd_timer snd_page_alloc e1000e snd_hwdep sg iTCO_wdt
iTCO_vendor_support ac pcspkr i2c_i801 i2c_core snd soundcore video
output ata_piix ata_generic libata sd_mod scsi_mod ext3 jbd mbcache
uhci_hcd ohci_hcd ehci_hcd [last unloaded: mac80211]
Pid: 4941, comm: modprobe Not tainted 2.6.27-rc4 #10
RIP: 0010:[&lt;ffffffff810531e1&gt;]  [&lt;ffffffff810531e1&gt;]
zap_class+0x24/0x82
RSP: 0000:ffff88007bcb3eb0  EFLAGS: 00010046
RAX: 0000000000068ee8 RBX: ffffffff8192a0a0 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000001dfb RDI: ffffffff816e70b0
RBP: ffffffffa00cd000 R08: ffffffff816818f8 R09: ffff88007c923558
R10: ffffe20002ad2408 R11: ffffffff811028ec R12: ffffffff8192a0a0
R13: 000000000002bd90 R14: 0000000000000000 R15: 0000000000000296
FS:  00007f9d1cee56f0(0000) GS:ffffffff814a58c0(0000)
knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000000008 CR3: 0000000073047000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process modprobe (pid: 4941, threadinfo ffff88007bcb2000, task
ffff8800758d1fc0)
Stack:  ffffffff81057376 0000000000000000 ffffffffa00f7b00
0000000000000000
 0000000000000080 0000000000618278 00007fff24f16720 0000000000000000
 ffffffff8105d37a ffffffffa00f7b00 ffffffff8105d591 313132303863616d
Call Trace:
 [&lt;ffffffff81057376&gt;] ? lockdep_free_key_range+0x61/0xf5
 [&lt;ffffffff8105d37a&gt;] ? free_module+0xd4/0xe4
 [&lt;ffffffff8105d591&gt;] ? sys_delete_module+0x1de/0x1f9
 [&lt;ffffffff8106dbfa&gt;] ? audit_syscall_entry+0x12d/0x160
 [&lt;ffffffff8100be2b&gt;] ? system_call_fastpath+0x16/0x1b

Code: b2 00 01 00 00 00 c3 31 f6 49 c7 c0 10 8a 61 81 eb 32 49 39 38
75 26 48 98 48 6b c0 38 48 8b 90 08 8a 61 81 48 8b 88 00 8a 61 81 &lt;48&gt;
89 51 08 48 89 0a 48 c7 80 08 8a 61 81 00 02 20 00 48 ff c6
RIP  [&lt;ffffffff810531e1&gt;] zap_class+0x24/0x82
 RSP &lt;ffff88007bcb3eb0&gt;
CR2: 0000000000000008
---[ end trace a1297e0c4abb0f2e ]---

The root cause for this oops is in add_lock_to_list() when
save_trace() fails due to MAX_STACK_TRACE_ENTRIES is reached,
entry-&gt;class is assigned but entry is never added into any lock list.
This makes the list_del_rcu() in zap_class() oops later when the
module is unloaded. This patch fixes the problem by assigning
entry-&gt;class after save_trace() returns success.

Signed-off-by: Zhu Yi &lt;yi.zhu@intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The problem is found during iwlagn driver testing on
v2.6.27-rc4-176-gb8e6c91 kernel, but it turns out to be a lockdep bug.
In our testing, we frequently load and unload the iwlagn driver
(&gt;50 times). Then the MAX_STACK_TRACE_ENTRIES is reached (expected
behaviour?). The error message with the call trace is as below.

BUG: MAX_STACK_TRACE_ENTRIES too low!
turning off the locking correctness validator.
Pid: 4895, comm: iwlagn Not tainted 2.6.27-rc4 #13

Call Trace:
 [&lt;ffffffff81014aa1&gt;] save_stack_trace+0x22/0x3e
 [&lt;ffffffff8105390a&gt;] save_trace+0x8b/0x91
 [&lt;ffffffff81054e60&gt;] mark_lock+0x1b0/0x8fa
 [&lt;ffffffff81056f71&gt;] __lock_acquire+0x5b9/0x716
 [&lt;ffffffffa00d818a&gt;] ieee80211_sta_work+0x0/0x6ea [mac80211]
 [&lt;ffffffff81057120&gt;] lock_acquire+0x52/0x6b
 [&lt;ffffffff81045f0e&gt;] run_workqueue+0x97/0x1ed
 [&lt;ffffffff81045f5e&gt;] run_workqueue+0xe7/0x1ed
 [&lt;ffffffff81045f0e&gt;] run_workqueue+0x97/0x1ed
 [&lt;ffffffff81046ae4&gt;] worker_thread+0xd8/0xe3
 [&lt;ffffffff81049503&gt;] autoremove_wake_function+0x0/0x2e
 [&lt;ffffffff81046a0c&gt;] worker_thread+0x0/0xe3
 [&lt;ffffffff810493ec&gt;] kthread+0x47/0x73
 [&lt;ffffffff8128e3ab&gt;] trace_hardirqs_on_thunk+0x3a/0x3f
 [&lt;ffffffff8100cea9&gt;] child_rip+0xa/0x11
 [&lt;ffffffff8100c4df&gt;] restore_args+0x0/0x30
 [&lt;ffffffff810316e1&gt;] finish_task_switch+0x0/0xcc
 [&lt;ffffffff810493a5&gt;] kthread+0x0/0x73
 [&lt;ffffffff8100ce9f&gt;] child_rip+0x0/0x11

Although the above is harmless, when the ilwagn module is removed
later lockdep will trigger a kernel oops as below.

BUG: unable to handle kernel NULL pointer dereference at
0000000000000008
IP: [&lt;ffffffff810531e1&gt;] zap_class+0x24/0x82
PGD 73128067 PUD 7448c067 PMD 0
Oops: 0002 [1] SMP
CPU 0
Modules linked in: rfcomm l2cap bluetooth autofs4 sunrpc
nf_conntrack_ipv6 xt_state nf_conntrack xt_tcpudp ip6t_ipv6header
ip6t_REJECT ip6table_filter ip6_tables x_tables ipv6 cpufreq_ondemand
acpi_cpufreq dm_mirror dm_log dm_multipath dm_mod snd_hda_intel sr_mod
snd_seq_dummy snd_seq_oss snd_seq_midi_event battery snd_seq
snd_seq_device cdrom button snd_pcm_oss snd_mixer_oss snd_pcm
snd_timer snd_page_alloc e1000e snd_hwdep sg iTCO_wdt
iTCO_vendor_support ac pcspkr i2c_i801 i2c_core snd soundcore video
output ata_piix ata_generic libata sd_mod scsi_mod ext3 jbd mbcache
uhci_hcd ohci_hcd ehci_hcd [last unloaded: mac80211]
Pid: 4941, comm: modprobe Not tainted 2.6.27-rc4 #10
RIP: 0010:[&lt;ffffffff810531e1&gt;]  [&lt;ffffffff810531e1&gt;]
zap_class+0x24/0x82
RSP: 0000:ffff88007bcb3eb0  EFLAGS: 00010046
RAX: 0000000000068ee8 RBX: ffffffff8192a0a0 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000001dfb RDI: ffffffff816e70b0
RBP: ffffffffa00cd000 R08: ffffffff816818f8 R09: ffff88007c923558
R10: ffffe20002ad2408 R11: ffffffff811028ec R12: ffffffff8192a0a0
R13: 000000000002bd90 R14: 0000000000000000 R15: 0000000000000296
FS:  00007f9d1cee56f0(0000) GS:ffffffff814a58c0(0000)
knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000000008 CR3: 0000000073047000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process modprobe (pid: 4941, threadinfo ffff88007bcb2000, task
ffff8800758d1fc0)
Stack:  ffffffff81057376 0000000000000000 ffffffffa00f7b00
0000000000000000
 0000000000000080 0000000000618278 00007fff24f16720 0000000000000000
 ffffffff8105d37a ffffffffa00f7b00 ffffffff8105d591 313132303863616d
Call Trace:
 [&lt;ffffffff81057376&gt;] ? lockdep_free_key_range+0x61/0xf5
 [&lt;ffffffff8105d37a&gt;] ? free_module+0xd4/0xe4
 [&lt;ffffffff8105d591&gt;] ? sys_delete_module+0x1de/0x1f9
 [&lt;ffffffff8106dbfa&gt;] ? audit_syscall_entry+0x12d/0x160
 [&lt;ffffffff8100be2b&gt;] ? system_call_fastpath+0x16/0x1b

Code: b2 00 01 00 00 00 c3 31 f6 49 c7 c0 10 8a 61 81 eb 32 49 39 38
75 26 48 98 48 6b c0 38 48 8b 90 08 8a 61 81 48 8b 88 00 8a 61 81 &lt;48&gt;
89 51 08 48 89 0a 48 c7 80 08 8a 61 81 00 02 20 00 48 ff c6
RIP  [&lt;ffffffff810531e1&gt;] zap_class+0x24/0x82
 RSP &lt;ffff88007bcb3eb0&gt;
CR2: 0000000000000008
---[ end trace a1297e0c4abb0f2e ]---

The root cause for this oops is in add_lock_to_list() when
save_trace() fails due to MAX_STACK_TRACE_ENTRIES is reached,
entry-&gt;class is assigned but entry is never added into any lock list.
This makes the list_del_rcu() in zap_class() oops later when the
module is unloaded. This patch fixes the problem by assigning
entry-&gt;class after save_trace() returns success.

Signed-off-by: Zhu Yi &lt;yi.zhu@intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lockstat: repair erronous contention statistics</title>
<updated>2008-08-26T08:37:47+00:00</updated>
<author>
<name>Joe Korty</name>
<email>joe.korty@ccur.com</email>
</author>
<published>2008-08-25T21:16:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=04148b73b89d49fe0fe201bcee395e51f7d637ce'/>
<id>04148b73b89d49fe0fe201bcee395e51f7d637ce</id>
<content type='text'>
Fix bad contention counting in /proc/lock_stat.

/proc/lockstat tries to gather per-ip contention
statistics per-lock.  This was failing due to
a garbage per-ip index selector being used.

Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix bad contention counting in /proc/lock_stat.

/proc/lockstat tries to gather per-ip contention
statistics per-lock.  This was failing due to
a garbage per-ip index selector being used.

Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lockdep: fix spurious 'inconsistent lock state' warning</title>
<updated>2008-08-18T07:42:31+00:00</updated>
<author>
<name>Dmitry Baryshkov</name>
<email>dbaryshkov@gmail.com</email>
</author>
<published>2008-08-18T00:26:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=6951b12a0fe7fc64789f2c4d62d2a304e93836a8'/>
<id>6951b12a0fe7fc64789f2c4d62d2a304e93836a8</id>
<content type='text'>
Since f82b217e3513fe3af342c0f3ee1494e86250c21c lockdep can output spurious
warnings related to hwirqs due to hardirq_off shrinkage from int to bit-sized
flag. Guard it with double negation to fix the warning.

Signed-off-by: Dmitry Baryshkov &lt;dbaryshkov@gmail.com&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since f82b217e3513fe3af342c0f3ee1494e86250c21c lockdep can output spurious
warnings related to hwirqs due to hardirq_off shrinkage from int to bit-sized
flag. Guard it with double negation to fix the warning.

Signed-off-by: Dmitry Baryshkov &lt;dbaryshkov@gmail.com&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lockdep: use WARN() in kernel/lockdep.c</title>
<updated>2008-08-13T17:06:46+00:00</updated>
<author>
<name>Arjan van de Ven</name>
<email>arjan@linux.intel.com</email>
</author>
<published>2008-07-30T19:43:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2df8b1d656021e180ab93c8a4b2c9c2923d30b82'/>
<id>2df8b1d656021e180ab93c8a4b2c9c2923d30b82</id>
<content type='text'>
Use WARN() instead of a printk+WARN_ON() pair; this way the message
becomes part of the warning section for better reporting/collection.

Signed-off-by: Arjan van de Ven &lt;arjan@linux.intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use WARN() instead of a printk+WARN_ON() pair; this way the message
becomes part of the warning section for better reporting/collection.

Signed-off-by: Arjan van de Ven &lt;arjan@linux.intel.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lockdep: fix debug_lock_alloc</title>
<updated>2008-08-11T20:45:51+00:00</updated>
<author>
<name>Peter Zijlstra</name>
<email>a.p.zijlstra@chello.nl</email>
</author>
<published>2008-08-11T20:45:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0f2bc27be27ca1dcc66b96131e44bf7648b959c6'/>
<id>0f2bc27be27ca1dcc66b96131e44bf7648b959c6</id>
<content type='text'>
When we enable DEBUG_LOCK_ALLOC but do not enable PROVE_LOCKING and or
LOCK_STAT, lock_alloc() and lock_release() turn into nops, even though
we should be doing hlock checking (check=1).

This causes a false warning and a lockdep self-disable.

Rectify this.

Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When we enable DEBUG_LOCK_ALLOC but do not enable PROVE_LOCKING and or
LOCK_STAT, lock_alloc() and lock_release() turn into nops, even though
we should be doing hlock checking (check=1).

This causes a false warning and a lockdep self-disable.

Rectify this.

Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lockdep: handle chains involving classes defined in modules</title>
<updated>2008-08-11T07:30:26+00:00</updated>
<author>
<name>Rabin Vincent</name>
<email>rabin@rab.in</email>
</author>
<published>2008-08-11T07:30:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8bfe0298f7a04952d19f4a2cf510d7a6311eeed0'/>
<id>8bfe0298f7a04952d19f4a2cf510d7a6311eeed0</id>
<content type='text'>
Solve this by marking the classes as unused and not printing information
about the unused classes.

Reported-by: Eric Sesterhenn &lt;snakebyte@gmx.de&gt;
Signed-off-by: Rabin Vincent &lt;rabin@rab.in&gt;
Acked-by: Huang Ying &lt;ying.huang@intel.com&gt;
Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Solve this by marking the classes as unused and not printing information
about the unused classes.

Reported-by: Eric Sesterhenn &lt;snakebyte@gmx.de&gt;
Signed-off-by: Rabin Vincent &lt;rabin@rab.in&gt;
Acked-by: Huang Ying &lt;ying.huang@intel.com&gt;
Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lockdep: lock protection locks</title>
<updated>2008-08-11T07:30:24+00:00</updated>
<author>
<name>Peter Zijlstra</name>
<email>a.p.zijlstra@chello.nl</email>
</author>
<published>2008-08-11T07:30:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7531e2f34d1d551b096143f19111139f0dd84c8b'/>
<id>7531e2f34d1d551b096143f19111139f0dd84c8b</id>
<content type='text'>
On Fri, 2008-08-01 at 16:26 -0700, Linus Torvalds wrote:

&gt; On Fri, 1 Aug 2008, David Miller wrote:
&gt; &gt;
&gt; &gt; Taking more than a few locks of the same class at once is bad
&gt; &gt; news and it's better to find an alternative method.
&gt;
&gt; It's not always wrong.
&gt;
&gt; If you can guarantee that anybody that takes more than one lock of a
&gt; particular class will always take a single top-level lock _first_, then
&gt; that's all good. You can obviously screw up and take the same lock _twice_
&gt; (which will deadlock), but at least you cannot get into ABBA situations.
&gt;
&gt; So maybe the right thing to do is to just teach lockdep about "lock
&gt; protection locks". That would have solved the multi-queue issues for
&gt; networking too - all the actual network drivers would still have taken
&gt; just their single queue lock, but the one case that needs to take all of
&gt; them would have taken a separate top-level lock first.
&gt;
&gt; Never mind that the multi-queue locks were always taken in the same order:
&gt; it's never wrong to just have some top-level serialization, and anybody
&gt; who needs to take &lt;n&gt; locks might as well do &lt;n+1&gt;, because they sure as
&gt; hell aren't going to be on _any_ fastpaths.
&gt;
&gt; So the simplest solution really sounds like just teaching lockdep about
&gt; that one special case. It's not "nesting" exactly, although it's obviously
&gt; related to it.

Do as Linus suggested. The lock protection lock is called nest_lock.

Note that we still have the MAX_LOCK_DEPTH (48) limit to consider, so anything
that spills that it still up shit creek.

Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On Fri, 2008-08-01 at 16:26 -0700, Linus Torvalds wrote:

&gt; On Fri, 1 Aug 2008, David Miller wrote:
&gt; &gt;
&gt; &gt; Taking more than a few locks of the same class at once is bad
&gt; &gt; news and it's better to find an alternative method.
&gt;
&gt; It's not always wrong.
&gt;
&gt; If you can guarantee that anybody that takes more than one lock of a
&gt; particular class will always take a single top-level lock _first_, then
&gt; that's all good. You can obviously screw up and take the same lock _twice_
&gt; (which will deadlock), but at least you cannot get into ABBA situations.
&gt;
&gt; So maybe the right thing to do is to just teach lockdep about "lock
&gt; protection locks". That would have solved the multi-queue issues for
&gt; networking too - all the actual network drivers would still have taken
&gt; just their single queue lock, but the one case that needs to take all of
&gt; them would have taken a separate top-level lock first.
&gt;
&gt; Never mind that the multi-queue locks were always taken in the same order:
&gt; it's never wrong to just have some top-level serialization, and anybody
&gt; who needs to take &lt;n&gt; locks might as well do &lt;n+1&gt;, because they sure as
&gt; hell aren't going to be on _any_ fastpaths.
&gt;
&gt; So the simplest solution really sounds like just teaching lockdep about
&gt; that one special case. It's not "nesting" exactly, although it's obviously
&gt; related to it.

Do as Linus suggested. The lock protection lock is called nest_lock.

Note that we still have the MAX_LOCK_DEPTH (48) limit to consider, so anything
that spills that it still up shit creek.

Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lockdep: shrink held_lock structure</title>
<updated>2008-08-11T07:30:23+00:00</updated>
<author>
<name>Dave Jones</name>
<email>davej@redhat.com</email>
</author>
<published>2008-08-11T07:30:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f82b217e3513fe3af342c0f3ee1494e86250c21c'/>
<id>f82b217e3513fe3af342c0f3ee1494e86250c21c</id>
<content type='text'>
struct held_lock {
        u64                        prev_chain_key;       /*     0     8 */
        struct lock_class *        class;                /*     8     8 */
        long unsigned int          acquire_ip;           /*    16     8 */
        struct lockdep_map *       instance;             /*    24     8 */
        int                        irq_context;          /*    32     4 */
        int                        trylock;              /*    36     4 */
        int                        read;                 /*    40     4 */
        int                        check;                /*    44     4 */
        int                        hardirqs_off;         /*    48     4 */

        /* size: 56, cachelines: 1 */
        /* padding: 4 */
        /* last cacheline: 56 bytes */
};

struct held_lock {
        u64                        prev_chain_key;       /*     0     8 */
        long unsigned int          acquire_ip;           /*     8     8 */
        struct lockdep_map *       instance;             /*    16     8 */
        unsigned int               class_idx:11;         /*    24:21  4 */
        unsigned int               irq_context:2;        /*    24:19  4 */
        unsigned int               trylock:1;            /*    24:18  4 */
        unsigned int               read:2;               /*    24:16  4 */
        unsigned int               check:2;              /*    24:14  4 */
        unsigned int               hardirqs_off:1;       /*    24:13  4 */

        /* size: 32, cachelines: 1 */
        /* padding: 4 */
        /* bit_padding: 13 bits */
        /* last cacheline: 32 bytes */
};

[mingo@elte.hu: shrunk hlock-&gt;class too]
[peterz@infradead.org: fixup bit sizes]
Signed-off-by: Dave Jones &lt;davej@redhat.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
struct held_lock {
        u64                        prev_chain_key;       /*     0     8 */
        struct lock_class *        class;                /*     8     8 */
        long unsigned int          acquire_ip;           /*    16     8 */
        struct lockdep_map *       instance;             /*    24     8 */
        int                        irq_context;          /*    32     4 */
        int                        trylock;              /*    36     4 */
        int                        read;                 /*    40     4 */
        int                        check;                /*    44     4 */
        int                        hardirqs_off;         /*    48     4 */

        /* size: 56, cachelines: 1 */
        /* padding: 4 */
        /* last cacheline: 56 bytes */
};

struct held_lock {
        u64                        prev_chain_key;       /*     0     8 */
        long unsigned int          acquire_ip;           /*     8     8 */
        struct lockdep_map *       instance;             /*    16     8 */
        unsigned int               class_idx:11;         /*    24:21  4 */
        unsigned int               irq_context:2;        /*    24:19  4 */
        unsigned int               trylock:1;            /*    24:18  4 */
        unsigned int               read:2;               /*    24:16  4 */
        unsigned int               check:2;              /*    24:14  4 */
        unsigned int               hardirqs_off:1;       /*    24:13  4 */

        /* size: 32, cachelines: 1 */
        /* padding: 4 */
        /* bit_padding: 13 bits */
        /* last cacheline: 32 bytes */
};

[mingo@elte.hu: shrunk hlock-&gt;class too]
[peterz@infradead.org: fixup bit sizes]
Signed-off-by: Dave Jones &lt;davej@redhat.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lockdep: lock_set_subclass - reset a held lock's subclass</title>
<updated>2008-08-11T07:30:21+00:00</updated>
<author>
<name>Peter Zijlstra</name>
<email>a.p.zijlstra@chello.nl</email>
</author>
<published>2008-08-11T07:30:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=64aa348edc617dea17bbd01ddee4e47886d5ec8c'/>
<id>64aa348edc617dea17bbd01ddee4e47886d5ec8c</id>
<content type='text'>
this can be used to reset a held lock's subclass, for arbitrary-depth
iterated data structures such as trees or lists which have per-node
locks.

Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
this can be used to reset a held lock's subclass, for arbitrary-depth
iterated data structures such as trees or lists which have per-node
locks.

Signed-off-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lockdep: fix combinatorial explosion in lock subgraph traversal</title>
<updated>2008-07-31T16:38:28+00:00</updated>
<author>
<name>David Miller</name>
<email>davem@davemloft.net</email>
</author>
<published>2008-07-30T04:45:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=419ca3f13532793b81aff09f80c60af3eacbb43d'/>
<id>419ca3f13532793b81aff09f80c60af3eacbb43d</id>
<content type='text'>
When we traverse the graph, either forwards or backwards, we
are interested in whether a certain property exists somewhere
in a node reachable in the graph.

Therefore it is never necessary to traverse through a node more
than once to get a correct answer to the given query.

Take advantage of this property using a global ID counter so that we
need not clear all the markers in all the lock_class entries before
doing a traversal.  A new ID is choosen when we start to traverse, and
we continue through a lock_class only if it's ID hasn't been marked
with the new value yet.

This short-circuiting is essential especially for high CPU count
systems.  The scheduler has a runqueue per cpu, and needs to take
two runqueue locks at a time, which leads to long chains of
backwards and forwards subgraphs from these runqueue lock nodes.
Without the short-circuit implemented here, a graph traversal on
a runqueue lock can take up to (1 &lt;&lt; (N - 1)) checks on a system
with N cpus.

For anything more than 16 cpus or so, lockdep will eventually bring
the machine to a complete standstill.

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When we traverse the graph, either forwards or backwards, we
are interested in whether a certain property exists somewhere
in a node reachable in the graph.

Therefore it is never necessary to traverse through a node more
than once to get a correct answer to the given query.

Take advantage of this property using a global ID counter so that we
need not clear all the markers in all the lock_class entries before
doing a traversal.  A new ID is choosen when we start to traverse, and
we continue through a lock_class only if it's ID hasn't been marked
with the new value yet.

This short-circuiting is essential especially for high CPU count
systems.  The scheduler has a runqueue per cpu, and needs to take
two runqueue locks at a time, which leads to long chains of
backwards and forwards subgraphs from these runqueue lock nodes.
Without the short-circuit implemented here, a graph traversal on
a runqueue lock can take up to (1 &lt;&lt; (N - 1)) checks on a system
with N cpus.

For anything more than 16 cpus or so, lockdep will eventually bring
the machine to a complete standstill.

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</pre>
</div>
</content>
</entry>
</feed>
