Initial support for Niagara T1 performance counters
PATCH 1/1 Initial support for Niagara T1 performance counters
The patch handles performance counter overflow traps, which are currently being ignored.
A trap with type 0x4f is generated by either a level-15 interrupt, or, if the processor interrupt level is smaller than 15, by the overflow of a performance counter (either the low or high parts). Currently, the kernel ignores the former, and handles only the latter. The patch checks the previous value of PIL and, if smaller than 15, increments a 64-bit per-cpu counter. The counter is used to count both types of overflows, being divided into two 32 bit values. The counter is exported, so that kernel modules can use it to keep track of 64-bit performance counter values.
A sample module, which uses the overflow counters, can be found on:
http://www.cs.uwaterloo.ca/~elahav/pcount.c
The module uses a procfs entry (/proc/pcount) that enables users to both programme the counters (start, stop, reset, configure event), as well as get a snapshot of the current value of all counters.
Notes:
1. I have tried to be as unintrusive as possible. The code is only enabled if a config option is turned on, and the option is marked as EXPERIMENTAL.
2. The way in which the previous PIL value is extracted from the stored TSTATE register is based on my interpretation of the code in etrap.S. I hope it is correct (seems to be working, though).
3. I'm not sure about the need to manually reset the PCR overflow flags
- see comment in the code (again, seems to be working).
---
arch/sparc64/Kconfig +9 -0
@@ -397,6 +397,15 @@ NOTE: This option WILL override the PROM bootargs setting! +config T1_PERF_COUNTERS + bool "Support for performance counters on the Niagara T1 (EXPERIMENTAL)" + depends on EXPERIMENTAL && SPARC64 + default n + help + Each virtual processor on the T1 has its own performance counter + unit, composed of two 32 bit counters. + Say Y to enable support for programming and reading these counters. + source "net/Kconfig" source "drivers/Kconfig"
arch/sparc64/kernel/irq.c +70 -0
88 lines not on this page · raw message
include/asm-sparc64/irq.h +4 -0
@@ -94,4 +94,8 @@extern void *softirq_stack[NR_CPUS ];#define __ARCH_HAS_DO_SOFTIRQ +#ifdef CONFIG_T1_PERF_COUNTERS +DECLARE_PER_CPU (u64, pic_overflows); +#endif /* CONFIG_T1_PERF_COUNTERS */ +#endif
From: Elad Lahav <[email protected]>
Date: Thu, 11 Sep 2008 17:05:36 -0400
Quoted 2 lines
The patch handles performance counter overflow traps, which are currently being ignored.
Full support for both T1 and T2 performance counters (as well as those of all other sparc64 processors) is contained in the perfmon2 tree.
Those patches handle the overflow conditions and everything else.
There is no reason to put short term hacks like this on into the tree, meanwhile.
Quoted 2 lines · David Miller
Full support for both T1 and T2 performance counters (as well as those of all other sparc64 processors) is contained in the perfmon2 tree.
Fair enough, I wasn't aware that perfmon supported the T1.
Just for the record, is the implementation correct? Specifically, is this the right way to extract the PIL at the time of the trap?
Thanks,
Elad
From: Elad Lahav <[email protected]>
Date: Thu, 11 Sep 2008 19:34:46 -0400
Quoted 2 lines
Just for the record, is the implementation correct? Specifically, is this the right way to extract the PIL at the time of the trap?
Yep it looks right.
Also, for the record, you should post sparc patches at least CC:'d to [email protected] in the future.