summaryrefslogtreecommitdiff
path: root/patches/net__Properly_annotate_the_try-lock_for_the_seqlock.patch
blob: ea946d2079ac1df7348a53cfdcbfab79274b8e9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Subject: net: Properly annotate the try-lock for the seqlock
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Tue Sep  8 16:57:11 2020 +0200

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

In patch
   ("net/Qdisc: use a seqlock instead seqcount")

the seqcount has been replaced with a seqlock to allow to reader to
boost the preempted writer.
The try_write_seqlock() acquired the lock with a try-lock but the
seqcount annotation was "lock".

Opencode write_seqcount_t_begin() and use the try-lock annotation for
lockdep.

Reported-by: Mike Galbraith <efault@gmx.de>
Cc: stable-rt@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>


---
 include/net/net_seq_lock.h |    9 ---------
 include/net/sch_generic.h  |   13 ++++++++++++-
 2 files changed, 12 insertions(+), 10 deletions(-)
---
--- a/include/net/net_seq_lock.h
+++ b/include/net/net_seq_lock.h
@@ -6,15 +6,6 @@
 # define net_seq_begin(__r)		read_seqbegin(__r)
 # define net_seq_retry(__r, __s)	read_seqretry(__r, __s)
 
-static inline int try_write_seqlock(seqlock_t *sl)
-{
-	if (spin_trylock(&sl->lock)) {
-		write_seqcount_begin(&sl->seqcount);
-		return 1;
-	}
-	return 0;
-}
-
 #else
 # define net_seqlock_t			seqcount_t
 # define net_seq_begin(__r)		read_seqcount_begin(__r)
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -216,7 +216,18 @@ static inline bool qdisc_run_begin(struc
 	}
 
 #ifdef CONFIG_PREEMPT_RT
-	return try_write_seqlock(&qdisc->running);
+	if (spin_trylock(&qdisc->running.lock)) {
+		seqcount_t *s = &qdisc->running.seqcount.seqcount;
+
+		/*
+		 * Variant of write_seqcount_t_begin() telling lockdep that
+		 * a trylock was attempted.
+		 */
+		do_raw_write_seqcount_begin(s);
+		seqcount_acquire(&s->dep_map, 0, 1, _RET_IP_);
+		return true;
+	}
+	return false;
 #else
 	/* Variant of write_seqcount_begin() telling lockdep a trylock
 	 * was attempted.