forked from shenki/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
locking/qspinlock_stat: Introduce generic lockevent_*() counting APIs
The percpu event counts used by qspinlock code can be useful for other locking code as well. So a new set of lockevent_* counting APIs is introduced with the lock event names extracted out into the new lock_events_list.h header file for easier addition in the future. The existing qstat_inc() calls are replaced by either lockevent_inc() or lockevent_cond_inc() calls. The qstat_hop() call is renamed to lockevent_pv_hop(). The "reset_counters" debugfs file is also renamed to ".reset_counts". Signed-off-by: Waiman Long <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Acked-by: Davidlohr Bueso <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Tim Chen <[email protected]> Cc: Will Deacon <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
- Loading branch information
1 parent
3b4ba66
commit ad53fa1
Showing
5 changed files
with
181 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* Authors: Waiman Long <[email protected]> | ||
*/ | ||
|
||
enum lock_events { | ||
|
||
#include "lock_events_list.h" | ||
|
||
lockevent_num, /* Total number of lock event counts */ | ||
LOCKEVENT_reset_cnts = lockevent_num, | ||
}; | ||
|
||
#ifdef CONFIG_QUEUED_LOCK_STAT | ||
/* | ||
* Per-cpu counters | ||
*/ | ||
DECLARE_PER_CPU(unsigned long, lockevents[lockevent_num]); | ||
|
||
/* | ||
* Increment the PV qspinlock statistical counters | ||
*/ | ||
static inline void __lockevent_inc(enum lock_events event, bool cond) | ||
{ | ||
if (cond) | ||
__this_cpu_inc(lockevents[event]); | ||
} | ||
|
||
#define lockevent_inc(ev) __lockevent_inc(LOCKEVENT_ ##ev, true) | ||
#define lockevent_cond_inc(ev, c) __lockevent_inc(LOCKEVENT_ ##ev, c) | ||
|
||
static inline void __lockevent_add(enum lock_events event, int inc) | ||
{ | ||
__this_cpu_add(lockevents[event], inc); | ||
} | ||
|
||
#define lockevent_add(ev, c) __lockevent_add(LOCKEVENT_ ##ev, c) | ||
|
||
#else /* CONFIG_QUEUED_LOCK_STAT */ | ||
|
||
#define lockevent_inc(ev) | ||
#define lockevent_add(ev, c) | ||
#define lockevent_cond_inc(ev, c) | ||
|
||
#endif /* CONFIG_QUEUED_LOCK_STAT */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* Authors: Waiman Long <[email protected]> | ||
*/ | ||
|
||
#ifndef LOCK_EVENT | ||
#define LOCK_EVENT(name) LOCKEVENT_ ## name, | ||
#endif | ||
|
||
#ifdef CONFIG_QUEUED_SPINLOCKS | ||
#ifdef CONFIG_PARAVIRT_SPINLOCKS | ||
/* | ||
* Locking events for PV qspinlock. | ||
*/ | ||
LOCK_EVENT(pv_hash_hops) /* Average # of hops per hashing operation */ | ||
LOCK_EVENT(pv_kick_unlock) /* # of vCPU kicks issued at unlock time */ | ||
LOCK_EVENT(pv_kick_wake) /* # of vCPU kicks for pv_latency_wake */ | ||
LOCK_EVENT(pv_latency_kick) /* Average latency (ns) of vCPU kick */ | ||
LOCK_EVENT(pv_latency_wake) /* Average latency (ns) of kick-to-wakeup */ | ||
LOCK_EVENT(pv_lock_stealing) /* # of lock stealing operations */ | ||
LOCK_EVENT(pv_spurious_wakeup) /* # of spurious wakeups in non-head vCPUs */ | ||
LOCK_EVENT(pv_wait_again) /* # of wait's after queue head vCPU kick */ | ||
LOCK_EVENT(pv_wait_early) /* # of early vCPU wait's */ | ||
LOCK_EVENT(pv_wait_head) /* # of vCPU wait's at the queue head */ | ||
LOCK_EVENT(pv_wait_node) /* # of vCPU wait's at non-head queue node */ | ||
#endif /* CONFIG_PARAVIRT_SPINLOCKS */ | ||
|
||
/* | ||
* Locking events for qspinlock | ||
* | ||
* Subtracting lock_use_node[234] from lock_slowpath will give you | ||
* lock_use_node1. | ||
*/ | ||
LOCK_EVENT(lock_pending) /* # of locking ops via pending code */ | ||
LOCK_EVENT(lock_slowpath) /* # of locking ops via MCS lock queue */ | ||
LOCK_EVENT(lock_use_node2) /* # of locking ops that use 2nd percpu node */ | ||
LOCK_EVENT(lock_use_node3) /* # of locking ops that use 3rd percpu node */ | ||
LOCK_EVENT(lock_use_node4) /* # of locking ops that use 4th percpu node */ | ||
LOCK_EVENT(lock_no_node) /* # of locking ops w/o using percpu node */ | ||
#endif /* CONFIG_QUEUED_SPINLOCKS */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.