Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

locking/qspinlock: Always evaluate lockevent* non-event parameter once

The 'inc' parameter of lockevent_add() and the cond parameter of
lockevent_cond_inc() are only evaluated when CONFIG_LOCK_EVENT_COUNTS
is on. That can cause problem if those parameters are expressions
with side effect like a "++". Fix this by evaluating those non-event
parameters once even if CONFIG_LOCK_EVENT_COUNTS is off. This will also
eliminate the need of the __maybe_unused attribute to the wait_early
local variable in pv_wait_node().

Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20240319005004.1692705-1-longman@redhat.com

authored by

Waiman Long and committed by
Ingo Molnar
3774b28d 4ae3dc83

+3 -3
+2 -2
kernel/locking/lock_events.h
··· 53 53 #else /* CONFIG_LOCK_EVENT_COUNTS */ 54 54 55 55 #define lockevent_inc(ev) 56 - #define lockevent_add(ev, c) 57 - #define lockevent_cond_inc(ev, c) 56 + #define lockevent_add(ev, c) do { (void)(c); } while (0) 57 + #define lockevent_cond_inc(ev, c) do { (void)(c); } while (0) 58 58 59 59 #endif /* CONFIG_LOCK_EVENT_COUNTS */ 60 60
+1 -1
kernel/locking/qspinlock_paravirt.h
··· 294 294 { 295 295 struct pv_node *pn = (struct pv_node *)node; 296 296 struct pv_node *pp = (struct pv_node *)prev; 297 - bool __maybe_unused wait_early; 297 + bool wait_early; 298 298 int loop; 299 299 300 300 for (;;) {