<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/lockdep.h, branch v5.10.1</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.10.1</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.10.1'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2020-10-09T06:55:17Z</updated>
<entry>
<title>Merge branch 'locking/urgent' into locking/core, to pick up fixes</title>
<updated>2020-10-09T06:55:17Z</updated>
<author>
<name>Ingo Molnar</name>
<email>mingo@kernel.org</email>
</author>
<published>2020-10-09T06:55:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=e705d397965811ac528d7213b42d74ffe43caf38'/>
<id>urn:sha1:e705d397965811ac528d7213b42d74ffe43caf38</id>
<content type='text'>
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>lockdep: Revert "lockdep: Use raw_cpu_*() for per-cpu variables"</title>
<updated>2020-10-09T06:54:00Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2020-10-05T07:56:57Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=baffd723e44dc3d7f84f0b8f1fe1ece00ddd2710'/>
<id>urn:sha1:baffd723e44dc3d7f84f0b8f1fe1ece00ddd2710</id>
<content type='text'>
The thinking in commit:

  fddf9055a60d ("lockdep: Use raw_cpu_*() for per-cpu variables")

is flawed. While it is true that when we're migratable both CPUs will
have a 0 value, it doesn't hold that when we do get migrated in the
middle of a raw_cpu_op(), the old CPU will still have 0 by the time we
get around to reading it on the new CPU.

Luckily, the reason for that commit (s390 using preempt_disable()
instead of preempt_disable_notrace() in their percpu code), has since
been fixed by commit:

  1196f12a2c96 ("s390: don't trace preemption in percpu macros")

An audit of arch/*/include/asm/percpu*.h shows there are no other
architectures affected by this particular issue.

Fixes: fddf9055a60d ("lockdep: Use raw_cpu_*() for per-cpu variables")
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lkml.kernel.org/r/20201005095958.GJ2651@hirez.programming.kicks-ass.net
</content>
</entry>
<entry>
<title>lockdep: Fix lockdep recursion</title>
<updated>2020-10-09T06:53:30Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2020-10-02T09:04:21Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4d004099a668c41522242aa146a38cc4eb59cb1e'/>
<id>urn:sha1:4d004099a668c41522242aa146a38cc4eb59cb1e</id>
<content type='text'>
Steve reported that lockdep_assert*irq*(), when nested inside lockdep
itself, will trigger a false-positive.

One example is the stack-trace code, as called from inside lockdep,
triggering tracing, which in turn calls RCU, which then uses
lockdep_assert_irqs_disabled().

Fixes: a21ee6055c30 ("lockdep: Change hardirq{s_enabled,_context} to per-cpu variables")
Reported-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>lockdep: Extend __bfs() to work with multiple types of dependencies</title>
<updated>2020-08-26T10:42:04Z</updated>
<author>
<name>Boqun Feng</name>
<email>boqun.feng@gmail.com</email>
</author>
<published>2020-08-07T07:42:26Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6971c0f345620aae5e6172207a57b7524603a34e'/>
<id>urn:sha1:6971c0f345620aae5e6172207a57b7524603a34e</id>
<content type='text'>
Now we have four types of dependencies in the dependency graph, and not
all the pathes carry real dependencies (the dependencies that may cause
a deadlock), for example:

	Given lock A and B, if we have:

	CPU1			CPU2
	=============		==============
	write_lock(A);		read_lock(B);
	read_lock(B);		write_lock(A);

	(assuming read_lock(B) is a recursive reader)

	then we have dependencies A -(ER)-&gt; B, and B -(SN)-&gt; A, and a
	dependency path A -(ER)-&gt; B -(SN)-&gt; A.

	In lockdep w/o recursive locks, a dependency path from A to A
	means a deadlock. However, the above case is obviously not a
	deadlock, because no one holds B exclusively, therefore no one
	waits for the other to release B, so who get A first in CPU1 and
	CPU2 will run non-blockingly.

	As a result, dependency path A -(ER)-&gt; B -(SN)-&gt; A is not a
	real/strong dependency that could cause a deadlock.

From the observation above, we know that for a dependency path to be
real/strong, no two adjacent dependencies can be as -(*R)-&gt; -(S*)-&gt;.

Now our mission is to make __bfs() traverse only the strong dependency
paths, which is simple: we record whether we only have -(*R)-&gt; for the
previous lock_list of the path in lock_list::only_xr, and when we pick a
dependency in the traverse, we 1) filter out -(S*)-&gt; dependency if the
previous lock_list only has -(*R)-&gt; dependency (i.e. -&gt;only_xr is true)
and 2) set the next lock_list::only_xr to true if we only have -(*R)-&gt;
left after we filter out dependencies based on 1), otherwise, set it to
false.

With this extension for __bfs(), we now need to initialize the root of
__bfs() properly (with a correct -&gt;only_xr), to do so, we introduce some
helper functions, which also cleans up a little bit for the __bfs() root
initialization code.

Signed-off-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20200807074238.1632519-8-boqun.feng@gmail.com
</content>
</entry>
<entry>
<title>lockdep: Introduce lock_list::dep</title>
<updated>2020-08-26T10:42:04Z</updated>
<author>
<name>Boqun Feng</name>
<email>boqun.feng@gmail.com</email>
</author>
<published>2020-08-07T07:42:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3454a36d6a39186de508dd43df590a6363364176'/>
<id>urn:sha1:3454a36d6a39186de508dd43df590a6363364176</id>
<content type='text'>
To add recursive read locks into the dependency graph, we need to store
the types of dependencies for the BFS later. There are four types of
dependencies:

*	Exclusive -&gt; Non-recursive dependencies: EN
	e.g. write_lock(prev) held and try to acquire write_lock(next)
	or non-recursive read_lock(next), which can be represented as
	"prev -(EN)-&gt; next"

*	Shared -&gt; Non-recursive dependencies: SN
	e.g. read_lock(prev) held and try to acquire write_lock(next) or
	non-recursive read_lock(next), which can be represented as
	"prev -(SN)-&gt; next"

*	Exclusive -&gt; Recursive dependencies: ER
	e.g. write_lock(prev) held and try to acquire recursive
	read_lock(next), which can be represented as "prev -(ER)-&gt; next"

*	Shared -&gt; Recursive dependencies: SR
	e.g. read_lock(prev) held and try to acquire recursive
	read_lock(next), which can be represented as "prev -(SR)-&gt; next"

So we use 4 bits for the presence of each type in lock_list::dep. Helper
functions and macros are also introduced to convert a pair of locks into
lock_list::dep bit and maintain the addition of different types of
dependencies.

Signed-off-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20200807074238.1632519-7-boqun.feng@gmail.com
</content>
</entry>
<entry>
<title>lockdep: Reduce the size of lock_list::distance</title>
<updated>2020-08-26T10:42:04Z</updated>
<author>
<name>Boqun Feng</name>
<email>boqun.feng@gmail.com</email>
</author>
<published>2020-08-07T07:42:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bd76eca10de2eb9998d5125b08e8997cbf5508d5'/>
<id>urn:sha1:bd76eca10de2eb9998d5125b08e8997cbf5508d5</id>
<content type='text'>
lock_list::distance is always not greater than MAX_LOCK_DEPTH (which
is 48 right now), so a u16 will fit. This patch reduces the size of
lock_list::distance to save space, so that we can introduce other fields
to help detect recursive read lock deadlocks without increasing the size
of lock_list structure.

Suggested-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Signed-off-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20200807074238.1632519-6-boqun.feng@gmail.com
</content>
</entry>
<entry>
<title>locking: More accurate annotations for read_lock()</title>
<updated>2020-08-26T10:42:02Z</updated>
<author>
<name>Boqun Feng</name>
<email>boqun.feng@gmail.com</email>
</author>
<published>2020-08-07T07:42:20Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=e918188611f073063415f40fae568fa4d86d9044'/>
<id>urn:sha1:e918188611f073063415f40fae568fa4d86d9044</id>
<content type='text'>
On the archs using QUEUED_RWLOCKS, read_lock() is not always a recursive
read lock, actually it's only recursive if in_interrupt() is true. So
change the annotation accordingly to catch more deadlocks.

Note we used to treat read_lock() as pure recursive read locks in
lib/locking-seftest.c, and this is useful, especially for the lockdep
development selftest, so we keep this via a variable to force switching
lock annotation for read_lock().

Signed-off-by: Boqun Feng &lt;boqun.feng@gmail.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20200807074238.1632519-2-boqun.feng@gmail.com
</content>
</entry>
<entry>
<title>lockdep: Use raw_cpu_*() for per-cpu variables</title>
<updated>2020-08-26T10:41:53Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2020-08-20T07:13:30Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=fddf9055a60dfcc97bda5ef03c8fa4108ed555c5'/>
<id>urn:sha1:fddf9055a60dfcc97bda5ef03c8fa4108ed555c5</id>
<content type='text'>
Sven reported that commit a21ee6055c30 ("lockdep: Change
hardirq{s_enabled,_context} to per-cpu variables") caused trouble on
s390 because their this_cpu_*() primitives disable preemption which
then lands back tracing.

On the one hand, per-cpu ops should use preempt_*able_notrace() and
raw_local_irq_*(), on the other hand, we can trivialy use raw_cpu_*()
ops for this.

Fixes: a21ee6055c30 ("lockdep: Change hardirq{s_enabled,_context} to per-cpu variables")
Reported-by: Sven Schnelle &lt;svens@linux.ibm.com&gt;
Reviewed-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
Reviewed-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Tested-by: Marco Elver &lt;elver@google.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20200821085348.192346882@infradead.org
</content>
</entry>
<entry>
<title>locking/seqlock, headers: Untangle the spaghetti monster</title>
<updated>2020-08-06T14:13:13Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2020-08-06T12:35:11Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=0cd39f4600ed4de859383018eb10f0f724900e1b'/>
<id>urn:sha1:0cd39f4600ed4de859383018eb10f0f724900e1b</id>
<content type='text'>
By using lockdep_assert_*() from seqlock.h, the spaghetti monster
attacked.

Attack back by reducing seqlock.h dependencies from two key high level headers:

 - &lt;linux/seqlock.h&gt;:               -Remove &lt;linux/ww_mutex.h&gt;
 - &lt;linux/time.h&gt;:                  -Remove &lt;linux/seqlock.h&gt;
 - &lt;linux/sched.h&gt;:                 +Add    &lt;linux/seqlock.h&gt;

The price was to add it to sched.h ...

Core header fallout, we add direct header dependencies instead of gaining them
parasitically from higher level headers:

 - &lt;linux/dynamic_queue_limits.h&gt;:  +Add &lt;asm/bug.h&gt;
 - &lt;linux/hrtimer.h&gt;:               +Add &lt;linux/seqlock.h&gt;
 - &lt;linux/ktime.h&gt;:                 +Add &lt;asm/bug.h&gt;
 - &lt;linux/lockdep.h&gt;:               +Add &lt;linux/smp.h&gt;
 - &lt;linux/sched.h&gt;:                 +Add &lt;linux/seqlock.h&gt;
 - &lt;linux/videodev2.h&gt;:             +Add &lt;linux/kernel.h&gt;

Arch headers fallout:

 - PARISC: &lt;asm/timex.h&gt;:           +Add &lt;asm/special_insns.h&gt;
 - SH:     &lt;asm/io.h&gt;:              +Add &lt;asm/page.h&gt;
 - SPARC:  &lt;asm/timer_64.h&gt;:        +Add &lt;uapi/asm/asi.h&gt;
 - SPARC:  &lt;asm/vvar.h&gt;:            +Add &lt;asm/processor.h&gt;, &lt;asm/barrier.h&gt;
                                    -Remove &lt;linux/seqlock.h&gt;
 - X86:    &lt;asm/fixmap.h&gt;:          +Add &lt;asm/pgtable_types.h&gt;
                                    -Remove &lt;asm/acpi.h&gt;

There's also a bunch of parasitic header dependency fallout in .c files, not listed
separately.

[ mingo: Extended the changelog, split up &amp; fixed the original patch. ]

Co-developed-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20200804133438.GK2674@hirez.programming.kicks-ass.net
</content>
</entry>
<entry>
<title>lockdep: Add preemption enabled/disabled assertion APIs</title>
<updated>2020-07-29T14:14:24Z</updated>
<author>
<name>Ahmed S. Darwish</name>
<email>a.darwish@linutronix.de</email>
</author>
<published>2020-07-20T15:55:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8fd8ad5c5dfcb09cf62abadd4043eaf1afbbd0ce'/>
<id>urn:sha1:8fd8ad5c5dfcb09cf62abadd4043eaf1afbbd0ce</id>
<content type='text'>
Asserting that preemption is enabled or disabled is a critical sanity
check.  Developers are usually reluctant to add such a check in a
fastpath as reading the preemption count can be costly.

Extend the lockdep API with macros asserting that preemption is disabled
or enabled. If lockdep is disabled, or if the underlying architecture
does not support kernel preemption, this assert has no runtime overhead.

References: f54bb2ec02c8 ("locking/lockdep: Add IRQs disabled/enabled assertion APIs: ...")
Signed-off-by: Ahmed S. Darwish &lt;a.darwish@linutronix.de&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20200720155530.1173732-8-a.darwish@linutronix.de
</content>
</entry>
</feed>
