History

Merge tag 'locking-core-2024-03-11' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking updates from Ingo Molnar: - Micro-optimize local_xchg() and the rtmutex code on x86 - Fix percpu-rwsem contention tracepoints - Simplify debugging Kconfig dependencies - Update/clarify the documentation of atomic primitives - Misc cleanups * tag 'locking-core-2024-03-11' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: locking/rtmutex: Use try_cmpxchg_relaxed() in mark_rt_mutex_waiters() locking/x86: Implement local_xchg() using CMPXCHG without the LOCK prefix locking/percpu-rwsem: Trigger contention tracepoints only if contended locking/rwsem: Make DEBUG_RWSEMS and PREEMPT_RT mutually exclusive locking/rwsem: Clarify that RWSEM_READER_OWNED is just a hint locking/mutex: Simplify <linux/mutex.h> locking/qspinlock: Fix 'wait_early' set but not used warning locking/atomic: scripts: Clarify ordering of conditional atomics

Linus Torvalds committed 2 years ago

Commit a5b1a012 parents b040240 ce3576e17 files · +154 −49Browse files

Unified · Split

17 files
  1. arch/x86/include/asm/local.h +14 −2
  2. include/linux/atomic/atomic-arch-fallback.h +37 −9
  3. include/linux/atomic/atomic-instrumented.h +55 −13
  4. include/linux/atomic/atomic-long.h +19 −5
  5. include/linux/mutex.h +2 −6
  6. kernel/locking/percpu-rwsem.c +8 −3
  7. kernel/locking/qspinlock_paravirt.h +1 −1
  8. kernel/locking/rtmutex.c +5 −4
  9. kernel/locking/rwsem.c +3 −3
  10. lib/Kconfig.debug +2 −2
  11. scripts/atomic/kerneldoc/add_unless +1 −0
  12. scripts/atomic/kerneldoc/cmpxchg +1 −0
  13. scripts/atomic/kerneldoc/dec_if_positive +1 −0
  14. scripts/atomic/kerneldoc/dec_unless_positive +1 −0
  15. scripts/atomic/kerneldoc/inc_not_zero +1 −0
  16. scripts/atomic/kerneldoc/inc_unless_negative +1 −0
  17. scripts/atomic/kerneldoc/try_cmpxchg +2 −1
arch/x86/include/asm/local.h+14−2
@@ -131,8 +131,20 @@ static inline bool local_try_cmpxchg(local_t *l, long *old, long new) · 130 unmodified lines
131131 (typeof(l->a.counter) *) old, new);
132132 }
133133
134−/* Always has a lock prefix */
135−#define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
134+/*
135+ * Implement local_xchg using CMPXCHG instruction without the LOCK prefix.
136+ * XCHG is expensive due to the implied LOCK prefix. The processor
137+ * cannot prefetch cachelines if XCHG is used.
138+ */
139+static __always_inline long
140+local_xchg(local_t *l, long n)
141+{
142+ long c = local_read(l);
143+
144+ do { } while (!local_try_cmpxchg(l, &c, n));
145+
146+ return c;
147+}
136148
137149 /**
138150 * local_add_unless - add unless the number is already a given value
include/linux/atomic/atomic-arch-fallback.h+37−9
@@ -2005,6 +2005,7 @@ raw_atomic_xchg_relaxed(atomic_t *v, int new) · 2004 unmodified lines
20052005 * @new: int value to assign
20062006 *
20072007 * If (@v == @old), atomically updates @v to @new with full ordering.
2008+ * Otherwise, @v is not modified and relaxed ordering is provided.
20082009 *
20092010 * Safe to use in noinstr code; prefer atomic_cmpxchg() elsewhere.
20102011 *
@@ -2033,6 +2034,7 @@ raw_atomic_cmpxchg(atomic_t *v, int old, int new) · 22 unmodified lines
20332034 * @new: int value to assign
20342035 *
20352036 * If (@v == @old), atomically updates @v to @new with acquire ordering.
2037+ * Otherwise, @v is not modified and relaxed ordering is provided.
20362038 *
20372039 * Safe to use in noinstr code; prefer atomic_cmpxchg_acquire() elsewhere.
20382040 *
@@ -2061,6 +2063,7 @@ raw_atomic_cmpxchg_acquire(atomic_t *v, int old, int new) · 22 unmodified lines
20612063 * @new: int value to assign
20622064 *
20632065 * If (@v == @old), atomically updates @v to @new with release ordering.
2066+ * Otherwise, @v is not modified and relaxed ordering is provided.
20642067 *
20652068 * Safe to use in noinstr code; prefer atomic_cmpxchg_release() elsewhere.
20662069 *
@@ -2088,6 +2091,7 @@ raw_atomic_cmpxchg_release(atomic_t *v, int old, int new) · 21 unmodified lines
20882091 * @new: int value to assign
20892092 *
20902093 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
2094+ * Otherwise, @v is not modified and relaxed ordering is provided.
20912095 *
20922096 * Safe to use in noinstr code; prefer atomic_cmpxchg_relaxed() elsewhere.
20932097 *
@@ -2112,7 +2116,8 @@ raw_atomic_cmpxchg_relaxed(atomic_t *v, int old, int new) · 18 unmodified lines
21122116 * @new: int value to assign
21132117 *
21142118 * If (@v == @old), atomically updates @v to @new with full ordering.
2115− * Otherwise, updates @old to the current value of @v.
2119+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
2120+ * and relaxed ordering is provided.
21162121 *
21172122 * Safe to use in noinstr code; prefer atomic_try_cmpxchg() elsewhere.
21182123 *
@@ -2145,7 +2150,8 @@ raw_atomic_try_cmpxchg(atomic_t *v, int *old, int new) · 26 unmodified lines
21452150 * @new: int value to assign
21462151 *
21472152 * If (@v == @old), atomically updates @v to @new with acquire ordering.
2148− * Otherwise, updates @old to the current value of @v.
2153+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
2154+ * and relaxed ordering is provided.
21492155 *
21502156 * Safe to use in noinstr code; prefer atomic_try_cmpxchg_acquire() elsewhere.
21512157 *
@@ -2178,7 +2184,8 @@ raw_atomic_try_cmpxchg_acquire(atomic_t *v, int *old, int new) · 26 unmodified lines
21782184 * @new: int value to assign
21792185 *
21802186 * If (@v == @old), atomically updates @v to @new with release ordering.
2181− * Otherwise, updates @old to the current value of @v.
2187+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
2188+ * and relaxed ordering is provided.
21822189 *
21832190 * Safe to use in noinstr code; prefer atomic_try_cmpxchg_release() elsewhere.
21842191 *
@@ -2210,7 +2217,8 @@ raw_atomic_try_cmpxchg_release(atomic_t *v, int *old, int new) · 25 unmodified lines
22102217 * @new: int value to assign
22112218 *
22122219 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
2213− * Otherwise, updates @old to the current value of @v.
2220+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
2221+ * and relaxed ordering is provided.
22142222 *
22152223 * Safe to use in noinstr code; prefer atomic_try_cmpxchg_relaxed() elsewhere.
22162224 *
@@ -2403,6 +2411,7 @@ raw_atomic_add_negative_relaxed(int i, atomic_t *v) · 186 unmodified lines
24032411 * @u: int value to compare with
24042412 *
24052413 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
2414+ * Otherwise, @v is not modified and relaxed ordering is provided.
24062415 *
24072416 * Safe to use in noinstr code; prefer atomic_fetch_add_unless() elsewhere.
24082417 *
@@ -2432,6 +2441,7 @@ raw_atomic_fetch_add_unless(atomic_t *v, int a, int u) · 23 unmodified lines
24322441 * @u: int value to compare with
24332442 *
24342443 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
2444+ * Otherwise, @v is not modified and relaxed ordering is provided.
24352445 *
24362446 * Safe to use in noinstr code; prefer atomic_add_unless() elsewhere.
24372447 *
@@ -2452,6 +2462,7 @@ raw_atomic_add_unless(atomic_t *v, int a, int u) · 14 unmodified lines
24522462 * @v: pointer to atomic_t
24532463 *
24542464 * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
2465+ * Otherwise, @v is not modified and relaxed ordering is provided.
24552466 *
24562467 * Safe to use in noinstr code; prefer atomic_inc_not_zero() elsewhere.
24572468 *
@@ -2472,6 +2483,7 @@ raw_atomic_inc_not_zero(atomic_t *v) · 14 unmodified lines
24722483 * @v: pointer to atomic_t
24732484 *
24742485 * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
2486+ * Otherwise, @v is not modified and relaxed ordering is provided.
24752487 *
24762488 * Safe to use in noinstr code; prefer atomic_inc_unless_negative() elsewhere.
24772489 *
@@ -2499,6 +2511,7 @@ raw_atomic_inc_unless_negative(atomic_t *v) · 21 unmodified lines
24992511 * @v: pointer to atomic_t
25002512 *
25012513 * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
2514+ * Otherwise, @v is not modified and relaxed ordering is provided.
25022515 *
25032516 * Safe to use in noinstr code; prefer atomic_dec_unless_positive() elsewhere.
25042517 *
@@ -2526,6 +2539,7 @@ raw_atomic_dec_unless_positive(atomic_t *v) · 21 unmodified lines
25262539 * @v: pointer to atomic_t
25272540 *
25282541 * If (@v > 0), atomically updates @v to (@v - 1) with full ordering.
2542+ * Otherwise, @v is not modified and relaxed ordering is provided.
25292543 *
25302544 * Safe to use in noinstr code; prefer atomic_dec_if_positive() elsewhere.
25312545 *
@@ -4117,6 +4131,7 @@ raw_atomic64_xchg_relaxed(atomic64_t *v, s64 new) · 1585 unmodified lines
41174131 * @new: s64 value to assign
41184132 *
41194133 * If (@v == @old), atomically updates @v to @new with full ordering.
4134+ * Otherwise, @v is not modified and relaxed ordering is provided.
41204135 *
41214136 * Safe to use in noinstr code; prefer atomic64_cmpxchg() elsewhere.
41224137 *
@@ -4145,6 +4160,7 @@ raw_atomic64_cmpxchg(atomic64_t *v, s64 old, s64 new) · 22 unmodified lines
41454160 * @new: s64 value to assign
41464161 *
41474162 * If (@v == @old), atomically updates @v to @new with acquire ordering.
4163+ * Otherwise, @v is not modified and relaxed ordering is provided.
41484164 *
41494165 * Safe to use in noinstr code; prefer atomic64_cmpxchg_acquire() elsewhere.
41504166 *
@@ -4173,6 +4189,7 @@ raw_atomic64_cmpxchg_acquire(atomic64_t *v, s64 old, s64 new) · 22 unmodified lines
41734189 * @new: s64 value to assign
41744190 *
41754191 * If (@v == @old), atomically updates @v to @new with release ordering.
4192+ * Otherwise, @v is not modified and relaxed ordering is provided.
41764193 *
41774194 * Safe to use in noinstr code; prefer atomic64_cmpxchg_release() elsewhere.
41784195 *
@@ -4200,6 +4217,7 @@ raw_atomic64_cmpxchg_release(atomic64_t *v, s64 old, s64 new) · 21 unmodified lines
42004217 * @new: s64 value to assign
42014218 *
42024219 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
4220+ * Otherwise, @v is not modified and relaxed ordering is provided.
42034221 *
42044222 * Safe to use in noinstr code; prefer atomic64_cmpxchg_relaxed() elsewhere.
42054223 *
@@ -4224,7 +4242,8 @@ raw_atomic64_cmpxchg_relaxed(atomic64_t *v, s64 old, s64 new) · 18 unmodified lines
42244242 * @new: s64 value to assign
42254243 *
42264244 * If (@v == @old), atomically updates @v to @new with full ordering.
4227− * Otherwise, updates @old to the current value of @v.
4245+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
4246+ * and relaxed ordering is provided.
42284247 *
42294248 * Safe to use in noinstr code; prefer atomic64_try_cmpxchg() elsewhere.
42304249 *
@@ -4257,7 +4276,8 @@ raw_atomic64_try_cmpxchg(atomic64_t *v, s64 *old, s64 new) · 26 unmodified lines
42574276 * @new: s64 value to assign
42584277 *
42594278 * If (@v == @old), atomically updates @v to @new with acquire ordering.
4260− * Otherwise, updates @old to the current value of @v.
4279+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
4280+ * and relaxed ordering is provided.
42614281 *
42624282 * Safe to use in noinstr code; prefer atomic64_try_cmpxchg_acquire() elsewhere.
42634283 *
@@ -4290,7 +4310,8 @@ raw_atomic64_try_cmpxchg_acquire(atomic64_t *v, s64 *old, s64 new) · 26 unmodified lines
42904310 * @new: s64 value to assign
42914311 *
42924312 * If (@v == @old), atomically updates @v to @new with release ordering.
4293− * Otherwise, updates @old to the current value of @v.
4313+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
4314+ * and relaxed ordering is provided.
42944315 *
42954316 * Safe to use in noinstr code; prefer atomic64_try_cmpxchg_release() elsewhere.
42964317 *
@@ -4322,7 +4343,8 @@ raw_atomic64_try_cmpxchg_release(atomic64_t *v, s64 *old, s64 new) · 25 unmodified lines
43224343 * @new: s64 value to assign
43234344 *
43244345 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
4325− * Otherwise, updates @old to the current value of @v.
4346+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
4347+ * and relaxed ordering is provided.
43264348 *
43274349 * Safe to use in noinstr code; prefer atomic64_try_cmpxchg_relaxed() elsewhere.
43284350 *
@@ -4515,6 +4537,7 @@ raw_atomic64_add_negative_relaxed(s64 i, atomic64_t *v) · 186 unmodified lines
45154537 * @u: s64 value to compare with
45164538 *
45174539 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
4540+ * Otherwise, @v is not modified and relaxed ordering is provided.
45184541 *
45194542 * Safe to use in noinstr code; prefer atomic64_fetch_add_unless() elsewhere.
45204543 *
@@ -4544,6 +4567,7 @@ raw_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u) · 23 unmodified lines
45444567 * @u: s64 value to compare with
45454568 *
45464569 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
4570+ * Otherwise, @v is not modified and relaxed ordering is provided.
45474571 *
45484572 * Safe to use in noinstr code; prefer atomic64_add_unless() elsewhere.
45494573 *
@@ -4564,6 +4588,7 @@ raw_atomic64_add_unless(atomic64_t *v, s64 a, s64 u) · 14 unmodified lines
45644588 * @v: pointer to atomic64_t
45654589 *
45664590 * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
4591+ * Otherwise, @v is not modified and relaxed ordering is provided.
45674592 *
45684593 * Safe to use in noinstr code; prefer atomic64_inc_not_zero() elsewhere.
45694594 *
@@ -4584,6 +4609,7 @@ raw_atomic64_inc_not_zero(atomic64_t *v) · 14 unmodified lines
45844609 * @v: pointer to atomic64_t
45854610 *
45864611 * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
4612+ * Otherwise, @v is not modified and relaxed ordering is provided.
45874613 *
45884614 * Safe to use in noinstr code; prefer atomic64_inc_unless_negative() elsewhere.
45894615 *
@@ -4611,6 +4637,7 @@ raw_atomic64_inc_unless_negative(atomic64_t *v) · 21 unmodified lines
46114637 * @v: pointer to atomic64_t
46124638 *
46134639 * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
4640+ * Otherwise, @v is not modified and relaxed ordering is provided.
46144641 *
46154642 * Safe to use in noinstr code; prefer atomic64_dec_unless_positive() elsewhere.
46164643 *
@@ -4638,6 +4665,7 @@ raw_atomic64_dec_unless_positive(atomic64_t *v) · 21 unmodified lines
46384665 * @v: pointer to atomic64_t
46394666 *
46404667 * If (@v > 0), atomically updates @v to (@v - 1) with full ordering.
4668+ * Otherwise, @v is not modified and relaxed ordering is provided.
46414669 *
46424670 * Safe to use in noinstr code; prefer atomic64_dec_if_positive() elsewhere.
46434671 *
@@ -4662,4 +4690,4 @@ raw_atomic64_dec_if_positive(atomic64_t *v) · 18 unmodified lines
46624690 }
46634691
46644692 #endif /* _LINUX_ATOMIC_FALLBACK_H */
4665−// eec048affea735b8464f58e6d96992101f8f85f1
4693+// 14850c0b0db20c62fdc78ccd1d42b98b88d76331
include/linux/atomic/atomic-instrumented.h+55−13
@@ -1182,6 +1182,7 @@ atomic_xchg_relaxed(atomic_t *v, int new) · 1181 unmodified lines
11821182 * @new: int value to assign
11831183 *
11841184 * If (@v == @old), atomically updates @v to @new with full ordering.
1185+ * Otherwise, @v is not modified and relaxed ordering is provided.
11851186 *
11861187 * Unsafe to use in noinstr code; use raw_atomic_cmpxchg() there.
11871188 *
@@ -1202,6 +1203,7 @@ atomic_cmpxchg(atomic_t *v, int old, int new) · 14 unmodified lines
12021203 * @new: int value to assign
12031204 *
12041205 * If (@v == @old), atomically updates @v to @new with acquire ordering.
1206+ * Otherwise, @v is not modified and relaxed ordering is provided.
12051207 *
12061208 * Unsafe to use in noinstr code; use raw_atomic_cmpxchg_acquire() there.
12071209 *
@@ -1221,6 +1223,7 @@ atomic_cmpxchg_acquire(atomic_t *v, int old, int new) · 13 unmodified lines
12211223 * @new: int value to assign
12221224 *
12231225 * If (@v == @old), atomically updates @v to @new with release ordering.
1226+ * Otherwise, @v is not modified and relaxed ordering is provided.
12241227 *
12251228 * Unsafe to use in noinstr code; use raw_atomic_cmpxchg_release() there.
12261229 *
@@ -1241,6 +1244,7 @@ atomic_cmpxchg_release(atomic_t *v, int old, int new) · 14 unmodified lines
12411244 * @new: int value to assign
12421245 *
12431246 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
1247+ * Otherwise, @v is not modified and relaxed ordering is provided.
12441248 *
12451249 * Unsafe to use in noinstr code; use raw_atomic_cmpxchg_relaxed() there.
12461250 *
@@ -1260,7 +1264,8 @@ atomic_cmpxchg_relaxed(atomic_t *v, int old, int new) · 13 unmodified lines
12601264 * @new: int value to assign
12611265 *
12621266 * If (@v == @old), atomically updates @v to @new with full ordering.
1263− * Otherwise, updates @old to the current value of @v.
1267+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
1268+ * and relaxed ordering is provided.
12641269 *
12651270 * Unsafe to use in noinstr code; use raw_atomic_try_cmpxchg() there.
12661271 *
@@ -1282,7 +1287,8 @@ atomic_try_cmpxchg(atomic_t *v, int *old, int new) · 15 unmodified lines
12821287 * @new: int value to assign
12831288 *
12841289 * If (@v == @old), atomically updates @v to @new with acquire ordering.
1285− * Otherwise, updates @old to the current value of @v.
1290+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
1291+ * and relaxed ordering is provided.
12861292 *
12871293 * Unsafe to use in noinstr code; use raw_atomic_try_cmpxchg_acquire() there.
12881294 *
@@ -1303,7 +1309,8 @@ atomic_try_cmpxchg_acquire(atomic_t *v, int *old, int new) · 14 unmodified lines
13031309 * @new: int value to assign
13041310 *
13051311 * If (@v == @old), atomically updates @v to @new with release ordering.
1306− * Otherwise, updates @old to the current value of @v.
1312+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
1313+ * and relaxed ordering is provided.
13071314 *
13081315 * Unsafe to use in noinstr code; use raw_atomic_try_cmpxchg_release() there.
13091316 *
@@ -1325,7 +1332,8 @@ atomic_try_cmpxchg_release(atomic_t *v, int *old, int new) · 15 unmodified lines
13251332 * @new: int value to assign
13261333 *
13271334 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
1328− * Otherwise, updates @old to the current value of @v.
1335+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
1336+ * and relaxed ordering is provided.
13291337 *
13301338 * Unsafe to use in noinstr code; use raw_atomic_try_cmpxchg_relaxed() there.
13311339 *
@@ -1475,6 +1483,7 @@ atomic_add_negative_relaxed(int i, atomic_t *v) · 143 unmodified lines
14751483 * @u: int value to compare with
14761484 *
14771485 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
1486+ * Otherwise, @v is not modified and relaxed ordering is provided.
14781487 *
14791488 * Unsafe to use in noinstr code; use raw_atomic_fetch_add_unless() there.
14801489 *
@@ -1495,6 +1504,7 @@ atomic_fetch_add_unless(atomic_t *v, int a, int u) · 14 unmodified lines
14951504 * @u: int value to compare with
14961505 *
14971506 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
1507+ * Otherwise, @v is not modified and relaxed ordering is provided.
14981508 *
14991509 * Unsafe to use in noinstr code; use raw_atomic_add_unless() there.
15001510 *
@@ -1513,6 +1523,7 @@ atomic_add_unless(atomic_t *v, int a, int u) · 12 unmodified lines
15131523 * @v: pointer to atomic_t
15141524 *
15151525 * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
1526+ * Otherwise, @v is not modified and relaxed ordering is provided.
15161527 *
15171528 * Unsafe to use in noinstr code; use raw_atomic_inc_not_zero() there.
15181529 *
@@ -1531,6 +1542,7 @@ atomic_inc_not_zero(atomic_t *v) · 12 unmodified lines
15311542 * @v: pointer to atomic_t
15321543 *
15331544 * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
1545+ * Otherwise, @v is not modified and relaxed ordering is provided.
15341546 *
15351547 * Unsafe to use in noinstr code; use raw_atomic_inc_unless_negative() there.
15361548 *
@@ -1549,6 +1561,7 @@ atomic_inc_unless_negative(atomic_t *v) · 12 unmodified lines
15491561 * @v: pointer to atomic_t
15501562 *
15511563 * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
1564+ * Otherwise, @v is not modified and relaxed ordering is provided.
15521565 *
15531566 * Unsafe to use in noinstr code; use raw_atomic_dec_unless_positive() there.
15541567 *
@@ -1567,6 +1580,7 @@ atomic_dec_unless_positive(atomic_t *v) · 12 unmodified lines
15671580 * @v: pointer to atomic_t
15681581 *
15691582 * If (@v > 0), atomically updates @v to (@v - 1) with full ordering.
1583+ * Otherwise, @v is not modified and relaxed ordering is provided.
15701584 *
15711585 * Unsafe to use in noinstr code; use raw_atomic_dec_if_positive() there.
15721586 *
@@ -2746,6 +2760,7 @@ atomic64_xchg_relaxed(atomic64_t *v, s64 new) · 1173 unmodified lines
27462760 * @new: s64 value to assign
27472761 *
27482762 * If (@v == @old), atomically updates @v to @new with full ordering.
2763+ * Otherwise, @v is not modified and relaxed ordering is provided.
27492764 *
27502765 * Unsafe to use in noinstr code; use raw_atomic64_cmpxchg() there.
27512766 *
@@ -2766,6 +2781,7 @@ atomic64_cmpxchg(atomic64_t *v, s64 old, s64 new) · 14 unmodified lines
27662781 * @new: s64 value to assign
27672782 *
27682783 * If (@v == @old), atomically updates @v to @new with acquire ordering.
2784+ * Otherwise, @v is not modified and relaxed ordering is provided.
27692785 *
27702786 * Unsafe to use in noinstr code; use raw_atomic64_cmpxchg_acquire() there.
27712787 *
@@ -2785,6 +2801,7 @@ atomic64_cmpxchg_acquire(atomic64_t *v, s64 old, s64 new) · 13 unmodified lines
27852801 * @new: s64 value to assign
27862802 *
27872803 * If (@v == @old), atomically updates @v to @new with release ordering.
2804+ * Otherwise, @v is not modified and relaxed ordering is provided.
27882805 *
27892806 * Unsafe to use in noinstr code; use raw_atomic64_cmpxchg_release() there.
27902807 *
@@ -2805,6 +2822,7 @@ atomic64_cmpxchg_release(atomic64_t *v, s64 old, s64 new) · 14 unmodified lines
28052822 * @new: s64 value to assign
28062823 *
28072824 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
2825+ * Otherwise, @v is not modified and relaxed ordering is provided.
28082826 *
28092827 * Unsafe to use in noinstr code; use raw_atomic64_cmpxchg_relaxed() there.
28102828 *
@@ -2824,7 +2842,8 @@ atomic64_cmpxchg_relaxed(atomic64_t *v, s64 old, s64 new) · 13 unmodified lines
28242842 * @new: s64 value to assign
28252843 *
28262844 * If (@v == @old), atomically updates @v to @new with full ordering.
2827− * Otherwise, updates @old to the current value of @v.
2845+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
2846+ * and relaxed ordering is provided.
28282847 *
28292848 * Unsafe to use in noinstr code; use raw_atomic64_try_cmpxchg() there.
28302849 *
@@ -2846,7 +2865,8 @@ atomic64_try_cmpxchg(atomic64_t *v, s64 *old, s64 new) · 15 unmodified lines
28462865 * @new: s64 value to assign
28472866 *
28482867 * If (@v == @old), atomically updates @v to @new with acquire ordering.
2849− * Otherwise, updates @old to the current value of @v.
2868+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
2869+ * and relaxed ordering is provided.
28502870 *
28512871 * Unsafe to use in noinstr code; use raw_atomic64_try_cmpxchg_acquire() there.
28522872 *
@@ -2867,7 +2887,8 @@ atomic64_try_cmpxchg_acquire(atomic64_t *v, s64 *old, s64 new) · 14 unmodified lines
28672887 * @new: s64 value to assign
28682888 *
28692889 * If (@v == @old), atomically updates @v to @new with release ordering.
2870− * Otherwise, updates @old to the current value of @v.
2890+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
2891+ * and relaxed ordering is provided.
28712892 *
28722893 * Unsafe to use in noinstr code; use raw_atomic64_try_cmpxchg_release() there.
28732894 *
@@ -2889,7 +2910,8 @@ atomic64_try_cmpxchg_release(atomic64_t *v, s64 *old, s64 new) · 15 unmodified lines
28892910 * @new: s64 value to assign
28902911 *
28912912 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
2892− * Otherwise, updates @old to the current value of @v.
2913+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
2914+ * and relaxed ordering is provided.
28932915 *
28942916 * Unsafe to use in noinstr code; use raw_atomic64_try_cmpxchg_relaxed() there.
28952917 *
@@ -3039,6 +3061,7 @@ atomic64_add_negative_relaxed(s64 i, atomic64_t *v) · 143 unmodified lines
30393061 * @u: s64 value to compare with
30403062 *
30413063 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
3064+ * Otherwise, @v is not modified and relaxed ordering is provided.
30423065 *
30433066 * Unsafe to use in noinstr code; use raw_atomic64_fetch_add_unless() there.
30443067 *
@@ -3059,6 +3082,7 @@ atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u) · 14 unmodified lines
30593082 * @u: s64 value to compare with
30603083 *
30613084 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
3085+ * Otherwise, @v is not modified and relaxed ordering is provided.
30623086 *
30633087 * Unsafe to use in noinstr code; use raw_atomic64_add_unless() there.
30643088 *
@@ -3077,6 +3101,7 @@ atomic64_add_unless(atomic64_t *v, s64 a, s64 u) · 12 unmodified lines
30773101 * @v: pointer to atomic64_t
30783102 *
30793103 * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
3104+ * Otherwise, @v is not modified and relaxed ordering is provided.
30803105 *
30813106 * Unsafe to use in noinstr code; use raw_atomic64_inc_not_zero() there.
30823107 *
@@ -3095,6 +3120,7 @@ atomic64_inc_not_zero(atomic64_t *v) · 12 unmodified lines
30953120 * @v: pointer to atomic64_t
30963121 *
30973122 * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
3123+ * Otherwise, @v is not modified and relaxed ordering is provided.
30983124 *
30993125 * Unsafe to use in noinstr code; use raw_atomic64_inc_unless_negative() there.
31003126 *
@@ -3113,6 +3139,7 @@ atomic64_inc_unless_negative(atomic64_t *v) · 12 unmodified lines
31133139 * @v: pointer to atomic64_t
31143140 *
31153141 * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
3142+ * Otherwise, @v is not modified and relaxed ordering is provided.
31163143 *
31173144 * Unsafe to use in noinstr code; use raw_atomic64_dec_unless_positive() there.
31183145 *
@@ -3131,6 +3158,7 @@ atomic64_dec_unless_positive(atomic64_t *v) · 12 unmodified lines
31313158 * @v: pointer to atomic64_t
31323159 *
31333160 * If (@v > 0), atomically updates @v to (@v - 1) with full ordering.
3161+ * Otherwise, @v is not modified and relaxed ordering is provided.
31343162 *
31353163 * Unsafe to use in noinstr code; use raw_atomic64_dec_if_positive() there.
31363164 *
@@ -4310,6 +4338,7 @@ atomic_long_xchg_relaxed(atomic_long_t *v, long new) · 1173 unmodified lines
43104338 * @new: long value to assign
43114339 *
43124340 * If (@v == @old), atomically updates @v to @new with full ordering.
4341+ * Otherwise, @v is not modified and relaxed ordering is provided.
43134342 *
43144343 * Unsafe to use in noinstr code; use raw_atomic_long_cmpxchg() there.
43154344 *
@@ -4330,6 +4359,7 @@ atomic_long_cmpxchg(atomic_long_t *v, long old, long new) · 14 unmodified lines
43304359 * @new: long value to assign
43314360 *
43324361 * If (@v == @old), atomically updates @v to @new with acquire ordering.
4362+ * Otherwise, @v is not modified and relaxed ordering is provided.
43334363 *
43344364 * Unsafe to use in noinstr code; use raw_atomic_long_cmpxchg_acquire() there.
43354365 *
@@ -4349,6 +4379,7 @@ atomic_long_cmpxchg_acquire(atomic_long_t *v, long old, long new) · 13 unmodified lines
43494379 * @new: long value to assign
43504380 *
43514381 * If (@v == @old), atomically updates @v to @new with release ordering.
4382+ * Otherwise, @v is not modified and relaxed ordering is provided.
43524383 *
43534384 * Unsafe to use in noinstr code; use raw_atomic_long_cmpxchg_release() there.
43544385 *
@@ -4369,6 +4400,7 @@ atomic_long_cmpxchg_release(atomic_long_t *v, long old, long new) · 14 unmodified lines
43694400 * @new: long value to assign
43704401 *
43714402 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
4403+ * Otherwise, @v is not modified and relaxed ordering is provided.
43724404 *
43734405 * Unsafe to use in noinstr code; use raw_atomic_long_cmpxchg_relaxed() there.
43744406 *
@@ -4388,7 +4420,8 @@ atomic_long_cmpxchg_relaxed(atomic_long_t *v, long old, long new) · 13 unmodified lines
43884420 * @new: long value to assign
43894421 *
43904422 * If (@v == @old), atomically updates @v to @new with full ordering.
4391− * Otherwise, updates @old to the current value of @v.
4423+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
4424+ * and relaxed ordering is provided.
43924425 *
43934426 * Unsafe to use in noinstr code; use raw_atomic_long_try_cmpxchg() there.
43944427 *
@@ -4410,7 +4443,8 @@ atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new) · 15 unmodified lines
44104443 * @new: long value to assign
44114444 *
44124445 * If (@v == @old), atomically updates @v to @new with acquire ordering.
4413− * Otherwise, updates @old to the current value of @v.
4446+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
4447+ * and relaxed ordering is provided.
44144448 *
44154449 * Unsafe to use in noinstr code; use raw_atomic_long_try_cmpxchg_acquire() there.
44164450 *
@@ -4431,7 +4465,8 @@ atomic_long_try_cmpxchg_acquire(atomic_long_t *v, long *old, long new) · 14 unmodified lines
44314465 * @new: long value to assign
44324466 *
44334467 * If (@v == @old), atomically updates @v to @new with release ordering.
4434− * Otherwise, updates @old to the current value of @v.
4468+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
4469+ * and relaxed ordering is provided.
44354470 *
44364471 * Unsafe to use in noinstr code; use raw_atomic_long_try_cmpxchg_release() there.
44374472 *
@@ -4453,7 +4488,8 @@ atomic_long_try_cmpxchg_release(atomic_long_t *v, long *old, long new) · 15 unmodified lines
44534488 * @new: long value to assign
44544489 *
44554490 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
4456− * Otherwise, updates @old to the current value of @v.
4491+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
4492+ * and relaxed ordering is provided.
44574493 *
44584494 * Unsafe to use in noinstr code; use raw_atomic_long_try_cmpxchg_relaxed() there.
44594495 *
@@ -4603,6 +4639,7 @@ atomic_long_add_negative_relaxed(long i, atomic_long_t *v) · 143 unmodified lines
46034639 * @u: long value to compare with
46044640 *
46054641 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
4642+ * Otherwise, @v is not modified and relaxed ordering is provided.
46064643 *
46074644 * Unsafe to use in noinstr code; use raw_atomic_long_fetch_add_unless() there.
46084645 *
@@ -4623,6 +4660,7 @@ atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u) · 14 unmodified lines
46234660 * @u: long value to compare with
46244661 *
46254662 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
4663+ * Otherwise, @v is not modified and relaxed ordering is provided.
46264664 *
46274665 * Unsafe to use in noinstr code; use raw_atomic_long_add_unless() there.
46284666 *
@@ -4641,6 +4679,7 @@ atomic_long_add_unless(atomic_long_t *v, long a, long u) · 12 unmodified lines
46414679 * @v: pointer to atomic_long_t
46424680 *
46434681 * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
4682+ * Otherwise, @v is not modified and relaxed ordering is provided.
46444683 *
46454684 * Unsafe to use in noinstr code; use raw_atomic_long_inc_not_zero() there.
46464685 *
@@ -4659,6 +4698,7 @@ atomic_long_inc_not_zero(atomic_long_t *v) · 12 unmodified lines
46594698 * @v: pointer to atomic_long_t
46604699 *
46614700 * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
4701+ * Otherwise, @v is not modified and relaxed ordering is provided.
46624702 *
46634703 * Unsafe to use in noinstr code; use raw_atomic_long_inc_unless_negative() there.
46644704 *
@@ -4677,6 +4717,7 @@ atomic_long_inc_unless_negative(atomic_long_t *v) · 12 unmodified lines
46774717 * @v: pointer to atomic_long_t
46784718 *
46794719 * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
4720+ * Otherwise, @v is not modified and relaxed ordering is provided.
46804721 *
46814722 * Unsafe to use in noinstr code; use raw_atomic_long_dec_unless_positive() there.
46824723 *
@@ -4695,6 +4736,7 @@ atomic_long_dec_unless_positive(atomic_long_t *v) · 12 unmodified lines
46954736 * @v: pointer to atomic_long_t
46964737 *
46974738 * If (@v > 0), atomically updates @v to (@v - 1) with full ordering.
4739+ * Otherwise, @v is not modified and relaxed ordering is provided.
46984740 *
46994741 * Unsafe to use in noinstr code; use raw_atomic_long_dec_if_positive() there.
47004742 *
@@ -5008,4 +5050,4 @@ atomic_long_dec_if_positive(atomic_long_t *v) · 307 unmodified lines
50085050
50095051
50105052 #endif /* _LINUX_ATOMIC_INSTRUMENTED_H */
5011−// 2cc4bc990fef44d3836ec108f11b610f3f438184
5053+// ce5b65e0f1f8a276268b667194581d24bed219d4
include/linux/atomic/atomic-long.h+19−5
@@ -1352,6 +1352,7 @@ raw_atomic_long_xchg_relaxed(atomic_long_t *v, long new) · 1351 unmodified lines
13521352 * @new: long value to assign
13531353 *
13541354 * If (@v == @old), atomically updates @v to @new with full ordering.
1355+ * Otherwise, @v is not modified and relaxed ordering is provided.
13551356 *
13561357 * Safe to use in noinstr code; prefer atomic_long_cmpxchg() elsewhere.
13571358 *
@@ -1374,6 +1375,7 @@ raw_atomic_long_cmpxchg(atomic_long_t *v, long old, long new) · 16 unmodified lines
13741375 * @new: long value to assign
13751376 *
13761377 * If (@v == @old), atomically updates @v to @new with acquire ordering.
1378+ * Otherwise, @v is not modified and relaxed ordering is provided.
13771379 *
13781380 * Safe to use in noinstr code; prefer atomic_long_cmpxchg_acquire() elsewhere.
13791381 *
@@ -1396,6 +1398,7 @@ raw_atomic_long_cmpxchg_acquire(atomic_long_t *v, long old, long new) · 16 unmodified lines
13961398 * @new: long value to assign
13971399 *
13981400 * If (@v == @old), atomically updates @v to @new with release ordering.
1401+ * Otherwise, @v is not modified and relaxed ordering is provided.
13991402 *
14001403 * Safe to use in noinstr code; prefer atomic_long_cmpxchg_release() elsewhere.
14011404 *
@@ -1418,6 +1421,7 @@ raw_atomic_long_cmpxchg_release(atomic_long_t *v, long old, long new) · 16 unmodified lines
14181421 * @new: long value to assign
14191422 *
14201423 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
1424+ * Otherwise, @v is not modified and relaxed ordering is provided.
14211425 *
14221426 * Safe to use in noinstr code; prefer atomic_long_cmpxchg_relaxed() elsewhere.
14231427 *
@@ -1440,7 +1444,8 @@ raw_atomic_long_cmpxchg_relaxed(atomic_long_t *v, long old, long new) · 16 unmodified lines
14401444 * @new: long value to assign
14411445 *
14421446 * If (@v == @old), atomically updates @v to @new with full ordering.
1443− * Otherwise, updates @old to the current value of @v.
1447+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
1448+ * and relaxed ordering is provided.
14441449 *
14451450 * Safe to use in noinstr code; prefer atomic_long_try_cmpxchg() elsewhere.
14461451 *
@@ -1463,7 +1468,8 @@ raw_atomic_long_try_cmpxchg(atomic_long_t *v, long *old, long new) · 16 unmodified lines
14631468 * @new: long value to assign
14641469 *
14651470 * If (@v == @old), atomically updates @v to @new with acquire ordering.
1466− * Otherwise, updates @old to the current value of @v.
1471+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
1472+ * and relaxed ordering is provided.
14671473 *
14681474 * Safe to use in noinstr code; prefer atomic_long_try_cmpxchg_acquire() elsewhere.
14691475 *
@@ -1486,7 +1492,8 @@ raw_atomic_long_try_cmpxchg_acquire(atomic_long_t *v, long *old, long new) · 16 unmodified lines
14861492 * @new: long value to assign
14871493 *
14881494 * If (@v == @old), atomically updates @v to @new with release ordering.
1489− * Otherwise, updates @old to the current value of @v.
1495+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
1496+ * and relaxed ordering is provided.
14901497 *
14911498 * Safe to use in noinstr code; prefer atomic_long_try_cmpxchg_release() elsewhere.
14921499 *
@@ -1509,7 +1516,8 @@ raw_atomic_long_try_cmpxchg_release(atomic_long_t *v, long *old, long new) · 16 unmodified lines
15091516 * @new: long value to assign
15101517 *
15111518 * If (@v == @old), atomically updates @v to @new with relaxed ordering.
1512− * Otherwise, updates @old to the current value of @v.
1519+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
1520+ * and relaxed ordering is provided.
15131521 *
15141522 * Safe to use in noinstr code; prefer atomic_long_try_cmpxchg_relaxed() elsewhere.
15151523 *
@@ -1677,6 +1685,7 @@ raw_atomic_long_add_negative_relaxed(long i, atomic_long_t *v) · 161 unmodified lines
16771685 * @u: long value to compare with
16781686 *
16791687 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
1688+ * Otherwise, @v is not modified and relaxed ordering is provided.
16801689 *
16811690 * Safe to use in noinstr code; prefer atomic_long_fetch_add_unless() elsewhere.
16821691 *
@@ -1699,6 +1708,7 @@ raw_atomic_long_fetch_add_unless(atomic_long_t *v, long a, long u) · 16 unmodified lines
16991708 * @u: long value to compare with
17001709 *
17011710 * If (@v != @u), atomically updates @v to (@v + @a) with full ordering.
1711+ * Otherwise, @v is not modified and relaxed ordering is provided.
17021712 *
17031713 * Safe to use in noinstr code; prefer atomic_long_add_unless() elsewhere.
17041714 *
@@ -1719,6 +1729,7 @@ raw_atomic_long_add_unless(atomic_long_t *v, long a, long u) · 14 unmodified lines
17191729 * @v: pointer to atomic_long_t
17201730 *
17211731 * If (@v != 0), atomically updates @v to (@v + 1) with full ordering.
1732+ * Otherwise, @v is not modified and relaxed ordering is provided.
17221733 *
17231734 * Safe to use in noinstr code; prefer atomic_long_inc_not_zero() elsewhere.
17241735 *
@@ -1739,6 +1750,7 @@ raw_atomic_long_inc_not_zero(atomic_long_t *v) · 14 unmodified lines
17391750 * @v: pointer to atomic_long_t
17401751 *
17411752 * If (@v >= 0), atomically updates @v to (@v + 1) with full ordering.
1753+ * Otherwise, @v is not modified and relaxed ordering is provided.
17421754 *
17431755 * Safe to use in noinstr code; prefer atomic_long_inc_unless_negative() elsewhere.
17441756 *
@@ -1759,6 +1771,7 @@ raw_atomic_long_inc_unless_negative(atomic_long_t *v) · 14 unmodified lines
17591771 * @v: pointer to atomic_long_t
17601772 *
17611773 * If (@v <= 0), atomically updates @v to (@v - 1) with full ordering.
1774+ * Otherwise, @v is not modified and relaxed ordering is provided.
17621775 *
17631776 * Safe to use in noinstr code; prefer atomic_long_dec_unless_positive() elsewhere.
17641777 *
@@ -1779,6 +1792,7 @@ raw_atomic_long_dec_unless_positive(atomic_long_t *v) · 14 unmodified lines
17791792 * @v: pointer to atomic_long_t
17801793 *
17811794 * If (@v > 0), atomically updates @v to (@v - 1) with full ordering.
1795+ * Otherwise, @v is not modified and relaxed ordering is provided.
17821796 *
17831797 * Safe to use in noinstr code; prefer atomic_long_dec_if_positive() elsewhere.
17841798 *
@@ -1795,4 +1809,4 @@ raw_atomic_long_dec_if_positive(atomic_long_t *v) · 10 unmodified lines
17951809 }
17961810
17971811 #endif /* _LINUX_ATOMIC_LONG_H */
1798−// 4ef23f98c73cff96d239896175fd26b10b88899e
1812+// 1c4a26fc77f345342953770ebe3c4d08e7ce2f9a
include/linux/mutex.h+2−6
@@ -32,11 +32,9 @@ · 31 unmodified lines
3232 # define __DEP_MAP_MUTEX_INITIALIZER(lockname)
3333 #endif
3434
35−#ifndef CONFIG_PREEMPT_RT
36−
3735 #ifdef CONFIG_DEBUG_MUTEXES
3836
39−#define __DEBUG_MUTEX_INITIALIZER(lockname) \
37+# define __DEBUG_MUTEX_INITIALIZER(lockname) \
4038 , .magic = &lockname
4139
4240 extern void mutex_destroy(struct mutex *lock);
@@ -49,6 +47,7 @@ static inline void mutex_destroy(struct mutex *lock) {} · 6 unmodified lines
4947
5048 #endif
5149
50+#ifndef CONFIG_PREEMPT_RT
5251 /**
5352 * mutex_init - initialize the mutex
5453 * @mutex: the mutex to be initialized
@@ -101,9 +100,6 @@ extern bool mutex_is_locked(struct mutex *lock); · 46 unmodified lines
101100
102101 extern void __mutex_rt_init(struct mutex *lock, const char *name,
103102 struct lock_class_key *key);
104−extern int mutex_trylock(struct mutex *lock);
105−
106−static inline void mutex_destroy(struct mutex *lock) { }
107103
108104 #define mutex_is_locked(l) rt_mutex_base_is_locked(&(l)->rtmutex)
109105
kernel/locking/percpu-rwsem.c+8−3
@@ -223,9 +223,10 @@ static bool readers_active_check(struct percpu_rw_semaphore *sem) · 222 unmodified lines
223223
224224 void __sched percpu_down_write(struct percpu_rw_semaphore *sem)
225225 {
226+ bool contended = false;
227+
226228 might_sleep();
227229 rwsem_acquire(&sem->dep_map, 0, 0, _RET_IP_);
228− trace_contention_begin(sem, LCB_F_PERCPU | LCB_F_WRITE);
229230
230231 /* Notify readers to take the slow path. */
231232 rcu_sync_enter(&sem->rss);
@@ -234,8 +235,11 @@ void __sched percpu_down_write(struct percpu_rw_semaphore *sem) · 2 unmodified lines
234235 * Try set sem->block; this provides writer-writer exclusion.
235236 * Having sem->block set makes new readers block.
236237 */
237− if (!__percpu_down_write_trylock(sem))
238+ if (!__percpu_down_write_trylock(sem)) {
239+ trace_contention_begin(sem, LCB_F_PERCPU | LCB_F_WRITE);
238240 percpu_rwsem_wait(sem, /* .reader = */ false);
241+ contended = true;
242+ }
239243
240244 /* smp_mb() implied by __percpu_down_write_trylock() on success -- D matches A */
241245
@@ -247,7 +251,8 @@ void __sched percpu_down_write(struct percpu_rw_semaphore *sem) · 5 unmodified lines
247251
248252 /* Wait for all active readers to complete. */
249253 rcuwait_wait_event(&sem->writer, readers_active_check(sem), TASK_UNINTERRUPTIBLE);
250− trace_contention_end(sem, 0);
254+ if (contended)
255+ trace_contention_end(sem, 0);
251256 }
252257 EXPORT_SYMBOL_GPL(percpu_down_write);
253258
kernel/locking/qspinlock_paravirt.h+1−1
@@ -294,8 +294,8 @@ static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev) · 293 unmodified lines
294294 {
295295 struct pv_node *pn = (struct pv_node *)node;
296296 struct pv_node *pp = (struct pv_node *)prev;
297+ bool __maybe_unused wait_early;
297298 int loop;
298− bool wait_early;
299299
300300 for (;;) {
301301 for (wait_early = false, loop = SPIN_THRESHOLD; loop; loop--) {
kernel/locking/rtmutex.c+5−4
@@ -237,12 +237,13 @@ static __always_inline bool rt_mutex_cmpxchg_release(struct rt_mutex_base *lock, · 236 unmodified lines
237237 */
238238 static __always_inline void mark_rt_mutex_waiters(struct rt_mutex_base *lock)
239239 {
240− unsigned long owner, *p = (unsigned long *) &lock->owner;
240+ unsigned long *p = (unsigned long *) &lock->owner;
241+ unsigned long owner, new;
241242
243+ owner = READ_ONCE(*p);
242244 do {
243− owner = *p;
244− } while (cmpxchg_relaxed(p, owner,
245− owner | RT_MUTEX_HAS_WAITERS) != owner);
245+ new = owner | RT_MUTEX_HAS_WAITERS;
246+ } while (!try_cmpxchg_relaxed(p, &owner, new));
246247
247248 /*
248249 * The cmpxchg loop above is relaxed to avoid back-to-back ACQUIRE
kernel/locking/rwsem.c+3−3
@@ -35,7 +35,7 @@ · 34 unmodified lines
3535 /*
3636 * The least significant 2 bits of the owner value has the following
3737 * meanings when set.
38− * - Bit 0: RWSEM_READER_OWNED - The rwsem is owned by readers
38+ * - Bit 0: RWSEM_READER_OWNED - rwsem may be owned by readers (just a hint)
3939 * - Bit 1: RWSEM_NONSPINNABLE - Cannot spin on a reader-owned lock
4040 *
4141 * When the rwsem is reader-owned and a spinning writer has timed out,
@@ -1002,8 +1002,8 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int stat · 960 unmodified lines
10021002
10031003 /*
10041004 * To prevent a constant stream of readers from starving a sleeping
1005− * waiter, don't attempt optimistic lock stealing if the lock is
1006− * currently owned by readers.
1005+ * writer, don't attempt optimistic lock stealing if the lock is
1006+ * very likely owned by readers.
10071007 */
10081008 if ((atomic_long_read(&sem->owner) & RWSEM_READER_OWNED) &&
10091009 (rcnt > 1) && !(count & RWSEM_WRITER_LOCKED))
lib/Kconfig.debug+2−2
@@ -1303,7 +1303,7 @@ config PROVE_LOCKING · 1302 unmodified lines
13031303 select DEBUG_SPINLOCK
13041304 select DEBUG_MUTEXES if !PREEMPT_RT
13051305 select DEBUG_RT_MUTEXES if RT_MUTEXES
1306− select DEBUG_RWSEMS
1306+ select DEBUG_RWSEMS if !PREEMPT_RT
13071307 select DEBUG_WW_MUTEX_SLOWPATH
13081308 select DEBUG_LOCK_ALLOC
13091309 select PREEMPT_COUNT if !ARCH_NO_PREEMPT
@@ -1426,7 +1426,7 @@ config DEBUG_WW_MUTEX_SLOWPATH · 116 unmodified lines
14261426
14271427 config DEBUG_RWSEMS
14281428 bool "RW Semaphore debugging: basic checks"
1429− depends on DEBUG_KERNEL
1429+ depends on DEBUG_KERNEL && !PREEMPT_RT
14301430 help
14311431 This debugging feature allows mismatched rw semaphore locks
14321432 and unlocks to be detected and reported.
scripts/atomic/kerneldoc/add_unless+1−0
@@ -10,6 +10,7 @@ cat <<EOF · 9 unmodified lines
1010 * @u: ${int} value to compare with
1111 *
1212 * If (@v != @u), atomically updates @v to (@v + @a) with ${desc_order} ordering.
13+ * Otherwise, @v is not modified and relaxed ordering is provided.
1314 *
1415 * ${desc_noinstr}
1516 *
scripts/atomic/kerneldoc/cmpxchg+1−0
@@ -6,6 +6,7 @@ cat <<EOF · 5 unmodified lines
66 * @new: ${int} value to assign
77 *
88 * If (@v == @old), atomically updates @v to @new with ${desc_order} ordering.
9+ * Otherwise, @v is not modified and relaxed ordering is provided.
910 *
1011 * ${desc_noinstr}
1112 *
scripts/atomic/kerneldoc/dec_if_positive+1−0
@@ -4,6 +4,7 @@ cat <<EOF · 3 unmodified lines
44 * @v: pointer to ${atomic}_t
55 *
66 * If (@v > 0), atomically updates @v to (@v - 1) with ${desc_order} ordering.
7+ * Otherwise, @v is not modified and relaxed ordering is provided.
78 *
89 * ${desc_noinstr}
910 *
scripts/atomic/kerneldoc/dec_unless_positive+1−0
@@ -4,6 +4,7 @@ cat <<EOF · 3 unmodified lines
44 * @v: pointer to ${atomic}_t
55 *
66 * If (@v <= 0), atomically updates @v to (@v - 1) with ${desc_order} ordering.
7+ * Otherwise, @v is not modified and relaxed ordering is provided.
78 *
89 * ${desc_noinstr}
910 *
scripts/atomic/kerneldoc/inc_not_zero+1−0
@@ -4,6 +4,7 @@ cat <<EOF · 3 unmodified lines
44 * @v: pointer to ${atomic}_t
55 *
66 * If (@v != 0), atomically updates @v to (@v + 1) with ${desc_order} ordering.
7+ * Otherwise, @v is not modified and relaxed ordering is provided.
78 *
89 * ${desc_noinstr}
910 *
scripts/atomic/kerneldoc/inc_unless_negative+1−0
@@ -4,6 +4,7 @@ cat <<EOF · 3 unmodified lines
44 * @v: pointer to ${atomic}_t
55 *
66 * If (@v >= 0), atomically updates @v to (@v + 1) with ${desc_order} ordering.
7+ * Otherwise, @v is not modified and relaxed ordering is provided.
78 *
89 * ${desc_noinstr}
910 *
scripts/atomic/kerneldoc/try_cmpxchg+2−1
@@ -6,7 +6,8 @@ cat <<EOF · 5 unmodified lines
66 * @new: ${int} value to assign
77 *
88 * If (@v == @old), atomically updates @v to @new with ${desc_order} ordering.
9− * Otherwise, updates @old to the current value of @v.
9+ * Otherwise, @v is not modified, @old is updated to the current value of @v,
10+ * and relaxed ordering is provided.
1011 *
1112 * ${desc_noinstr}
1213 *

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t