Commit a4ae67e8 authored by Kan Liang's avatar Kan Liang Committed by Yunying Sun
Browse files

perf: Add PMU_FORMAT_ATTR_SHOW

mainline inclusion
from mainline-v6.3-rc1
commit b6c00fb9
category: feature
feature: SRF core PMU support
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I8RWG5
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b6c00fb9949fbd073e651a77aa75faca978cf2a6



Intel-SIG: commit b6c00fb9 perf: Add PMU_FORMAT_ATTR_SHOW
Backport as a dependency for Sierra Forrest core PMU support.

-------------------------------------

The macro PMU_FORMAT_ATTR facilitates the definition of both the "show"
function and "format_attr". But it only works for a non-hybrid platform.
For a hybrid platform, the name "format_attr_hybrid_" is used.

The definition of the "show" function can be shared between a non-hybrid
platform and a hybrid platform. Add a new macro PMU_FORMAT_ATTR_SHOW.

No functional change. The PMU_FORMAT_ATTR_SHOW will be used in the
following patch.

Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230104201349.1451191-1-kan.liang@linux.intel.com


Signed-off-by: default avatarYunying Sun <yunying.sun@intel.com>
parent 8de16cca
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1617,7 +1617,7 @@ static struct perf_pmu_events_attr _var = { \
	.event_str	= _str,						    \
};

#define PMU_FORMAT_ATTR(_name, _format)					\
#define PMU_FORMAT_ATTR_SHOW(_name, _format)					\
static ssize_t								\
_name##_show(struct device *dev,					\
			       struct device_attribute *attr,		\
@@ -1626,6 +1626,9 @@ _name##_show(struct device *dev, \
	BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE);			\
	return sprintf(page, _format "\n");				\
}									\

#define PMU_FORMAT_ATTR(_name, _format)					\
	PMU_FORMAT_ATTR_SHOW(_name, _format)				\
									\
static struct device_attribute format_attr_##_name = __ATTR_RO(_name)