From 490fb153006941ec7b576c9e89cb220a0739a95c Mon Sep 17 00:00:00 2001 From: Waiman Long Date: Thu, 23 Feb 2023 17:32:06 -0500 Subject: [PATCH] locking/lock_events: Add a new lockevent_cond_inc2() helper Add a new lockevent_cond_inc2(cond, true_event, false_event) helper to conditionally increment one of the 2 given events. Signed-off-by: Waiman Long --- kernel/locking/lock_events.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/locking/lock_events.h b/kernel/locking/lock_events.h index 8c7e7d25f09c..668c2f1397f6 100644 --- a/kernel/locking/lock_events.h +++ b/kernel/locking/lock_events.h @@ -43,6 +43,21 @@ static inline void __lockevent_inc(enum lock_events event, bool cond) #define lockevent_inc(ev) __lockevent_inc(LOCKEVENT_ ##ev, true) #define lockevent_cond_inc(ev, c) __lockevent_inc(LOCKEVENT_ ##ev, c) +/* + * Increment either the tevent (cond true) or fevent (cond false) + */ +static inline void __lockevent_cond_inc2(bool cond, enum lock_events tevent, + enum lock_events fevent) +{ + if (cond) + raw_cpu_inc(lockevents[tevent]); + else + raw_cpu_inc(lockevents[fevent]); + +} +#define lockevent_cond_inc2(c, tev, fev) \ + __lockevent_cond_inc2(c, LOCKEVENT_ ##tev, LOCKEVENT_ ##fev) + static inline void __lockevent_add(enum lock_events event, int inc) { raw_cpu_add(lockevents[event], inc); @@ -55,6 +70,7 @@ static inline void __lockevent_add(enum lock_events event, int inc) #define lockevent_inc(ev) #define lockevent_add(ev, c) #define lockevent_cond_inc(ev, c) +#define lockevent_cond_inc2(c, tev, fev) #endif /* CONFIG_LOCK_EVENT_COUNTS */ #endif /* __LOCKING_LOCK_EVENTS_H */ -- 2.31.1