Skip to content

Commit 8c069ff

Browse files
hbruecknerMartin Schwidefsky
authored andcommitted
s390/perf: add support for the CPU-Measurement Sampling Facility
Introduce a perf PMU, "cpum_sf", to support the CPU-Measurement Sampling Facility. You can control the sampling facility through this perf PMU interfaces. Perf sampling events are created for hardware samples. For details about the CPU-Measurement Sampling Facility, see "The Load-Program-Parameter and the CPU-Measurement Facilities" (SA23-2260). Signed-off-by: Hendrik Brueckner <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent c716832 commit 8c069ff

File tree

5 files changed

+1086
-13
lines changed

5 files changed

+1086
-13
lines changed

arch/s390/include/asm/cpu_mf.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,20 @@ static inline int lsctl(struct hws_lsctl_request_block *req)
210210

211211
/* Sampling control helper functions */
212212

213+
#include <linux/time.h>
214+
215+
static inline unsigned long freq_to_sample_rate(struct hws_qsi_info_block *qsi,
216+
unsigned long freq)
217+
{
218+
return (USEC_PER_SEC / freq) * qsi->cpu_speed;
219+
}
220+
221+
static inline unsigned long sample_rate_to_freq(struct hws_qsi_info_block *qsi,
222+
unsigned long rate)
223+
{
224+
return USEC_PER_SEC * qsi->cpu_speed / rate;
225+
}
226+
213227
#define SDB_TE_ALERT_REQ_MASK 0x4000000000000000UL
214228
#define SDB_TE_BUFFER_FULL_MASK 0x8000000000000000UL
215229

arch/s390/include/asm/perf_event.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
#include <linux/device.h>
1616
#include <asm/cpu_mf.h>
1717

18-
/* CPU-measurement counter facility */
19-
#define PERF_CPUM_CF_MAX_CTR 256
20-
2118
/* Per-CPU flags for PMU states */
2219
#define PMU_F_RESERVED 0x1000
2320
#define PMU_F_ENABLED 0x2000
21+
#define PMU_F_IN_USE 0x4000
22+
#define PMU_F_ERR_IBE 0x0100
23+
#define PMU_F_ERR_LSDA 0x0200
24+
#define PMU_F_ERR_MASK (PMU_F_ERR_IBE|PMU_F_ERR_LSDA)
2425

2526
/* Perf defintions for PMU event attributes in sysfs */
2627
extern __init const struct attribute_group **cpumf_cf_event_group(void);
@@ -41,5 +42,15 @@ extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
4142
extern unsigned long perf_misc_flags(struct pt_regs *regs);
4243
#define perf_misc_flags(regs) perf_misc_flags(regs)
4344

45+
/* Perf PMU definitions for the counter facility */
46+
#define PERF_CPUM_CF_MAX_CTR 256
47+
48+
/* Perf PMU definitions for the sampling facility */
49+
#define PERF_CPUM_SF_MAX_CTR 1
50+
#define PERF_EVENT_CPUM_SF 0xB0000UL /* Raw event ID */
51+
52+
#define TEAR_REG(hwc) ((hwc)->last_tag)
53+
#define SAMPL_RATE(hwc) ((hwc)->event_base)
54+
4455
#endif /* CONFIG_64BIT */
4556
#endif /* _ASM_S390_PERF_EVENT_H */

arch/s390/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
6060
obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
6161

6262
ifdef CONFIG_64BIT
63-
obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf.o \
63+
obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf.o perf_cpum_sf.o \
6464
perf_cpum_cf_events.o
6565
obj-y += runtime_instr.o cache.o
6666
endif

0 commit comments

Comments
 (0)