Skip to content

Commit e3e7439

Browse files
mchehabJonathan Corbet
authored andcommitted
docs: lockdep-design: fix some warning issues
There are several warnings caused by a recent change 224ec48 ("lockdep/Documention: Recursive read lock detection reasoning") Those are reported by htmldocs build: Documentation/locking/lockdep-design.rst:429: WARNING: Definition list ends without a blank line; unexpected unindent. Documentation/locking/lockdep-design.rst:452: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/locking/lockdep-design.rst:453: WARNING: Unexpected indentation. Documentation/locking/lockdep-design.rst:453: WARNING: Blank line required after table. Documentation/locking/lockdep-design.rst:454: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/locking/lockdep-design.rst:455: WARNING: Unexpected indentation. Documentation/locking/lockdep-design.rst:455: WARNING: Blank line required after table. Documentation/locking/lockdep-design.rst:456: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/locking/lockdep-design.rst:457: WARNING: Unexpected indentation. Documentation/locking/lockdep-design.rst:457: WARNING: Blank line required after table. Besides the reported issues, there are some missing blank lines that ended producing wrong html output, and some literals are not properly identified. Also, the symbols used at the irq enabled/disable table are not displayed as expected, as they're not literals. Also, on another table they're using a different notation. Fixes: 224ec48 ("lockdep/Documention: Recursive read lock detection reasoning") Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/3b9431ac5c01e38111cd59928a93e7259ab7db0f.1603791716.git.mchehab+huawei@kernel.org Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent ef900cc commit e3e7439

1 file changed

Lines changed: 31 additions & 20 deletions

File tree

‎Documentation/locking/lockdep-design.rst‎

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,20 @@ The validator tracks lock-class usage history and divides the usage into
4242
(4 usages * n STATEs + 1) categories:
4343

4444
where the 4 usages can be:
45+
4546
- 'ever held in STATE context'
4647
- 'ever held as readlock in STATE context'
4748
- 'ever held with STATE enabled'
4849
- 'ever held as readlock with STATE enabled'
4950

5051
where the n STATEs are coded in kernel/locking/lockdep_states.h and as of
5152
now they include:
53+
5254
- hardirq
5355
- softirq
5456

5557
where the last 1 category is:
58+
5659
- 'ever used' [ == !unused ]
5760

5861
When locking rules are violated, these usage bits are presented in the
@@ -96,9 +99,9 @@ exact case is for the lock as of the reporting time.
9699
+--------------+-------------+--------------+
97100
| | irq enabled | irq disabled |
98101
+--------------+-------------+--------------+
99-
| ever in irq | ? | - |
102+
| ever in irq | '?' | '-' |
100103
+--------------+-------------+--------------+
101-
| never in irq | + | . |
104+
| never in irq | '+' | '.' |
102105
+--------------+-------------+--------------+
103106

104107
The character '-' suggests irq is disabled because if otherwise the
@@ -216,7 +219,7 @@ looks like this::
216219
BD_MUTEX_PARTITION
217220
};
218221

219-
mutex_lock_nested(&bdev->bd_contains->bd_mutex, BD_MUTEX_PARTITION);
222+
mutex_lock_nested(&bdev->bd_contains->bd_mutex, BD_MUTEX_PARTITION);
220223

221224
In this case the locking is done on a bdev object that is known to be a
222225
partition.
@@ -334,7 +337,7 @@ Troubleshooting:
334337
----------------
335338

336339
The validator tracks a maximum of MAX_LOCKDEP_KEYS number of lock classes.
337-
Exceeding this number will trigger the following lockdep warning:
340+
Exceeding this number will trigger the following lockdep warning::
338341

339342
(DEBUG_LOCKS_WARN_ON(id >= MAX_LOCKDEP_KEYS))
340343

@@ -420,7 +423,8 @@ the critical section of another reader of the same lock instance.
420423

421424
The difference between recursive readers and non-recursive readers is because:
422425
recursive readers get blocked only by a write lock *holder*, while non-recursive
423-
readers could get blocked by a write lock *waiter*. Considering the follow example:
426+
readers could get blocked by a write lock *waiter*. Considering the follow
427+
example::
424428

425429
TASK A: TASK B:
426430

@@ -448,20 +452,22 @@ There are simply four block conditions:
448452

449453
Block condition matrix, Y means the row blocks the column, and N means otherwise.
450454

451-
| E | r | R |
452455
+---+---+---+---+
453-
E | Y | Y | Y |
456+
| | E | r | R |
457+
+---+---+---+---+
458+
| E | Y | Y | Y |
459+
+---+---+---+---+
460+
| r | Y | Y | N |
454461
+---+---+---+---+
455-
r | Y | Y | N |
462+
| R | Y | Y | N |
456463
+---+---+---+---+
457-
R | Y | Y | N |
458464

459465
(W: writers, r: non-recursive readers, R: recursive readers)
460466

461467

462468
acquired recursively. Unlike non-recursive read locks, recursive read locks
463469
only get blocked by current write lock *holders* other than write lock
464-
*waiters*, for example:
470+
*waiters*, for example::
465471

466472
TASK A: TASK B:
467473

@@ -491,7 +497,7 @@ Recursive locks don't block each other, while non-recursive locks do (this is
491497
even true for two non-recursive read locks). A non-recursive lock can block the
492498
corresponding recursive lock, and vice versa.
493499

494-
A deadlock case with recursive locks involved is as follow:
500+
A deadlock case with recursive locks involved is as follow::
495501

496502
TASK A: TASK B:
497503

@@ -510,7 +516,7 @@ because there are 3 types for lockers, there are, in theory, 9 types of lock
510516
dependencies, but we can show that 4 types of lock dependencies are enough for
511517
deadlock detection.
512518

513-
For each lock dependency:
519+
For each lock dependency::
514520

515521
L1 -> L2
516522

@@ -525,20 +531,25 @@ same types).
525531
With the above combination for simplification, there are 4 types of dependency edges
526532
in the lockdep graph:
527533

528-
1) -(ER)->: exclusive writer to recursive reader dependency, "X -(ER)-> Y" means
534+
1) -(ER)->:
535+
exclusive writer to recursive reader dependency, "X -(ER)-> Y" means
529536
X -> Y and X is a writer and Y is a recursive reader.
530537

531-
2) -(EN)->: exclusive writer to non-recursive locker dependency, "X -(EN)-> Y" means
538+
2) -(EN)->:
539+
exclusive writer to non-recursive locker dependency, "X -(EN)-> Y" means
532540
X -> Y and X is a writer and Y is either a writer or non-recursive reader.
533541

534-
3) -(SR)->: shared reader to recursive reader dependency, "X -(SR)-> Y" means
542+
3) -(SR)->:
543+
shared reader to recursive reader dependency, "X -(SR)-> Y" means
535544
X -> Y and X is a reader (recursive or not) and Y is a recursive reader.
536545

537-
4) -(SN)->: shared reader to non-recursive locker dependency, "X -(SN)-> Y" means
546+
4) -(SN)->:
547+
shared reader to non-recursive locker dependency, "X -(SN)-> Y" means
538548
X -> Y and X is a reader (recursive or not) and Y is either a writer or
539549
non-recursive reader.
540550

541-
Note that given two locks, they may have multiple dependencies between them, for example:
551+
Note that given two locks, they may have multiple dependencies between them,
552+
for example::
542553

543554
TASK A:
544555

@@ -592,11 +603,11 @@ circles that won't cause deadlocks.
592603

593604
Proof for sufficiency (Lemma 1):
594605

595-
Let's say we have a strong circle:
606+
Let's say we have a strong circle::
596607

597608
L1 -> L2 ... -> Ln -> L1
598609

599-
, which means we have dependencies:
610+
, which means we have dependencies::
600611

601612
L1 -> L2
602613
L2 -> L3
@@ -633,7 +644,7 @@ a lock held by P2, and P2 is waiting for a lock held by P3, ... and Pn is waitin
633644
for a lock held by P1. Let's name the lock Px is waiting as Lx, so since P1 is waiting
634645
for L1 and holding Ln, so we will have Ln -> L1 in the dependency graph. Similarly,
635646
we have L1 -> L2, L2 -> L3, ..., Ln-1 -> Ln in the dependency graph, which means we
636-
have a circle:
647+
have a circle::
637648

638649
Ln -> L1 -> L2 -> ... -> Ln
639650

0 commit comments

Comments
 (0)