mirror of
https://github.com/torvalds/linux.git
synced 2026-11-26 16:33:17 +00:00
Adding perf_msr_probe function to provide interface for
checking up on MSR register and set the related attribute
group visibility.
User defines following struct for each MSR register:
struct perf_msr {
u64 msr;
struct attribute_group *grp;
bool (*test)(int idx, void *data);
bool no_check;
};
Where:
msr - is the MSR address
attrs - is attribute groups array to add if the check passed
test - is test function pointer
no_check - is bool that bypass the check and adds the
attribute without any test
The array of struct perf_msr is passed into:
perf_msr_probe(struct perf_msr *msr, int cnt, bool zero, void *data)
Together with:
cnt - which is the number of struct msr array elements
data - which is user pointer passed to the test function
zero - allow counters that returns zero on rdmsr
The perf_msr_probe will executed test code, read the MSR and
check the value is != 0. If all these tests pass, related
attribute group is kept visible.
Also adding PMU_EVENT_GROUP macro helper to define attribute
group for single attribute. It will be used in following patches.
Signed-off-by: Jiri Olsa <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kan <[email protected]>
Cc: Liang
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vince Weaver <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
30 lines
702 B
C
30 lines
702 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __ARCH_X86_EVENTS_PROBE_H__
|
|
#define __ARCH_X86_EVENTS_PROBE_H__
|
|
#include <linux/sysfs.h>
|
|
|
|
struct perf_msr {
|
|
u64 msr;
|
|
struct attribute_group *grp;
|
|
bool (*test)(int idx, void *data);
|
|
bool no_check;
|
|
};
|
|
|
|
unsigned long
|
|
perf_msr_probe(struct perf_msr *msr, int cnt, bool no_zero, void *data);
|
|
|
|
#define __PMU_EVENT_GROUP(_name) \
|
|
static struct attribute *attrs_##_name[] = { \
|
|
&attr_##_name.attr.attr, \
|
|
NULL, \
|
|
}
|
|
|
|
#define PMU_EVENT_GROUP(_grp, _name) \
|
|
__PMU_EVENT_GROUP(_name); \
|
|
static struct attribute_group group_##_name = { \
|
|
.name = #_grp, \
|
|
.attrs = attrs_##_name, \
|
|
}
|
|
|
|
#endif /* __ARCH_X86_EVENTS_PROBE_H__ */
|