Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * This program is free software; you can redistribute it and/or modify
0004  * it under the terms of the GNU General Public License as published by
0005  * the Free Software Foundation; either version 2 of the License, or
0006  * (at your option) any later version.
0007  *
0008  * This program is distributed in the hope that it will be useful,
0009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0011  * GNU General Public License for more details.
0012  *
0013  * Authors: Waiman Long <longman@redhat.com>
0014  */
0015 
0016 #ifndef __LOCKING_LOCK_EVENTS_H
0017 #define __LOCKING_LOCK_EVENTS_H
0018 
0019 enum lock_events {
0020 
0021 #include "lock_events_list.h"
0022 
0023     lockevent_num,  /* Total number of lock event counts */
0024     LOCKEVENT_reset_cnts = lockevent_num,
0025 };
0026 
0027 #ifdef CONFIG_LOCK_EVENT_COUNTS
0028 /*
0029  * Per-cpu counters
0030  */
0031 DECLARE_PER_CPU(unsigned long, lockevents[lockevent_num]);
0032 
0033 /*
0034  * Increment the statistical counters. use raw_cpu_inc() because of lower
0035  * overhead and we don't care if we loose the occasional update.
0036  */
0037 static inline void __lockevent_inc(enum lock_events event, bool cond)
0038 {
0039     if (cond)
0040         raw_cpu_inc(lockevents[event]);
0041 }
0042 
0043 #define lockevent_inc(ev)     __lockevent_inc(LOCKEVENT_ ##ev, true)
0044 #define lockevent_cond_inc(ev, c) __lockevent_inc(LOCKEVENT_ ##ev, c)
0045 
0046 static inline void __lockevent_add(enum lock_events event, int inc)
0047 {
0048     raw_cpu_add(lockevents[event], inc);
0049 }
0050 
0051 #define lockevent_add(ev, c)    __lockevent_add(LOCKEVENT_ ##ev, c)
0052 
0053 #else  /* CONFIG_LOCK_EVENT_COUNTS */
0054 
0055 #define lockevent_inc(ev)
0056 #define lockevent_add(ev, c)
0057 #define lockevent_cond_inc(ev, c)
0058 
0059 #endif /* CONFIG_LOCK_EVENT_COUNTS */
0060 #endif /* __LOCKING_LOCK_EVENTS_H */