/* SPDX-License-Identifier: GPL-2.0 */1/*2* This program is free software; you can redistribute it and/or modify3* it under the terms of the GNU General Public License as published by4* the Free Software Foundation; either version 2 of the License, or5* (at your option) any later version.6*7* This program is distributed in the hope that it will be useful,8* but WITHOUT ANY WARRANTY; without even the implied warranty of9* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10* GNU General Public License for more details.11*12* Authors: Waiman Long <[email protected]>13*/1415#ifndef __LOCKING_LOCK_EVENTS_H16#define __LOCKING_LOCK_EVENTS_H1718enum lock_events {1920#include "lock_events_list.h"2122lockevent_num, /* Total number of lock event counts */23LOCKEVENT_reset_cnts = lockevent_num,24};2526#ifdef CONFIG_LOCK_EVENT_COUNTS27/*28* Per-cpu counters29*/30DECLARE_PER_CPU(unsigned long, lockevents[lockevent_num]);3132/*33* Increment the statistical counters. use raw_cpu_inc() because of lower34* overhead and we don't care if we loose the occasional update.35*/36static inline void __lockevent_inc(enum lock_events event, bool cond)37{38if (cond)39raw_cpu_inc(lockevents[event]);40}4142#define lockevent_inc(ev) __lockevent_inc(LOCKEVENT_ ##ev, true)43#define lockevent_cond_inc(ev, c) __lockevent_inc(LOCKEVENT_ ##ev, c)4445static inline void __lockevent_add(enum lock_events event, int inc)46{47raw_cpu_add(lockevents[event], inc);48}4950#define lockevent_add(ev, c) __lockevent_add(LOCKEVENT_ ##ev, c)5152#else /* CONFIG_LOCK_EVENT_COUNTS */5354#define lockevent_inc(ev)55#define lockevent_add(ev, c) do { (void)(c); } while (0)56#define lockevent_cond_inc(ev, c) do { (void)(c); } while (0)5758#endif /* CONFIG_LOCK_EVENT_COUNTS */5960ssize_t lockevent_read(struct file *file, char __user *user_buf,61size_t count, loff_t *ppos);6263#endif /* __LOCKING_LOCK_EVENTS_H */646566