perf: Clean up common uncore boilerplate
Subsystems (26)
Robin Murphy
maintainercover perf: Clean up common uncore boilerplate
Hi all,
Since this came up yet again recently, and it's an idea which has been nagging me for years, I decided it was time to see how hard it really would be to start shaving this yak. And it turns out to be refreshingly simple - the core code has quietly become capable of doing most of what we want, the one new functional addition is trivial (patch #2), and the resulting largely-mechanical cleanup seems a pretty nice win.
This series is focused on drivers/perf/ as that's where most mess is concentrated, but figured I'd include the arch/ patches as well since they might be reasonable to land with the core changes, at least for x86 (FWIW I did also look at the powerpc drivers but they scared me and I ran away; sorry). The remaining stragglers elsewhere around the tree I'd come back to as a follow-up.
(And yes, I appreciate it's mid-merge-window already, but since I do have a tree-wide rename proposed here, may as well give the discussion a chance for a head start before -rc1...)
Thanks,
Robin.
Robin Murphy (10):
perf/alibaba_uncore_drw: Use correct CPU affinity
perf: Add capability for common event support drivers/perf: Use PERF_PMU_CAP_NO_COMMON_EVENTS
perf: Rename PERF_PMU_CAP_NO_INTERRUPT drivers/perf: Use PERF_PMU_CAP_NO_SAMPLING consistently drivers/perf: Clean up redundant per-task checks
perf: Define common uncore capabilities drivers/perf: Use common uncore capabilities
x86: Use common uncore PMU capabilities
ARM: Use common uncore PMU capabilities
arch/arc/kernel/perf_event.c | 2 +- arch/arm/mach-imx/mmdc.c | 16 +------------- arch/arm/mm/cache-l2x0-pmu.c | 12 +--------- arch/csky/kernel/perf_event.c | 2 +- arch/powerpc/perf/8xx-pmu.c | 2 +- arch/powerpc/perf/hv-24x7.c | 2 +- arch/powerpc/perf/hv-gpci.c | 2 +- arch/powerpc/platforms/pseries/papr_scm.c | 2 +- arch/s390/kernel/perf_cpum_cf.c | 2 +- arch/sh/kernel/perf_event.c | 2 +- arch/x86/events/amd/iommu.c | 17 +------------- arch/x86/events/amd/power.c | 10 +-------- arch/x86/events/amd/uncore.c | 12 +++------- arch/x86/events/core.c | 2 +- arch/x86/events/intel/cstate.c | 16 +++----------- arch/x86/events/intel/uncore.c | 11 +-------- arch/x86/events/intel/uncore_snb.c | 20 +++-------------- arch/x86/events/msr.c | 9 +------- arch/x86/events/rapl.c | 9 +------- drivers/fpga/dfl-fme-perf.c | 2 +- drivers/perf/alibaba_uncore_drw_pmu.c | 27 +++-------------------- drivers/perf/amlogic/meson_ddr_pmu_core.c | 11 +-------- drivers/perf/arm-cci.c | 15 +------------ drivers/perf/arm-ccn.c | 20 +---------------- drivers/perf/arm-cmn.c | 10 +-------- drivers/perf/arm_cspmu/arm_cspmu.c | 27 ++--------------------- drivers/perf/arm_dmc620_pmu.c | 18 +-------------- drivers/perf/arm_dsu_pmu.c | 22 +----------------- drivers/perf/arm_pmu_platform.c | 2 +- drivers/perf/arm_smmuv3_pmu.c | 15 +------------ drivers/perf/arm_spe_pmu.c | 7 ++---- drivers/perf/cxl_pmu.c | 8 +------ drivers/perf/dwc_pcie_pmu.c | 13 +---------- drivers/perf/fsl_imx8_ddr_perf.c | 13 +---------- drivers/perf/fsl_imx9_ddr_perf.c | 13 +---------- drivers/perf/hisilicon/hisi_pcie_pmu.c | 10 +-------- drivers/perf/hisilicon/hisi_uncore_pmu.c | 20 +---------------- drivers/perf/hisilicon/hns3_pmu.c | 9 +------- drivers/perf/marvell_cn10k_ddr_pmu.c | 15 +------------ drivers/perf/marvell_cn10k_tad_pmu.c | 6 +---- drivers/perf/qcom_l2_pmu.c | 21 ++---------------- drivers/perf/qcom_l3_pmu.c | 21 +----------------- drivers/perf/riscv_pmu_sbi.c | 2 +- drivers/perf/thunderx2_pmu.c | 17 +------------- drivers/perf/xgene_pmu.c | 16 +------------- include/linux/perf_event.h | 6 ++++- kernel/events/core.c | 7 +++++- 47 files changed, 67 insertions(+), 456 deletions(-)
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
Robin Murphy
maintainerPATCH 1/10 perf/alibaba_uncore_drw: Use correct CPU affinity
Although this driver is trying to use the IRQ-multiplexing mechanism to handle context migration correctly, it's failing to make events follow the IRQ instance, instead forcing them onto a per-PMU CPU which is set once at probe time then never maintained. Fix this by using the correct CPU from the IRQ instance, and remove the erroneous per-PMU data plus the redundant check which does not mean what it thinks it means.
--- drivers/perf/alibaba_uncore_drw_pmu.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/perf/alibaba_uncore_drw_pmu.c +2 -10
@@ -96,8 +96,6 @@ struct ali_drw_pmu {struct list_head pmus_node;struct ali_drw_pmu_irq *irq; -int irq_num; -int cpu;DECLARE_BITMAP (used_mask,ALI_DRW_PMU_COMMON_MAX_COUNTERS );struct perf_event *events[ALI_DRW_PMU_COMMON_MAX_COUNTERS ];int evtids[ALI_DRW_PMU_COMMON_MAX_COUNTERS ];
@@ -221,7 +219,7 @@ static ssize_t ali_drw_pmu_cpumask_show(struct device *dev, {struct ali_drw_pmu *drw_pmu =to_ali_drw_pmu (dev_get_drvdata (dev)); -return cpumap_print_to_pagebuf (true, buf,cpumask_of (drw_pmu->cpu)); +return cpumap_print_to_pagebuf (true, buf,cpumask_of (drw_pmu->irq->cpu)); } static struct device_attribute ali_drw_pmu_cpumask_attr =
@@ -550,11 +548,7 @@ static int ali_drw_pmu_event_init(struct perf_event *event)return -EOPNOTSUPP ; } - event->cpu = drw_pmu->cpu; -if (event->cpu <0 ) { -dev_err (dev,"Per-task mode not supported!\n" ); -return -EOPNOTSUPP ; - } + event->cpu = drw_pmu->irq->cpu;if (event->group_leader != event && !is_software_event (event->group_leader)) {
@@ -701,8 +695,6 @@ static int ali_drw_pmu_probe(struct platform_device *pdev)/* clearing interrupt status */ writel (0xffffff , drw_pmu->cfg_base +ALI_DRW_PMU_OV_INTR_CLR ); - drw_pmu->cpu =smp_processor_id (); - ret =ali_drw_pmu_init_irq (drw_pmu, pdev);if (ret)return ret;
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
Robin Murphy
maintainerPATCH 2/10 perf: Add capability for common event support
In reply to Robin MurphyMany PMUs do not support common hardware/cache/etc. events and only handle their own PMU-specific events. Since this only depends on matching the event and PMU types, it's a prime candidate for a core capability to save more event_init boilerplate in drivers.
--- include/linux/perf_event.h | 1 + kernel/events/core.c | 5 +++++ 2 files changed, 6 insertions(+)
include/linux/perf_event.h +1 -0
@@ -291,6 +291,7 @@ struct perf_event_pmu_context;#define PERF_PMU_CAP_NO_EXCLUDE 0x0040#define PERF_PMU_CAP_AUX_OUTPUT 0x0080#define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100 +#define PERF_PMU_CAP_NO_COMMON_EVENTS 0x0200struct perf_output_handle ;
kernel/events/core.c +5 -0
@@ -11649,6 +11649,11 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event)struct perf_event_context *ctx =NULL ;int ret; +/* Short-circuit if we know the PMU won't want this event */ +if (pmu->capabilities &PERF_PMU_CAP_NO_COMMON_EVENTS && + event->attr.type != pmu->type) +return -ENOENT ; +if (!try_module_get (pmu->module))return -ENODEV ;
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
Re: [PATCH 02/10] perf: Add capability for common event support
Quoted 28 lines · Robin Murphy
Many PMUs do not support common hardware/cache/etc. events and only handle their own PMU-specific events. Since this only depends on matching the event and PMU types, it's a prime candidate for a core capability to save more
event_initboilerplate in drivers.Signed-off-by Robin Murphy <[email protected]>--- include/linux/perf_event.h | 1 + kernel/events/core.c | 5 +++++ 2 files changed, 6 insertions(+)include/linux/perf_event.h +1
-0@@ -291,6 +291,7 @@ struct perf_event_pmu_context;#define PERF_PMU_CAP_NO_EXCLUDE 0x0040#define PERF_PMU_CAP_AUX_OUTPUT 0x0080#define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100 +#define PERF_PMU_CAP_NO_COMMON_EVENTS 0x0200struct perf_output_handle ;kernel/events/core.c +0
-0
kernel/events/core.c static int perf_try_init_event(struct pmu *pmu, struct perf_event *event) · line 11656
Quoted 8 lines
kernel/events/core.c +5
-0@@ -11649,6 +11649,11 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event)struct perf_event_context *ctx =NULL ;int ret; +/* Short-circuit if we know the PMU won't want this event */ +if (pmu->capabilities &PERF_PMU_CAP_NO_COMMON_EVENTS && + event->attr.type != pmu->type) +return -ENOENT ; +
/*
* PERF_TYPE_HARDWARE and PERF_TYPE_HW_CACHE
* are often aliases for PERF_TYPE_RAW.
*/
type = event->attr.type;
if (type == PERF_TYPE_HARDWARE || type == PERF_TYPE_HW_CACHE) {
type = event->attr.config >> PERF_PMU_TYPE_SHIFT;
if (!type) {
type = PERF_TYPE_RAW;
} else {
extended_type = true;
event->attr.config &= PERF_HW_EVENT_MASK;
}
}again:
rcu_read_lock();
pmu = idr_find(&pmu_idr, type);
rcu_read_unlock();
if (pmu) {Above code tells me it's possible that 'pmu->type != event->attr.type' is true when event->attr.type equals to PERF_TYPE_HARDWARE or PERF_TYPE_HW_CACHE, and pmu->type should equal to event->attr.config >> PERF_PMU_TYPE_SHIFT.
We find the target pmu by event->attr.config >> PERF_PMU_TYPE_SHIFT.
Code added discard this option.
And code tells me that no try. Target PMU is doubtless.
kernel/events/core.c static int perf_try_init_event(struct pmu *pmu, struct perf_event *event) · line 11659
Quoted 3 lines
kernel/events/core.c +0
-0if (!try_module_get (pmu->module))return -ENODEV ;
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Robin Murphy
maintainerRe: [PATCH 02/10] perf: Add capability for common event support
Quoted 53 lines · Yang Jialong 杨佳龙
Quoted 26 lines · Robin Murphy
Many PMUs do not support common hardware/cache/etc. events and only handle their own PMU-specific events. Since this only depends on matching the event and PMU types, it's a prime candidate for a core capability to save more
event_initboilerplate in drivers.Signed-off-by Robin Murphy <[email protected]>---
include/linux/perf_event.h| 1 +
kernel/events/core.c | 5 +++++2 files changed, 6 insertions(+)include/linux/perf_event.h +1
-0@@ -291,6 +291,7 @@ struct perf_event_pmu_context; #define PERF_PMU_CAP_NO_EXCLUDE 0x0040 #define PERF_PMU_CAP_AUX_OUTPUT 0x0080 #define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100 +#define PERF_PMU_CAP_NO_COMMON_EVENTS 0x0200 struct perf_output_handle;kernel/events/core.c +0
-0kernel/events/core.c static int perf_try_init_event(struct pmu · line 11656
Quoted 8 lines
kernel/events/core.c +5
-0@@ -11649,6 +11649,11 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event) struct perf_event_context *ctx = NULL; int ret; + /* Short-circuit if we know the PMU won't want this event */ + if (pmu->capabilities & PERF_PMU_CAP_NO_COMMON_EVENTS && + event->attr.type != pmu->type) + return -ENOENT; +/*
*PERF_TYPE_HARDWAREandPERF_TYPE_HW_CACHE
* are often aliases forPERF_TYPE_RAW.
*/
type =event->attr.type;
if (type ==PERF_TYPE_HARDWARE|| type ==PERF_TYPE_HW_CACHE) { type =event->attr.config>>PERF_PMU_TYPE_SHIFT; if (!type) {
type =PERF_TYPE_RAW;
} else {
extended_type= true;event->attr.config&=PERF_HW_EVENT_MASK; }
}
Quoted 8 lines
again:
rcu_read_lock();
pmu =idr_find(&pmu_idr, type);
rcu_read_unlock();
if (pmu) {
Above code tells me it's possible that 'pmu->type!=event->attr.type' is true whenevent->attr.typeequals toPERF_TYPE_HARDWAREorPERF_TYPE_HW_CACHE, andpmu->typeshould equal toevent->attr.config>>PERF_PMU_TYPE_SHIFT.We find the target pmu by
event->attr.config>>PERF_PMU_TYPE_SHIFT.
And if that PMU doesn't actually support PERF_TYPE_HARDWARE or PERF_TYPE_HW_CACHE then it would reject the event, if the very next lines didn't already do that:
if (event->attr.type != type && type != PERF_TYPE_RAW && !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE)) goto fail;
Either way it should be clear that there's no change of functionality here since the flow into perf_try_init_event() itself is untouched.
Quoted 1 line
Code added discard this option.
It would already be nonsensical for a driver to advertise PERF_PMU_CAP_EXTENDED_HW_TYPE to say it supports extended hardware events, but then reject all hardware events with a "event->attr.type != pmu->type" check in its event_init. Reworking the latter condition into PERF_PMU_CAP_NO_COMMON_EVENTS doesn't change that.
Thanks,
Robin.
Quoted 9 lines
And code tells me that no try. Target PMU is doubtless.
Quoted 2 lines
kernel/events/core.c +0
-0if (!try_module_get(pmu->module)) return -ENODEV;
Robin Murphy
maintainerPATCH 3/10 drivers/perf: Use PERF_PMU_CAP_NO_COMMON_EVENTS
In reply to Robin MurphyNow that we have a core capability for refusing common event types, make use of it to purge the -ENOENT boilerplate from our system PMU drivers.
--- drivers/perf/alibaba_uncore_drw_pmu.c | 6 ++---- drivers/perf/amlogic/meson_ddr_pmu_core.c | 6 ++---- drivers/perf/arm-cci.c | 10 ++-------- drivers/perf/arm-ccn.c | 6 ++---- drivers/perf/arm-cmn.c | 6 ++---- drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++---- drivers/perf/arm_dmc620_pmu.c | 6 ++---- drivers/perf/arm_dsu_pmu.c | 6 ++---- drivers/perf/arm_smmuv3_pmu.c | 6 ++---- drivers/perf/arm_spe_pmu.c | 7 ++----- drivers/perf/cxl_pmu.c | 7 ++----- drivers/perf/dwc_pcie_pmu.c | 6 ++---- drivers/perf/fsl_imx8_ddr_perf.c | 6 ++---- drivers/perf/fsl_imx9_ddr_perf.c | 6 ++---- drivers/perf/hisilicon/hisi_pcie_pmu.c | 7 ++----- drivers/perf/hisilicon/hisi_uncore_pmu.c | 6 ++---- drivers/perf/hisilicon/hns3_pmu.c | 6 ++---- drivers/perf/marvell_cn10k_ddr_pmu.c | 6 ++---- drivers/perf/marvell_cn10k_tad_pmu.c | 6 ++---- drivers/perf/qcom_l2_pmu.c | 10 +++------- drivers/perf/qcom_l3_pmu.c | 9 ++------- drivers/perf/thunderx2_pmu.c | 7 ++----- drivers/perf/xgene_pmu.c | 7 ++----- 23 files changed, 47 insertions(+), 107 deletions(-)
drivers/perf/alibaba_uncore_drw_pmu.c +2 -4
@@ -535,9 +535,6 @@ static int ali_drw_pmu_event_init(struct perf_event *event)struct perf_event *sibling;struct device *dev = drw_pmu->pmu.dev; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -if (is_sampling_event (event)) {dev_err (dev,"Sampling not supported!\n" );return -EOPNOTSUPP ;
@@ -709,7 +706,8 @@ static int ali_drw_pmu_probe(struct platform_device *pdev) .stop = ali_drw_pmu_stop, .read = ali_drw_pmu_read, .attr_groups = ali_drw_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; ret =perf_pmu_register (&drw_pmu->pmu, name,-1 );
drivers/perf/amlogic/meson_ddr_pmu_core.c +2 -4
@@ -121,9 +121,6 @@ static int meson_ddr_perf_event_init(struct perf_event *event)u64 config1 = event->attr.config1;u64 config2 = event->attr.config2; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;
@@ -492,7 +489,8 @@ int meson_ddr_pmu_create(struct platform_device *pdev) *pmu = (struct ddr_pmu ) { .pmu = { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE , + .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_COMMON_EVENTS , .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = meson_ddr_perf_event_init,
drivers/perf/arm-cci.c +2 -8
@@ -815,10 +815,6 @@ static int pmu_map_event(struct perf_event *event) {struct cci_pmu *cci_pmu =to_cci_pmu (event->pmu); -if (event->attr.type <PERF_TYPE_MAX || - !cci_pmu->model->validate_hw_event) -return -ENOENT ; -return cci_pmu->model->validate_hw_event (cci_pmu, event->attr.config); }
@@ -1316,9 +1312,6 @@ static int cci_pmu_event_init(struct perf_event *event)atomic_t *active_events = &cci_pmu->active_events;int err =0 ; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -/* Shared by all CPUs, no meaningful state to sample */ if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;
@@ -1420,7 +1413,8 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev) .stop = cci_pmu_stop, .read = pmu_read, .attr_groups = pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; cci_pmu->plat_device = pdev;
drivers/perf/arm-ccn.c +2 -4
@@ -719,9 +719,6 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)int i;struct perf_event *sibling; -if (event->attr.type != event->pmu->type) -return -ENOENT ; - ccn =pmu_to_arm_ccn (event->pmu);if (hw->sample_period) {
@@ -1275,7 +1272,8 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn) .read = arm_ccn_pmu_event_read, .pmu_enable = arm_ccn_pmu_enable, .pmu_disable = arm_ccn_pmu_disable, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, };/* No overflow interrupt? Have to use a timer instead. */
drivers/perf/arm-cmn.c +2 -4
@@ -1696,9 +1696,6 @@ static int arm_cmn_event_init(struct perf_event *event)bool bynodeid;u16 nodeid, eventid; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK )return -EINVAL ;
@@ -2471,7 +2468,8 @@ static int arm_cmn_probe(struct platform_device *pdev) cmn->pmu = (struct pmu ) { .module =THIS_MODULE , .attr_groups = arm_cmn_attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE , + .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_COMMON_EVENTS , .task_ctx_nr = perf_invalid_context, .pmu_enable = arm_cmn_pmu_enable, .pmu_disable = arm_cmn_pmu_disable,
drivers/perf/arm_cspmu/arm_cspmu.c +2 -4
@@ -676,9 +676,6 @@ static int arm_cspmu_event_init(struct perf_event *event) cspmu =to_arm_cspmu (event->pmu); -if (event->attr.type != event->pmu->type) -return -ENOENT ; -/* * Following other "uncore" PMUs, we do not support sampling mode or * attach to a task (per-process mode).
@@ -1186,7 +1183,8 @@ static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu)if (ret)return ret; - capabilities =PERF_PMU_CAP_NO_EXCLUDE ; + capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_COMMON_EVENTS ;if (cspmu->irq ==0 ) capabilities |=PERF_PMU_CAP_NO_INTERRUPT ;
drivers/perf/arm_dmc620_pmu.c +2 -4
@@ -515,9 +515,6 @@ static int dmc620_pmu_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct perf_event *sibling; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -/* * DMC 620 PMUs are shared across all cpus and cannot * support task bound and sampling events.
@@ -673,7 +670,8 @@ static int dmc620_pmu_device_probe(struct platform_device *pdev) dmc620_pmu->pmu = (struct pmu ) { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE , + .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_COMMON_EVENTS , .task_ctx_nr = perf_invalid_context, .event_init = dmc620_pmu_event_init, .add = dmc620_pmu_add,
drivers/perf/arm_dsu_pmu.c +2 -4
@@ -544,9 +544,6 @@ static int dsu_pmu_event_init(struct perf_event *event) {struct dsu_pmu *dsu_pmu =to_dsu_pmu (event->pmu); -if (event->attr.type != event->pmu->type) -return -ENOENT ; -/* We don't support sampling */ if (is_sampling_event (event)) {dev_dbg (dsu_pmu->pmu.dev,"Can't support sampling events\n" );
@@ -762,7 +759,8 @@ static int dsu_pmu_device_probe(struct platform_device *pdev) .read = dsu_pmu_read, .attr_groups = dsu_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities =PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; rc =perf_pmu_register (&dsu_pmu->pmu, name,-1 );
drivers/perf/arm_smmuv3_pmu.c +2 -4
@@ -401,9 +401,6 @@ static int smmu_pmu_event_init(struct perf_event *event)int group_num_events =1 ;u16 event_id; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -if (hwc->sample_period) {dev_dbg (dev,"Sampling not supported\n" );return -EOPNOTSUPP ;
@@ -870,7 +867,8 @@ static int smmu_pmu_probe(struct platform_device *pdev) .stop = smmu_pmu_event_stop, .read = smmu_pmu_event_read, .attr_groups = smmu_pmu_attr_grps, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; smmu_pmu->reg_base =devm_platform_get_and_ioremap_resource (pdev,0 , &res_0);
drivers/perf/arm_spe_pmu.c +2 -5
@@ -699,10 +699,6 @@ static int arm_spe_pmu_event_init(struct perf_event *event)struct perf_event_attr *attr = &event->attr;struct arm_spe_pmu *spe_pmu =to_spe_pmu (event->pmu); -/* This is, of course, deeply driver-specific */ -if (attr->type != event->pmu->type) -return -ENOENT ; -if (event->cpu >=0 && !cpumask_test_cpu (event->cpu, &spe_pmu->supported_cpus))return -ENOENT ;
@@ -932,7 +928,8 @@ static int arm_spe_pmu_perf_init(struct arm_spe_pmu *spe_pmu) spe_pmu->pmu = (struct pmu ) { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_EXCLUSIVE |PERF_PMU_CAP_ITRACE , + .capabilities =PERF_PMU_CAP_EXCLUSIVE |PERF_PMU_CAP_ITRACE | +PERF_PMU_CAP_NO_COMMON_EVENTS , .attr_groups = arm_spe_pmu_attr_groups,/* * We hitch a ride on the software context here, so that
drivers/perf/cxl_pmu.c +2 -5
@@ -571,10 +571,6 @@ static int cxl_pmu_event_init(struct perf_event *event)struct cxl_pmu_info *info =pmu_to_cxl_pmu_info (event->pmu);int rc; -/* Top level type sanity check - is this a Hardware Event being requested */ -if (event->attr.type != event->pmu->type) -return -ENOENT ; -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;/* TODO: Validation of any filter */
@@ -870,7 +866,8 @@ static int cxl_pmu_probe(struct device *dev) .read = cxl_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = cxl_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, };if (info->irq <=0 )
drivers/perf/dwc_pcie_pmu.c +2 -4
@@ -366,9 +366,6 @@ static int dwc_pcie_pmu_event_init(struct perf_event *event)struct perf_event *sibling;u32 lane; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -/* We don't support sampling */ if (is_sampling_event (event))return -EINVAL ;
@@ -636,7 +633,8 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev) .parent = &pdev->dev, .module = THIS_MODULE, .attr_groups = dwc_pcie_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities =PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .event_init = dwc_pcie_pmu_event_init, .add = dwc_pcie_pmu_event_add,
drivers/perf/fsl_imx8_ddr_perf.c +2 -4
@@ -398,9 +398,6 @@ static int ddr_perf_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct perf_event *sibling; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;
@@ -651,7 +648,8 @@ static int ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, *pmu = (struct ddr_pmu ) { .pmu = (struct pmu ) { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE , + .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_COMMON_EVENTS , .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = ddr_perf_event_init,
drivers/perf/fsl_imx9_ddr_perf.c +2 -4
@@ -416,9 +416,6 @@ static int ddr_perf_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct perf_event *sibling; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;
@@ -528,7 +525,8 @@ static void ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, *pmu = (struct ddr_pmu ) { .pmu = (struct pmu ) { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE , + .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_COMMON_EVENTS , .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = ddr_perf_event_init,
drivers/perf/hisilicon/hisi_pcie_pmu.c +2 -5
@@ -353,10 +353,6 @@ static int hisi_pcie_pmu_event_init(struct perf_event *event)struct hisi_pcie_pmu *pcie_pmu =to_pcie_pmu (event->pmu);struct hw_perf_event *hwc = &event->hw; -/* Check the type first before going on, otherwise it's not our event */ -if (event->attr.type != event->pmu->type) -return -ENOENT ; -if (EXT_COUNTER_IS_USED (hisi_pcie_get_event (event))) hwc->event_base =HISI_PCIE_EXT_CNT ;else
@@ -813,7 +809,8 @@ static int hisi_pcie_alloc_pmu(struct pci_dev *pdev, struct hisi_pcie_pmu *pcie_ .read = hisi_pcie_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = hisi_pcie_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, };return 0 ;
drivers/perf/hisilicon/hisi_uncore_pmu.c +2 -4
@@ -186,9 +186,6 @@ int hisi_uncore_pmu_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct hisi_pmu *hisi_pmu; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -/* * We do not support sampling as the counters are all * shared by all CPU cores in a CPU die(SCCL). Also we
@@ -548,7 +545,8 @@ void hisi_pmu_init(struct hisi_pmu *hisi_pmu, struct module *module) pmu->stop = hisi_uncore_pmu_stop; pmu->read = hisi_uncore_pmu_read; pmu->attr_groups = hisi_pmu->pmu_events.attr_groups; - pmu->capabilities =PERF_PMU_CAP_NO_EXCLUDE ; + pmu->capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_COMMON_EVENTS ; }EXPORT_SYMBOL_GPL (hisi_pmu_init);
drivers/perf/hisilicon/hns3_pmu.c +2 -4
@@ -1236,9 +1236,6 @@ static int hns3_pmu_event_init(struct perf_event *event)int idx;int ret; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -/* Sampling is not supported */ if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;
@@ -1429,7 +1426,8 @@ static int hns3_pmu_alloc_pmu(struct pci_dev *pdev, struct hns3_pmu *hns3_pmu) .read = hns3_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = hns3_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, };return 0 ;
drivers/perf/marvell_cn10k_ddr_pmu.c +2 -4
@@ -325,9 +325,6 @@ static int cn10k_ddr_perf_event_init(struct perf_event *event)struct cn10k_ddr_pmu *pmu =to_cn10k_ddr_pmu (event->pmu);struct hw_perf_event *hwc = &event->hw; -if (event->attr.type != event->pmu->type) -return -ENOENT ; -if (is_sampling_event (event)) {dev_info (pmu->dev,"Sampling not supported!\n" );return -EOPNOTSUPP ;
@@ -656,7 +653,8 @@ static int cn10k_ddr_perf_probe(struct platform_device *pdev) ddr_pmu->pmu = (struct pmu ) { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE , + .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_COMMON_EVENTS , .task_ctx_nr = perf_invalid_context, .attr_groups = cn10k_attr_groups, .event_init = cn10k_ddr_perf_event_init,
drivers/perf/marvell_cn10k_tad_pmu.c +2 -4
@@ -140,9 +140,6 @@ static int tad_pmu_event_init(struct perf_event *event) {struct tad_pmu *tad_pmu =to_tad_pmu (event->pmu); -if (event->attr.type != event->pmu->type) -return -ENOENT ; -if (!event->attr.disabled)return -EINVAL ;
@@ -321,7 +318,8 @@ static int tad_pmu_probe(struct platform_device *pdev) .module = THIS_MODULE, .attr_groups = tad_pmu_attr_groups, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | - PERF_PMU_CAP_NO_INTERRUPT, +PERF_PMU_CAP_NO_INTERRUPT | + PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .event_init = tad_pmu_event_init,
drivers/perf/qcom_l2_pmu.c +3 -7
@@ -440,12 +440,7 @@ static int l2_cache_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct cluster_pmu *cluster;struct perf_event *sibling; -struct l2cache_pmu *l2cache_pmu; - -if (event->attr.type != event->pmu->type) -return -ENOENT ; - - l2cache_pmu =to_l2cache_pmu (event->pmu); +struct l2cache_pmu *l2cache_pmu =to_l2cache_pmu (event->pmu);if (hwc->sample_period) { dev_dbg_ratelimited(&l2cache_pmu->pdev->dev,
@@ -914,7 +909,8 @@ static int l2_cache_pmu_probe(struct platform_device *pdev) .stop = l2_cache_event_stop, .read = l2_cache_event_read, .attr_groups = l2_cache_pmu_attr_grps, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; l2cache_pmu->num_counters =get_num_counters ();
drivers/perf/qcom_l3_pmu.c +2 -7
@@ -480,12 +480,6 @@ static int qcom_l3_cache__event_init(struct perf_event *event)struct l3cache_pmu *l3pmu =to_l3cache_pmu (event->pmu);struct hw_perf_event *hwc = &event->hw; -/* -* Is the event for this PMU? -*/ -if (event->attr.type != event->pmu->type) -return -ENOENT ; -/* * Sampling not supported since these events are not core-attributable. */
@@ -760,7 +754,8 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev) .read = qcom_l3_cache__event_read, .attr_groups = qcom_l3_cache_pmu_attr_grps, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities =PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; l3pmu->regs =devm_platform_get_and_ioremap_resource (pdev,0 , &memrc);
drivers/perf/thunderx2_pmu.c +2 -5
@@ -574,10 +574,6 @@ static int tx2_uncore_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct tx2_uncore_pmu *tx2_pmu; -/* Test the event attr type check for PMU enumeration */ -if (event->attr.type != event->pmu->type) -return -ENOENT ; -/* * SOC PMU counters are shared across all cores. * Therefore, it does not support per-process mode.
@@ -737,7 +733,8 @@ static int tx2_uncore_pmu_register( .start = tx2_uncore_event_start, .stop = tx2_uncore_event_stop, .read = tx2_uncore_event_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, }; tx2_pmu->pmu.name = devm_kasprintf(dev, GFP_KERNEL,
drivers/perf/xgene_pmu.c +2 -5
@@ -888,10 +888,6 @@ static int xgene_perf_event_init(struct perf_event *event)struct hw_perf_event *hw = &event->hw;struct perf_event *sibling; -/* Test the event attr type check for PMU enumeration */ -if (event->attr.type != event->pmu->type) -return -ENOENT ; -/* * SOC PMU counters are shared across all cores. * Therefore, it does not support per-process mode.
@@ -1112,7 +1108,8 @@ static int xgene_init_perf(struct xgene_pmu_dev *pmu_dev, char *name) .start = xgene_perf_start, .stop = xgene_perf_stop, .read = xgene_perf_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | + PERF_PMU_CAP_NO_COMMON_EVENTS, };/* Hardware counter init */
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
Robin Murphy
maintainerPATCH 4/10 perf: Rename PERF_PMU_CAP_NO_INTERRUPT
In reply to Robin MurphyThe PERF_PMU_CAP_NO_INTERRUPT flag is used by the core solely to determine whether PMUs can support sampling events or not. It makes sense to utilise the same capability for non-CPU-affine PMUs which have no relevant state to sample, but it would be a rather confusing misnomer when such PMUs do still have interrupts for handling overflows. Let's rename it to represent what it actually means.
--- arch/arc/kernel/perf_event.c | 2 +- arch/csky/kernel/perf_event.c | 2 +- arch/powerpc/perf/8xx-pmu.c | 2 +- arch/powerpc/perf/hv-24x7.c | 2 +- arch/powerpc/perf/hv-gpci.c | 2 +- arch/powerpc/platforms/pseries/papr_scm.c | 2 +- arch/s390/kernel/perf_cpum_cf.c | 2 +- arch/sh/kernel/perf_event.c | 2 +- arch/x86/events/amd/uncore.c | 6 +++--- arch/x86/events/core.c | 2 +- arch/x86/events/intel/cstate.c | 6 +++--- arch/x86/events/msr.c | 2 +- drivers/fpga/dfl-fme-perf.c | 2 +- drivers/perf/arm_cspmu/arm_cspmu.c | 2 +- drivers/perf/arm_pmu_platform.c | 2 +- drivers/perf/marvell_cn10k_tad_pmu.c | 2 +- drivers/perf/riscv_pmu_sbi.c | 2 +- include/linux/perf_event.h | 2 +- kernel/events/core.c | 2 +- 19 files changed, 23 insertions(+), 23 deletions(-)
arch/arc/kernel/perf_event.c +1 -1
@@ -819,7 +819,7 @@ static int arc_pmu_device_probe(struct platform_device *pdev) }if (irq ==-1 ) - arc_pmu->pmu.capabilities |=PERF_PMU_CAP_NO_INTERRUPT ; + arc_pmu->pmu.capabilities |=PERF_PMU_CAP_NO_SAMPLING ;/* * perf parser doesn't really like '-' symbol in events name, so let's
arch/csky/kernel/perf_event.c +1 -1
@@ -1315,7 +1315,7 @@ int csky_pmu_device_probe(struct platform_device *pdev, ret =csky_pmu_request_irq (csky_pmu_handle_irq);if (ret) { - csky_pmu.pmu.capabilities |=PERF_PMU_CAP_NO_INTERRUPT ; + csky_pmu.pmu.capabilities |=PERF_PMU_CAP_NO_SAMPLING ;pr_notice ("[perf] PMU request irq fail!\n" ); }
arch/powerpc/perf/8xx-pmu.c +1 -1
@@ -181,7 +181,7 @@ static struct pmu mpc8xx_pmu = { .add = mpc8xx_pmu_add, .del = mpc8xx_pmu_del, .read = mpc8xx_pmu_read, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT | + .capabilities = PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_NMI, };
arch/powerpc/perf/hv-24x7.c +1 -1
@@ -1737,7 +1737,7 @@ static int hv_24x7_init(void)return -ENOMEM ;/* sampling not supported */ - h_24x7_pmu.capabilities |=PERF_PMU_CAP_NO_INTERRUPT ; + h_24x7_pmu.capabilities |=PERF_PMU_CAP_NO_SAMPLING r = create_events_from_catalog(&event_group.attrs, &event_desc_group.attrs,
arch/powerpc/perf/hv-gpci.c +1 -1
@@ -984,7 +984,7 @@ static int hv_gpci_init(void)return r;/* sampling not supported */ - h_gpci_pmu.capabilities |=PERF_PMU_CAP_NO_INTERRUPT ; + h_gpci_pmu.capabilities |=PERF_PMU_CAP_NO_SAMPLING arg = (void *)get_cpu_var(hv_gpci_reqb);memset (arg,0 ,HGPCI_REQ_BUFFER_SIZE );
arch/powerpc/platforms/pseries/papr_scm.c +1 -1
@@ -501,7 +501,7 @@ static void papr_scm_pmu_register(struct papr_scm_priv *p) nd_pmu->pmu.add = papr_scm_pmu_add; nd_pmu->pmu.del = papr_scm_pmu_del; - nd_pmu->pmu.capabilities =PERF_PMU_CAP_NO_INTERRUPT | + nd_pmu->pmu.capabilities =PERF_PMU_CAP_NO_SAMPLING |PERF_PMU_CAP_NO_EXCLUDE ;/*updating the cpumask variable */
arch/s390/kernel/perf_cpum_cf.c +1 -1
@@ -1054,7 +1054,7 @@ static void cpumf_pmu_del(struct perf_event *event, int flags)/* Performance monitoring unit for s390x */ static struct pmu cpumf_pmu = { .task_ctx_nr = perf_sw_context, - .capabilities =PERF_PMU_CAP_NO_INTERRUPT , + .capabilities =PERF_PMU_CAP_NO_SAMPLING .pmu_enable = cpumf_pmu_enable, .pmu_disable = cpumf_pmu_disable, .event_init = cpumf_pmu_event_init,
arch/sh/kernel/perf_event.c +1 -1
@@ -352,7 +352,7 @@ int register_sh_pmu(struct sh_pmu *_pmu)* no interrupts, and are therefore unable to do sampling without * further work and timer assistance. */ - pmu.capabilities |=PERF_PMU_CAP_NO_INTERRUPT ; + pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLINGWARN_ON (_pmu->num_events >MAX_HWEVENTS );
arch/x86/events/amd/uncore.c +3 -3
@@ -700,7 +700,7 @@ int amd_uncore_df_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, .module = THIS_MODULE, };
@@ -833,7 +833,7 @@ int amd_uncore_l3_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, .module = THIS_MODULE, };
@@ -958,7 +958,7 @@ int amd_uncore_umc_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_umc_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT, + .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, .module = THIS_MODULE, };
arch/x86/events/core.c +1 -1
@@ -1812,7 +1812,7 @@ static void __init pmu_check_apic(void)* events (user-space has to fall back and * sample via a hrtimer based software event): */ - pmu.capabilities |=PERF_PMU_CAP_NO_INTERRUPT ; + pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING }
arch/x86/events/intel/cstate.c +3 -3
@@ -530,7 +530,7 @@ static struct pmu cstate_core_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE, .module = THIS_MODULE, };
@@ -545,7 +545,7 @@ static struct pmu cstate_pkg_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE, .module = THIS_MODULE, };
@@ -560,7 +560,7 @@ static struct pmu cstate_module_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_EXCLUDE, .module = THIS_MODULE, };
arch/x86/events/msr.c +1 -1
@@ -296,7 +296,7 @@ static struct pmu pmu_msr = { .start = msr_event_start, .stop = msr_event_stop, .read = msr_event_update, - .capabilities = PERF_PMU_CAP_NO_INTERRUPT | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_EXCLUDE, .attr_update = attr_update, };
drivers/fpga/dfl-fme-perf.c +1 -1
@@ -921,7 +921,7 @@ static int fme_perf_pmu_register(struct platform_device *pdev, pmu->start = fme_perf_event_start; pmu->stop = fme_perf_event_stop; pmu->read = fme_perf_event_read; - pmu->capabilities =PERF_PMU_CAP_NO_INTERRUPT | + pmu->capabilities =PERF_PMU_CAP_NO_SAMPLING |PERF_PMU_CAP_NO_EXCLUDE ; name =devm_kasprintf (priv->dev,GFP_KERNEL ,"dfl_fme%d" , pdev->id);
drivers/perf/arm_cspmu/arm_cspmu.c +1 -1
@@ -1186,7 +1186,7 @@ static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu) capabilities =PERF_PMU_CAP_NO_EXCLUDE |PERF_PMU_CAP_NO_COMMON_EVENTS ;if (cspmu->irq ==0 ) - capabilities |=PERF_PMU_CAP_NO_INTERRUPT ; + capabilities |=PERF_PMU_CAP_NO_SAMPLING ; cspmu->pmu = (struct pmu ){ .task_ctx_nr = perf_invalid_context,
drivers/perf/arm_pmu_platform.c +1 -1
@@ -109,7 +109,7 @@ static int pmu_parse_irqs(struct arm_pmu *pmu)*/ if (num_irqs ==0 ) {dev_warn (dev,"no irqs for PMU, sampling events not supported\n" ); - pmu->pmu.capabilities |=PERF_PMU_CAP_NO_INTERRUPT ; + pmu->pmu.capabilities |=PERF_PMU_CAP_NO_SAMPLING ;cpumask_setall (&pmu->supported_cpus);return 0 ; }
drivers/perf/marvell_cn10k_tad_pmu.c +1 -1
@@ -318,7 +318,7 @@ static int tad_pmu_probe(struct platform_device *pdev) .module = THIS_MODULE, .attr_groups = tad_pmu_attr_groups, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_INTERRUPT | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context,
drivers/perf/riscv_pmu_sbi.c +1 -1
@@ -1049,7 +1049,7 @@ static int pmu_sbi_device_probe(struct platform_device *pdev) ret =pmu_sbi_setup_irqs (pmu, pdev);if (ret <0 ) {pr_info ("Perf sampling/filtering is not supported as sscof extension is not available\n" ); - pmu->pmu.capabilities |=PERF_PMU_CAP_NO_INTERRUPT ; + pmu->pmu.capabilities |=PERF_PMU_CAP_NO_SAMPLING ; pmu->pmu.capabilities |=PERF_PMU_CAP_NO_EXCLUDE ; }
include/linux/perf_event.h +1 -1
@@ -282,7 +282,7 @@ struct perf_event_pmu_context;/** * pmu::capabilities flags */ -#define PERF_PMU_CAP_NO_INTERRUPT 0x0001 +#define PERF_PMU_CAP_NO_SAMPLING 0x0001#define PERF_PMU_CAP_NO_NMI 0x0002#define PERF_PMU_CAP_AUX_NO_SG 0x0004#define PERF_PMU_CAP_EXTENDED_REGS 0x0008
kernel/events/core.c +1 -1
@@ -12539,7 +12539,7 @@ SYSCALL_DEFINE5(perf_event_open, }if (is_sampling_event (event)) { -if (event->pmu->capabilities &PERF_PMU_CAP_NO_INTERRUPT ) { +if (event->pmu->capabilities &PERF_PMU_CAP_NO_SAMPLING ) { err = -EOPNOTSUPP ; goto err_alloc; }
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
kernel test robot
build botRe: [PATCH 04/10] perf: Rename PERF_PMU_CAP_NO_INTERRUPT
kernel test robot noticed the following build errors:
Hi Robin,
kernel test robot noticed the following build errors:
[auto build test ERROR on perf-tools-next/perf-tools-next]
[also build test ERROR on perf-tools/perf-tools linus/master v6.8 next-20240313] [cannot apply to acme/perf/core tip/perf/core]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Robin-Murphy/perf-alibaba_uncore_drw-Use-correct-CPU-affinity/20240313-013915 base: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git perf-tools-next patch link: https://lore.kernel.org/r/0999a39f0a068979dbcc6119380f63d706101b4f.1710257512.git.robin.murphy%40arm.com patch subject: [PATCH 04/10] perf: Rename PERF_PMU_CAP_NO_INTERRUPT config: x86_64-allnoconfig (https://download.01.org/0day-ci/archive/20240313/[email protected]/config) compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240313/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> arch/x86/events/core.c:1815:46: error: expected ';' after expression
1815 | pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING
| ^
| ;1 error generated.
vim +1815 arch/x86/events/core.c
1799
1800 static void __init pmu_check_apic(void)
1801 {
1802 if (boot_cpu_has(X86_FEATURE_APIC))
1803 return;
1804
1805 x86_pmu.apic = 0;
1806 pr_info("no APIC, boot with the \"lapic\" boot parameter to force-enable it.\n");
1807 pr_info("no hardware sampling interrupt available.\n");
1808
1809 /*
1810 * If we have a PMU initialized but no APIC
1811 * interrupts, we cannot sample hardware
1812 * events (user-space has to fall back and
1813 * sample via a hrtimer based software event):
1814 */
> 1815 pmu.capabilities |= PERF_PMU_CAP_NO_SAMPLING
1816
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 04/10] perf: Rename PERF_PMU_CAP_NO_INTERRUPT
In reply to Robin Murphykernel test robot noticed the following build warnings:
Hi Robin,
kernel test robot noticed the following build warnings:
[auto build test WARNING on perf-tools-next/perf-tools-next]
[also build test WARNING on perf-tools/perf-tools linus/master v6.8 next-20240313] [cannot apply to acme/perf/core tip/perf/core]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Robin-Murphy/perf-alibaba_uncore_drw-Use-correct-CPU-affinity/20240313-013915 base: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git perf-tools-next patch link: https://lore.kernel.org/r/0999a39f0a068979dbcc6119380f63d706101b4f.1710257512.git.robin.murphy%40arm.com patch subject: [PATCH 04/10] perf: Rename PERF_PMU_CAP_NO_INTERRUPT config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20240313/[email protected]/config) compiler: powerpc64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240313/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
arch/powerpc/perf/hv-24x7.c: In function 'hv_24x7_init':
arch/powerpc/perf/hv-24x7.c:1742:9: error: expected ';' before 'r'
1742 | r = create_events_from_catalog(&event_group.attrs,
| ^
arch/powerpc/perf/hv-24x7.c: At top level:
>> arch/powerpc/perf/hv-24x7.c:764:12: warning: 'create_events_from_catalog' defined but not used [-Wunused-function] 764 | static int create_events_from_catalog(struct attribute ***events_,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/create_events_from_catalog +764 arch/powerpc/perf/hv-24x7.c
5c5cd7b502595f Cody P Schafer 2015-01-30 763
7debc970ae7a55 Li Zhong 2015-04-13 @764 static int create_events_from_catalog(struct attribute ***events_,
5c5cd7b502595f Cody P Schafer 2015-01-30 765 struct attribute ***event_descs_,
5c5cd7b502595f Cody P Schafer 2015-01-30 766 struct attribute ***event_long_descs_)
5c5cd7b502595f Cody P Schafer 2015-01-30 767 {
38d81846106bb1 Thiago Jung Bauermann 2017-06-29 768 long hret;
5c5cd7b502595f Cody P Schafer 2015-01-30 769 size_t catalog_len, catalog_page_len, event_entry_count,
5c5cd7b502595f Cody P Schafer 2015-01-30 770 event_data_len, event_data_offs,
5c5cd7b502595f Cody P Schafer 2015-01-30 771 event_data_bytes, junk_events, event_idx, event_attr_ct, i,
5c5cd7b502595f Cody P Schafer 2015-01-30 772 attr_max, event_idx_last, desc_ct, long_desc_ct;
5c5cd7b502595f Cody P Schafer 2015-01-30 773 ssize_t ct, ev_len;
12bf85a71000af Thiago Jung Bauermann 2017-06-29 774 uint64_t catalog_version_num;
5c5cd7b502595f Cody P Schafer 2015-01-30 775 struct attribute **events, **event_descs, **event_long_descs;
5c5cd7b502595f Cody P Schafer 2015-01-30 776 struct hv_24x7_catalog_page_0 *page_0 =
5c5cd7b502595f Cody P Schafer 2015-01-30 777 kmem_cache_alloc(hv_page_cache, GFP_KERNEL);
5c5cd7b502595f Cody P Schafer 2015-01-30 778 void *page = page_0;
5c5cd7b502595f Cody P Schafer 2015-01-30 779 void *event_data, *end;
5c5cd7b502595f Cody P Schafer 2015-01-30 780 struct hv_24x7_event_data *event;
5c5cd7b502595f Cody P Schafer 2015-01-30 781 struct rb_root ev_uniq = RB_ROOT;
7debc970ae7a55 Li Zhong 2015-04-13 782 int ret = 0;
5c5cd7b502595f Cody P Schafer 2015-01-30 783
7debc970ae7a55 Li Zhong 2015-04-13 784 if (!page) {
7debc970ae7a55 Li Zhong 2015-04-13 785 ret = -ENOMEM;
5c5cd7b502595f Cody P Schafer 2015-01-30 786 goto e_out;
7debc970ae7a55 Li Zhong 2015-04-13 787 }
5c5cd7b502595f Cody P Schafer 2015-01-30 788
5c5cd7b502595f Cody P Schafer 2015-01-30 789 hret = h_get_24x7_catalog_page(page, 0, 0);
7debc970ae7a55 Li Zhong 2015-04-13 790 if (hret) {
7debc970ae7a55 Li Zhong 2015-04-13 791 ret = -EIO;
5c5cd7b502595f Cody P Schafer 2015-01-30 792 goto e_free;
7debc970ae7a55 Li Zhong 2015-04-13 793 }
5c5cd7b502595f Cody P Schafer 2015-01-30 794
5c5cd7b502595f Cody P Schafer 2015-01-30 795 catalog_version_num = be64_to_cpu(page_0->version);
5c5cd7b502595f Cody P Schafer 2015-01-30 796 catalog_page_len = be32_to_cpu(page_0->length);
5c5cd7b502595f Cody P Schafer 2015-01-30 797
5c5cd7b502595f Cody P Schafer 2015-01-30 798 if (MAX_4K < catalog_page_len) {
5c5cd7b502595f Cody P Schafer 2015-01-30 799 pr_err("invalid page count: %zu\n", catalog_page_len);
7debc970ae7a55 Li Zhong 2015-04-13 800 ret = -EIO;
5c5cd7b502595f Cody P Schafer 2015-01-30 801 goto e_free;
5c5cd7b502595f Cody P Schafer 2015-01-30 802 }
5c5cd7b502595f Cody P Schafer 2015-01-30 803
5c5cd7b502595f Cody P Schafer 2015-01-30 804 catalog_len = catalog_page_len * 4096;
5c5cd7b502595f Cody P Schafer 2015-01-30 805
5c5cd7b502595f Cody P Schafer 2015-01-30 806 event_entry_count = be16_to_cpu(page_0->event_entry_count);
5c5cd7b502595f Cody P Schafer 2015-01-30 807 event_data_offs = be16_to_cpu(page_0->event_data_offs);
5c5cd7b502595f Cody P Schafer 2015-01-30 808 event_data_len = be16_to_cpu(page_0->event_data_len);
5c5cd7b502595f Cody P Schafer 2015-01-30 809
12bf85a71000af Thiago Jung Bauermann 2017-06-29 810 pr_devel("cv %llu cl %zu eec %zu edo %zu edl %zu\n",
12bf85a71000af Thiago Jung Bauermann 2017-06-29 811 catalog_version_num, catalog_len,
5c5cd7b502595f Cody P Schafer 2015-01-30 812 event_entry_count, event_data_offs, event_data_len);
5c5cd7b502595f Cody P Schafer 2015-01-30 813
5c5cd7b502595f Cody P Schafer 2015-01-30 814 if ((MAX_4K < event_data_len)
5c5cd7b502595f Cody P Schafer 2015-01-30 815 || (MAX_4K < event_data_offs)
5c5cd7b502595f Cody P Schafer 2015-01-30 816 || (MAX_4K - event_data_offs < event_data_len)) {
5c5cd7b502595f Cody P Schafer 2015-01-30 817 pr_err("invalid event data offs %zu and/or len %zu\n",
5c5cd7b502595f Cody P Schafer 2015-01-30 818 event_data_offs, event_data_len);
7debc970ae7a55 Li Zhong 2015-04-13 819 ret = -EIO;
5c5cd7b502595f Cody P Schafer 2015-01-30 820 goto e_free;
5c5cd7b502595f Cody P Schafer 2015-01-30 821 }
5c5cd7b502595f Cody P Schafer 2015-01-30 822
5c5cd7b502595f Cody P Schafer 2015-01-30 823 if ((event_data_offs + event_data_len) > catalog_page_len) {
5c5cd7b502595f Cody P Schafer 2015-01-30 824 pr_err("event data %zu-%zu does not fit inside catalog 0-%zu\n",
5c5cd7b502595f Cody P Schafer 2015-01-30 825 event_data_offs,
5c5cd7b502595f Cody P Schafer 2015-01-30 826 event_data_offs + event_data_len,
5c5cd7b502595f Cody P Schafer 2015-01-30 827 catalog_page_len);
7debc970ae7a55 Li Zhong 2015-04-13 828 ret = -EIO;
5c5cd7b502595f Cody P Schafer 2015-01-30 829 goto e_free;
5c5cd7b502595f Cody P Schafer 2015-01-30 830 }
5c5cd7b502595f Cody P Schafer 2015-01-30 831
8f69dc701aac17 Sukadev Bhattiprolu 2016-02-16 832 if (SIZE_MAX - 1 < event_entry_count) {
8f69dc701aac17 Sukadev Bhattiprolu 2016-02-16 833 pr_err("event_entry_count %zu is invalid\n", event_entry_count);
7debc970ae7a55 Li Zhong 2015-04-13 834 ret = -EIO;
5c5cd7b502595f Cody P Schafer 2015-01-30 835 goto e_free;
5c5cd7b502595f Cody P Schafer 2015-01-30 836 }
5c5cd7b502595f Cody P Schafer 2015-01-30 837
5c5cd7b502595f Cody P Schafer 2015-01-30 838 event_data_bytes = event_data_len * 4096;
5c5cd7b502595f Cody P Schafer 2015-01-30 839
5c5cd7b502595f Cody P Schafer 2015-01-30 840 /*
5c5cd7b502595f Cody P Schafer 2015-01-30 841 * event data can span several pages, events can cross between these
5c5cd7b502595f Cody P Schafer 2015-01-30 842 * pages. Use vmalloc to make this easier.
5c5cd7b502595f Cody P Schafer 2015-01-30 843 */
5c5cd7b502595f Cody P Schafer 2015-01-30 844 event_data = vmalloc(event_data_bytes);
5c5cd7b502595f Cody P Schafer 2015-01-30 845 if (!event_data) {
5c5cd7b502595f Cody P Schafer 2015-01-30 846 pr_err("could not allocate event data\n");
7debc970ae7a55 Li Zhong 2015-04-13 847 ret = -ENOMEM;
5c5cd7b502595f Cody P Schafer 2015-01-30 848 goto e_free;
5c5cd7b502595f Cody P Schafer 2015-01-30 849 }
5c5cd7b502595f Cody P Schafer 2015-01-30 850
5c5cd7b502595f Cody P Schafer 2015-01-30 851 end = event_data + event_data_bytes;
5c5cd7b502595f Cody P Schafer 2015-01-30 852
5c5cd7b502595f Cody P Schafer 2015-01-30 853 /*
5c5cd7b502595f Cody P Schafer 2015-01-30 854 * using vmalloc_to_phys() like this only works if PAGE_SIZE is
5c5cd7b502595f Cody P Schafer 2015-01-30 855 * divisible by 4096
5c5cd7b502595f Cody P Schafer 2015-01-30 856 */
5c5cd7b502595f Cody P Schafer 2015-01-30 857 BUILD_BUG_ON(PAGE_SIZE % 4096);
5c5cd7b502595f Cody P Schafer 2015-01-30 858
5c5cd7b502595f Cody P Schafer 2015-01-30 859 for (i = 0; i < event_data_len; i++) {
5c5cd7b502595f Cody P Schafer 2015-01-30 860 hret = h_get_24x7_catalog_page_(
5c5cd7b502595f Cody P Schafer 2015-01-30 861 vmalloc_to_phys(event_data + i * 4096),
5c5cd7b502595f Cody P Schafer 2015-01-30 862 catalog_version_num,
5c5cd7b502595f Cody P Schafer 2015-01-30 863 i + event_data_offs);
5c5cd7b502595f Cody P Schafer 2015-01-30 864 if (hret) {
12bf85a71000af Thiago Jung Bauermann 2017-06-29 865 pr_err("Failed to get event data in page %zu: rc=%ld\n",
12bf85a71000af Thiago Jung Bauermann 2017-06-29 866 i + event_data_offs, hret);
7debc970ae7a55 Li Zhong 2015-04-13 867 ret = -EIO;
5c5cd7b502595f Cody P Schafer 2015-01-30 868 goto e_event_data;
5c5cd7b502595f Cody P Schafer 2015-01-30 869 }
5c5cd7b502595f Cody P Schafer 2015-01-30 870 }
5c5cd7b502595f Cody P Schafer 2015-01-30 871
5c5cd7b502595f Cody P Schafer 2015-01-30 872 /*
5c5cd7b502595f Cody P Schafer 2015-01-30 873 * scan the catalog to determine the number of attributes we need, and
5c5cd7b502595f Cody P Schafer 2015-01-30 874 * verify it at the same time.
5c5cd7b502595f Cody P Schafer 2015-01-30 875 */
5c5cd7b502595f Cody P Schafer 2015-01-30 876 for (junk_events = 0, event = event_data, event_idx = 0, attr_max = 0;
5c5cd7b502595f Cody P Schafer 2015-01-30 877 ;
5c5cd7b502595f Cody P Schafer 2015-01-30 878 event_idx++, event = (void *)event + ev_len) {
5c5cd7b502595f Cody P Schafer 2015-01-30 879 size_t offset = (void *)event - (void *)event_data;
5c5cd7b502595f Cody P Schafer 2015-01-30 880 char *name;
5c5cd7b502595f Cody P Schafer 2015-01-30 881 int nl;
5c5cd7b502595f Cody P Schafer 2015-01-30 882
5c5cd7b502595f Cody P Schafer 2015-01-30 883 ev_len = catalog_event_len_validate(event, event_idx,
5c5cd7b502595f Cody P Schafer 2015-01-30 884 event_data_bytes,
5c5cd7b502595f Cody P Schafer 2015-01-30 885 event_entry_count,
5c5cd7b502595f Cody P Schafer 2015-01-30 886 offset, end);
5c5cd7b502595f Cody P Schafer 2015-01-30 887 if (ev_len < 0)
5c5cd7b502595f Cody P Schafer 2015-01-30 888 break;
5c5cd7b502595f Cody P Schafer 2015-01-30 889
5c5cd7b502595f Cody P Schafer 2015-01-30 890 name = event_name(event, &nl);
5c5cd7b502595f Cody P Schafer 2015-01-30 891
e5f9d8858612c1 Kajol Jain 2020-12-28 892 if (ignore_event(name)) {
e5f9d8858612c1 Kajol Jain 2020-12-28 893 junk_events++;
e5f9d8858612c1 Kajol Jain 2020-12-28 894 continue;
e5f9d8858612c1 Kajol Jain 2020-12-28 895 }
5c5cd7b502595f Cody P Schafer 2015-01-30 896 if (event->event_group_record_len == 0) {
5c5cd7b502595f Cody P Schafer 2015-01-30 897 pr_devel("invalid event %zu (%.*s): group_record_len == 0, skipping\n",
5c5cd7b502595f Cody P Schafer 2015-01-30 898 event_idx, nl, name);
5c5cd7b502595f Cody P Schafer 2015-01-30 899 junk_events++;
5c5cd7b502595f Cody P Schafer 2015-01-30 900 continue;
5c5cd7b502595f Cody P Schafer 2015-01-30 901 }
5c5cd7b502595f Cody P Schafer 2015-01-30 902
5c5cd7b502595f Cody P Schafer 2015-01-30 903 if (!catalog_entry_domain_is_valid(event->domain)) {
5c5cd7b502595f Cody P Schafer 2015-01-30 904 pr_info("event %zu (%.*s) has invalid domain %d\n",
5c5cd7b502595f Cody P Schafer 2015-01-30 905 event_idx, nl, name, event->domain);
5c5cd7b502595f Cody P Schafer 2015-01-30 906 junk_events++;
5c5cd7b502595f Cody P Schafer 2015-01-30 907 continue;
5c5cd7b502595f Cody P Schafer 2015-01-30 908 }
5c5cd7b502595f Cody P Schafer 2015-01-30 909
8f69dc701aac17 Sukadev Bhattiprolu 2016-02-16 910 attr_max++;
5c5cd7b502595f Cody P Schafer 2015-01-30 911 }
5c5cd7b502595f Cody P Schafer 2015-01-30 912
5c5cd7b502595f Cody P Schafer 2015-01-30 913 event_idx_last = event_idx;
5c5cd7b502595f Cody P Schafer 2015-01-30 914 if (event_idx_last != event_entry_count)
5c5cd7b502595f Cody P Schafer 2015-01-30 915 pr_warn("event buffer ended before listed # of events were parsed (got %zu, wanted %zu, junk %zu)\n",
5c5cd7b502595f Cody P Schafer 2015-01-30 916 event_idx_last, event_entry_count, junk_events);
5c5cd7b502595f Cody P Schafer 2015-01-30 917
5c5cd7b502595f Cody P Schafer 2015-01-30 918 events = kmalloc_array(attr_max + 1, sizeof(*events), GFP_KERNEL);
7debc970ae7a55 Li Zhong 2015-04-13 919 if (!events) {
7debc970ae7a55 Li Zhong 2015-04-13 920 ret = -ENOMEM;
5c5cd7b502595f Cody P Schafer 2015-01-30 921 goto e_event_data;
7debc970ae7a55 Li Zhong 2015-04-13 922 }
5c5cd7b502595f Cody P Schafer 2015-01-30 923
5c5cd7b502595f Cody P Schafer 2015-01-30 924 event_descs = kmalloc_array(event_idx + 1, sizeof(*event_descs),
5c5cd7b502595f Cody P Schafer 2015-01-30 925 GFP_KERNEL);
7debc970ae7a55 Li Zhong 2015-04-13 926 if (!event_descs) {
7debc970ae7a55 Li Zhong 2015-04-13 927 ret = -ENOMEM;
5c5cd7b502595f Cody P Schafer 2015-01-30 928 goto e_event_attrs;
7debc970ae7a55 Li Zhong 2015-04-13 929 }
5c5cd7b502595f Cody P Schafer 2015-01-30 930
5c5cd7b502595f Cody P Schafer 2015-01-30 931 event_long_descs = kmalloc_array(event_idx + 1,
5c5cd7b502595f Cody P Schafer 2015-01-30 932 sizeof(*event_long_descs), GFP_KERNEL);
7debc970ae7a55 Li Zhong 2015-04-13 933 if (!event_long_descs) {
7debc970ae7a55 Li Zhong 2015-04-13 934 ret = -ENOMEM;
5c5cd7b502595f Cody P Schafer 2015-01-30 935 goto e_event_descs;
7debc970ae7a55 Li Zhong 2015-04-13 936 }
5c5cd7b502595f Cody P Schafer 2015-01-30 937
5c5cd7b502595f Cody P Schafer 2015-01-30 938 /* Iterate over the catalog filling in the attribute vector */
5c5cd7b502595f Cody P Schafer 2015-01-30 939 for (junk_events = 0, event_attr_ct = 0, desc_ct = 0, long_desc_ct = 0,
5c5cd7b502595f Cody P Schafer 2015-01-30 940 event = event_data, event_idx = 0;
5c5cd7b502595f Cody P Schafer 2015-01-30 941 event_idx < event_idx_last;
5c5cd7b502595f Cody P Schafer 2015-01-30 942 event_idx++, ev_len = be16_to_cpu(event->length),
5c5cd7b502595f Cody P Schafer 2015-01-30 943 event = (void *)event + ev_len) {
5c5cd7b502595f Cody P Schafer 2015-01-30 944 char *name;
5c5cd7b502595f Cody P Schafer 2015-01-30 945 int nl;
5c5cd7b502595f Cody P Schafer 2015-01-30 946 int nonce;
5c5cd7b502595f Cody P Schafer 2015-01-30 947 /*
5c5cd7b502595f Cody P Schafer 2015-01-30 948 * these are the only "bad" events that are intermixed and that
5c5cd7b502595f Cody P Schafer 2015-01-30 949 * we can ignore without issue. make sure to skip them here
5c5cd7b502595f Cody P Schafer 2015-01-30 950 */
5c5cd7b502595f Cody P Schafer 2015-01-30 951 if (event->event_group_record_len == 0)
5c5cd7b502595f Cody P Schafer 2015-01-30 952 continue;
5c5cd7b502595f Cody P Schafer 2015-01-30 953 if (!catalog_entry_domain_is_valid(event->domain))
5c5cd7b502595f Cody P Schafer 2015-01-30 954 continue;
5c5cd7b502595f Cody P Schafer 2015-01-30 955
5c5cd7b502595f Cody P Schafer 2015-01-30 956 name = event_name(event, &nl);
e5f9d8858612c1 Kajol Jain 2020-12-28 957 if (ignore_event(name))
e5f9d8858612c1 Kajol Jain 2020-12-28 958 continue;
e5f9d8858612c1 Kajol Jain 2020-12-28 959
5c5cd7b502595f Cody P Schafer 2015-01-30 960 nonce = event_uniq_add(&ev_uniq, name, nl, event->domain);
5c5cd7b502595f Cody P Schafer 2015-01-30 961 ct = event_data_to_attrs(event_idx, events + event_attr_ct,
5c5cd7b502595f Cody P Schafer 2015-01-30 962 event, nonce);
8f69dc701aac17 Sukadev Bhattiprolu 2016-02-16 963 if (ct < 0) {
5c5cd7b502595f Cody P Schafer 2015-01-30 964 pr_warn("event %zu (%.*s) creation failure, skipping\n",
5c5cd7b502595f Cody P Schafer 2015-01-30 965 event_idx, nl, name);
5c5cd7b502595f Cody P Schafer 2015-01-30 966 junk_events++;
5c5cd7b502595f Cody P Schafer 2015-01-30 967 } else {
8f69dc701aac17 Sukadev Bhattiprolu 2016-02-16 968 event_attr_ct++;
5c5cd7b502595f Cody P Schafer 2015-01-30 969 event_descs[desc_ct] = event_to_desc_attr(event, nonce);
5c5cd7b502595f Cody P Schafer 2015-01-30 970 if (event_descs[desc_ct])
5c5cd7b502595f Cody P Schafer 2015-01-30 971 desc_ct++;
5c5cd7b502595f Cody P Schafer 2015-01-30 972 event_long_descs[long_desc_ct] =
5c5cd7b502595f Cody P Schafer 2015-01-30 973 event_to_long_desc_attr(event, nonce);
5c5cd7b502595f Cody P Schafer 2015-01-30 974 if (event_long_descs[long_desc_ct])
5c5cd7b502595f Cody P Schafer 2015-01-30 975 long_desc_ct++;
5c5cd7b502595f Cody P Schafer 2015-01-30 976 }
5c5cd7b502595f Cody P Schafer 2015-01-30 977 }
5c5cd7b502595f Cody P Schafer 2015-01-30 978
5c5cd7b502595f Cody P Schafer 2015-01-30 979 pr_info("read %zu catalog entries, created %zu event attrs (%zu failures), %zu descs\n",
5c5cd7b502595f Cody P Schafer 2015-01-30 980 event_idx, event_attr_ct, junk_events, desc_ct);
5c5cd7b502595f Cody P Schafer 2015-01-30 981
5c5cd7b502595f Cody P Schafer 2015-01-30 982 events[event_attr_ct] = NULL;
5c5cd7b502595f Cody P Schafer 2015-01-30 983 event_descs[desc_ct] = NULL;
5c5cd7b502595f Cody P Schafer 2015-01-30 984 event_long_descs[long_desc_ct] = NULL;
5c5cd7b502595f Cody P Schafer 2015-01-30 985
5c5cd7b502595f Cody P Schafer 2015-01-30 986 event_uniq_destroy(&ev_uniq);
5c5cd7b502595f Cody P Schafer 2015-01-30 987 vfree(event_data);
5c5cd7b502595f Cody P Schafer 2015-01-30 988 kmem_cache_free(hv_page_cache, page);
5c5cd7b502595f Cody P Schafer 2015-01-30 989
5c5cd7b502595f Cody P Schafer 2015-01-30 990 *events_ = events;
5c5cd7b502595f Cody P Schafer 2015-01-30 991 *event_descs_ = event_descs;
5c5cd7b502595f Cody P Schafer 2015-01-30 992 *event_long_descs_ = event_long_descs;
7debc970ae7a55 Li Zhong 2015-04-13 993 return 0;
5c5cd7b502595f Cody P Schafer 2015-01-30 994
5c5cd7b502595f Cody P Schafer 2015-01-30 995 e_event_descs:
5c5cd7b502595f Cody P Schafer 2015-01-30 996 kfree(event_descs);
5c5cd7b502595f Cody P Schafer 2015-01-30 997 e_event_attrs:
5c5cd7b502595f Cody P Schafer 2015-01-30 998 kfree(events);
5c5cd7b502595f Cody P Schafer 2015-01-30 999 e_event_data:
5c5cd7b502595f Cody P Schafer 2015-01-30 1000 vfree(event_data);
5c5cd7b502595f Cody P Schafer 2015-01-30 1001 e_free:
5c5cd7b502595f Cody P Schafer 2015-01-30 1002 kmem_cache_free(hv_page_cache, page);
5c5cd7b502595f Cody P Schafer 2015-01-30 1003 e_out:
5c5cd7b502595f Cody P Schafer 2015-01-30 1004 *events_ = NULL;
5c5cd7b502595f Cody P Schafer 2015-01-30 1005 *event_descs_ = NULL;
5c5cd7b502595f Cody P Schafer 2015-01-30 1006 *event_long_descs_ = NULL;
7debc970ae7a55 Li Zhong 2015-04-13 1007 return ret;
5c5cd7b502595f Cody P Schafer 2015-01-30 1008 }
5c5cd7b502595f Cody P Schafer 2015-01-30 1009 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Robin Murphy
maintainerPATCH 5/10 drivers/perf: Use PERF_PMU_CAP_NO_SAMPLING consistently
In reply to Robin MurphyOur system PMUs fundamentally cannot support the current notion of sampling events, so now that the core capability has been clarified, apply it consistently and purge yet more boilerplate.
--- drivers/perf/alibaba_uncore_drw_pmu.c | 6 +----- drivers/perf/amlogic/meson_ddr_pmu_core.c | 3 ++- drivers/perf/arm-cci.c | 3 ++- drivers/perf/arm-ccn.c | 12 +----------- drivers/perf/arm-cmn.c | 3 ++- drivers/perf/arm_cspmu/arm_cspmu.c | 17 ++++------------- drivers/perf/arm_dmc620_pmu.c | 4 ++-- drivers/perf/arm_dsu_pmu.c | 12 +----------- drivers/perf/arm_smmuv3_pmu.c | 6 +----- drivers/perf/cxl_pmu.c | 3 ++- drivers/perf/dwc_pcie_pmu.c | 5 +---- drivers/perf/fsl_imx8_ddr_perf.c | 3 ++- drivers/perf/fsl_imx9_ddr_perf.c | 3 ++- drivers/perf/hisilicon/hisi_pcie_pmu.c | 4 ++-- drivers/perf/hisilicon/hisi_uncore_pmu.c | 3 ++- drivers/perf/hisilicon/hns3_pmu.c | 4 ++-- drivers/perf/marvell_cn10k_ddr_pmu.c | 6 +----- drivers/perf/qcom_l2_pmu.c | 7 +------ drivers/perf/qcom_l3_pmu.c | 7 +------ drivers/perf/thunderx2_pmu.c | 4 ++-- drivers/perf/xgene_pmu.c | 4 ++-- 21 files changed, 36 insertions(+), 83 deletions(-)
drivers/perf/alibaba_uncore_drw_pmu.c +1 -5
@@ -535,11 +535,6 @@ static int ali_drw_pmu_event_init(struct perf_event *event)struct perf_event *sibling;struct device *dev = drw_pmu->pmu.dev; -if (is_sampling_event (event)) { -dev_err (dev,"Sampling not supported!\n" ); -return -EOPNOTSUPP ; - } -if (event->attach_state &PERF_ATTACH_TASK ) {dev_err (dev,"Per-task counter cannot allocate!\n" );return -EOPNOTSUPP ;
@@ -707,6 +702,7 @@ static int ali_drw_pmu_probe(struct platform_device *pdev) .read = ali_drw_pmu_read, .attr_groups = ali_drw_pmu_attr_groups, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/amlogic/meson_ddr_pmu_core.c +2 -1
@@ -121,7 +121,7 @@ static int meson_ddr_perf_event_init(struct perf_event *event)u64 config1 = event->attr.config1;u64 config2 = event->attr.config2; -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;if (event->cpu <0 )
@@ -490,6 +490,7 @@ int meson_ddr_pmu_create(struct platform_device *pdev) .pmu = { .module = THIS_MODULE, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups,
drivers/perf/arm-cci.c +2 -1
@@ -1313,7 +1313,7 @@ static int cci_pmu_event_init(struct perf_event *event)int err =0 ;/* Shared by all CPUs, no meaningful state to sample */ -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;/*
@@ -1414,6 +1414,7 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev) .read = pmu_read, .attr_groups = pmu_attr_groups, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/arm-ccn.c +1 -11
@@ -713,7 +713,6 @@ static void arm_ccn_pmu_event_release(struct perf_event *event)static int arm_ccn_pmu_event_init (struct perf_event *event) {struct arm_ccn *ccn; -struct hw_perf_event *hw = &event->hw;u32 node_xp, type, event_id;int valid;int i;
@@ -721,16 +720,6 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) ccn =pmu_to_arm_ccn (event->pmu); -if (hw->sample_period) { -dev_dbg (ccn->dev,"Sampling not supported!\n" ); -return -EOPNOTSUPP ; - } - -if (has_branch_stack (event)) { -dev_dbg (ccn->dev,"Can't exclude execution levels!\n" ); -return -EINVAL ; - } -if (event->cpu <0 ) {dev_dbg (ccn->dev,"Can't provide per-task data!\n" );return -EOPNOTSUPP ;
@@ -1273,6 +1262,7 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn) .pmu_enable = arm_ccn_pmu_enable, .pmu_disable = arm_ccn_pmu_disable, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/arm-cmn.c +2 -1
@@ -1696,7 +1696,7 @@ static int arm_cmn_event_init(struct perf_event *event)bool bynodeid;u16 nodeid, eventid; -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EINVAL ; event->cpu = cmn->cpu;
@@ -2469,6 +2469,7 @@ static int arm_cmn_probe(struct platform_device *pdev) .module = THIS_MODULE, .attr_groups = arm_cmn_attr_groups, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .pmu_enable = arm_cmn_pmu_enable,
drivers/perf/arm_cspmu/arm_cspmu.c +4 -13
@@ -680,12 +680,6 @@ static int arm_cspmu_event_init(struct perf_event *event)* Following other "uncore" PMUs, we do not support sampling mode or * attach to a task (per-process mode). */ -if (is_sampling_event (event)) { -dev_dbg (cspmu->pmu.dev, -"Can't support sampling events\n" ); -return -EOPNOTSUPP ; - } -if (event->cpu <0 || event->attach_state &PERF_ATTACH_TASK ) {dev_dbg (cspmu->pmu.dev,"Can't support per-task counters\n" );
@@ -1171,7 +1165,7 @@ static int arm_cspmu_get_cpus(struct arm_cspmu *cspmu)static int arm_cspmu_register_pmu (struct arm_cspmu *cspmu) { -int ret, capabilities; +int ret;struct attribute_group **attr_groups; attr_groups =arm_cspmu_alloc_attr_group (cspmu);
@@ -1183,11 +1177,6 @@ static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu)if (ret)return ret; - capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_COMMON_EVENTS ; -if (cspmu->irq ==0 ) - capabilities |=PERF_PMU_CAP_NO_SAMPLING ; - cspmu->pmu = (struct pmu ){ .task_ctx_nr = perf_invalid_context, .module = cspmu->impl.module,
@@ -1200,7 +1189,9 @@ static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu) .stop = arm_cspmu_stop, .read = arm_cspmu_read, .attr_groups = (const struct attribute_group **)attr_groups, - .capabilities = capabilities, + .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | + PERF_PMU_CAP_NO_COMMON_EVENTS, };/* Hardware counter init */
drivers/perf/arm_dmc620_pmu.c +2 -2
@@ -519,8 +519,7 @@ static int dmc620_pmu_event_init(struct perf_event *event)* DMC 620 PMUs are shared across all cpus and cannot * support task bound and sampling events. */ -if (is_sampling_event (event) || - event->attach_state &PERF_ATTACH_TASK ) { +if (event->attach_state &PERF_ATTACH_TASK ) {dev_dbg (dmc620_pmu->pmu.dev,"Can't support per-task counters\n" );return -EOPNOTSUPP ;
@@ -671,6 +670,7 @@ static int dmc620_pmu_device_probe(struct platform_device *pdev) dmc620_pmu->pmu = (struct pmu ) { .module =THIS_MODULE , .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING |PERF_PMU_CAP_NO_COMMON_EVENTS , .task_ctx_nr = perf_invalid_context, .event_init = dmc620_pmu_event_init,
drivers/perf/arm_dsu_pmu.c +1 -11
@@ -544,23 +544,12 @@ static int dsu_pmu_event_init(struct perf_event *event) {struct dsu_pmu *dsu_pmu =to_dsu_pmu (event->pmu); -/* We don't support sampling */ -if (is_sampling_event (event)) { -dev_dbg (dsu_pmu->pmu.dev,"Can't support sampling events\n" ); -return -EOPNOTSUPP ; - } -/* We cannot support task bound events */ if (event->cpu <0 || event->attach_state &PERF_ATTACH_TASK ) {dev_dbg (dsu_pmu->pmu.dev,"Can't support per-task counters\n" );return -EINVAL ; } -if (has_branch_stack (event)) { -dev_dbg (dsu_pmu->pmu.dev,"Can't support filtering\n" ); -return -EINVAL ; - } -if (!cpumask_test_cpu (event->cpu, &dsu_pmu->associated_cpus)) {dev_dbg (dsu_pmu->pmu.dev,"Requested cpu is not associated with the DSU\n" );
@@ -760,6 +749,7 @@ static int dsu_pmu_device_probe(struct platform_device *pdev) .attr_groups = dsu_pmu_attr_groups, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/arm_smmuv3_pmu.c +1 -5
@@ -401,11 +401,6 @@ static int smmu_pmu_event_init(struct perf_event *event)int group_num_events =1 ;u16 event_id; -if (hwc->sample_period) { -dev_dbg (dev,"Sampling not supported\n" ); -return -EOPNOTSUPP ; - } -if (event->cpu <0 ) {dev_dbg (dev,"Per-task mode not supported\n" );return -EOPNOTSUPP ;
@@ -868,6 +863,7 @@ static int smmu_pmu_probe(struct platform_device *pdev) .read = smmu_pmu_event_read, .attr_groups = smmu_pmu_attr_grps, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/cxl_pmu.c +2 -1
@@ -571,7 +571,7 @@ static int cxl_pmu_event_init(struct perf_event *event)struct cxl_pmu_info *info =pmu_to_cxl_pmu_info (event->pmu);int rc; -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;/* TODO: Validation of any filter */
@@ -867,6 +867,7 @@ static int cxl_pmu_probe(struct device *dev) .task_ctx_nr = perf_invalid_context, .attr_groups = cxl_pmu_attr_groups, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/dwc_pcie_pmu.c +1 -4
@@ -366,10 +366,6 @@ static int dwc_pcie_pmu_event_init(struct perf_event *event)struct perf_event *sibling;u32 lane; -/* We don't support sampling */ -if (is_sampling_event (event)) -return -EINVAL ; -/* We cannot support task bound events */ if (event->cpu <0 || event->attach_state &PERF_ATTACH_TASK )return -EINVAL ;
@@ -634,6 +630,7 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev) .module = THIS_MODULE, .attr_groups = dwc_pcie_attr_groups, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, .task_ctx_nr = perf_invalid_context, .event_init = dwc_pcie_pmu_event_init,
drivers/perf/fsl_imx8_ddr_perf.c +2 -1
@@ -398,7 +398,7 @@ static int ddr_perf_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct perf_event *sibling; -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;if (event->cpu <0 ) {
@@ -649,6 +649,7 @@ static int ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, .pmu = (struct pmu) { .module =THIS_MODULE , .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING |PERF_PMU_CAP_NO_COMMON_EVENTS , .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups,
drivers/perf/fsl_imx9_ddr_perf.c +2 -1
@@ -416,7 +416,7 @@ static int ddr_perf_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct perf_event *sibling; -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;if (event->cpu <0 ) {
@@ -526,6 +526,7 @@ static void ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, .pmu = (struct pmu) { .module =THIS_MODULE , .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING |PERF_PMU_CAP_NO_COMMON_EVENTS , .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups,
drivers/perf/hisilicon/hisi_pcie_pmu.c +2 -2
@@ -358,8 +358,7 @@ static int hisi_pcie_pmu_event_init(struct perf_event *event)else hwc->event_base =HISI_PCIE_CNT ; -/* Sampling is not supported. */ -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;if (!hisi_pcie_pmu_valid_filter (event, pcie_pmu))
@@ -810,6 +809,7 @@ static int hisi_pcie_alloc_pmu(struct pci_dev *pdev, struct hisi_pcie_pmu *pcie_ .task_ctx_nr = perf_invalid_context, .attr_groups = hisi_pcie_pmu_attr_groups, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/hisilicon/hisi_uncore_pmu.c +2 -1
@@ -191,7 +191,7 @@ int hisi_uncore_pmu_event_init(struct perf_event *event)* shared by all CPU cores in a CPU die(SCCL). Also we * do not support attach to a task(per-process mode) */ -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ;/*
@@ -546,6 +546,7 @@ void hisi_pmu_init(struct hisi_pmu *hisi_pmu, struct module *module) pmu->read = hisi_uncore_pmu_read; pmu->attr_groups = hisi_pmu->pmu_events.attr_groups; pmu->capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING |PERF_PMU_CAP_NO_COMMON_EVENTS ; }EXPORT_SYMBOL_GPL (hisi_pmu_init);
drivers/perf/hisilicon/hns3_pmu.c +2 -2
@@ -1236,8 +1236,7 @@ static int hns3_pmu_event_init(struct perf_event *event)int idx;int ret; -/* Sampling is not supported */ -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EOPNOTSUPP ; event->cpu = hns3_pmu->on_cpu;
@@ -1427,6 +1426,7 @@ static int hns3_pmu_alloc_pmu(struct pci_dev *pdev, struct hns3_pmu *hns3_pmu) .task_ctx_nr = perf_invalid_context, .attr_groups = hns3_pmu_attr_groups, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/marvell_cn10k_ddr_pmu.c +1 -5
@@ -325,11 +325,6 @@ static int cn10k_ddr_perf_event_init(struct perf_event *event)struct cn10k_ddr_pmu *pmu =to_cn10k_ddr_pmu (event->pmu);struct hw_perf_event *hwc = &event->hw; -if (is_sampling_event (event)) { -dev_info (pmu->dev,"Sampling not supported!\n" ); -return -EOPNOTSUPP ; - } -if (event->cpu <0 ) {dev_warn (pmu->dev,"Can't provide per-task data!\n" );return -EOPNOTSUPP ;
@@ -654,6 +649,7 @@ static int cn10k_ddr_perf_probe(struct platform_device *pdev) ddr_pmu->pmu = (struct pmu ) { .module =THIS_MODULE , .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING |PERF_PMU_CAP_NO_COMMON_EVENTS , .task_ctx_nr = perf_invalid_context, .attr_groups = cn10k_attr_groups,
drivers/perf/qcom_l2_pmu.c +1 -6
@@ -442,12 +442,6 @@ static int l2_cache_event_init(struct perf_event *event)struct perf_event *sibling;struct l2cache_pmu *l2cache_pmu =to_l2cache_pmu (event->pmu); -if (hwc->sample_period) { -dev_dbg_ratelimited (&l2cache_pmu->pdev->dev, -"Sampling not supported\n" ); -return -EOPNOTSUPP ; - } -if (event->cpu <0 ) {dev_dbg_ratelimited (&l2cache_pmu->pdev->dev,"Per-task mode not supported\n" );
@@ -910,6 +904,7 @@ static int l2_cache_pmu_probe(struct platform_device *pdev) .read = l2_cache_event_read, .attr_groups = l2_cache_pmu_attr_grps, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/qcom_l3_pmu.c +1 -6
@@ -480,12 +480,6 @@ static int qcom_l3_cache__event_init(struct perf_event *event)struct l3cache_pmu *l3pmu =to_l3cache_pmu (event->pmu);struct hw_perf_event *hwc = &event->hw; -/* -* Sampling not supported since these events are not core-attributable. -*/ -if (hwc->sample_period) -return -EINVAL ; -/* * Task mode not available, we run the counters as socket counters, * not attributable to any CPU and therefore cannot attribute per-task.
@@ -755,6 +749,7 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev) .attr_groups = qcom_l3_cache_pmu_attr_grps, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/thunderx2_pmu.c +2 -2
@@ -577,9 +577,8 @@ static int tx2_uncore_event_init(struct perf_event *event)/* * SOC PMU counters are shared across all cores. * Therefore, it does not support per-process mode. -* Also, it does not support event sampling mode. */ -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EINVAL ;if (event->cpu <0 )
@@ -734,6 +733,7 @@ static int tx2_uncore_pmu_register( .stop = tx2_uncore_event_stop, .read = tx2_uncore_event_read, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
drivers/perf/xgene_pmu.c +2 -2
@@ -891,9 +891,8 @@ static int xgene_perf_event_init(struct perf_event *event)/* * SOC PMU counters are shared across all cores. * Therefore, it does not support per-process mode. -* Also, it does not support event sampling mode. */ -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) +if (event->attach_state &PERF_ATTACH_TASK )return -EINVAL ;if (event->cpu <0 )
@@ -1109,6 +1108,7 @@ static int xgene_init_perf(struct xgene_pmu_dev *pmu_dev, char *name) .stop = xgene_perf_stop, .read = xgene_perf_read, .capabilities =PERF_PMU_CAP_NO_EXCLUDE | +PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_COMMON_EVENTS, };
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
Re: [PATCH 05/10] drivers/perf: Use PERF_PMU_CAP_NO_SAMPLING consistently
Quoted 29 lines · Robin Murphy
Our system PMUs fundamentally cannot support the current notion of sampling events, so now that the core capability has been clarified, apply it consistently and purge yet more boilerplate.
Signed-off-by Robin Murphy <[email protected]>--- drivers/perf/alibaba_uncore_drw_pmu.c | 6 +----- drivers/perf/amlogic/meson_ddr_pmu_core.c | 3 ++- drivers/perf/arm-cci.c | 3 ++- drivers/perf/arm-ccn.c | 12 +----------- drivers/perf/arm-cmn.c | 3 ++- drivers/perf/arm_cspmu/arm_cspmu.c | 17 ++++------------- drivers/perf/arm_dmc620_pmu.c | 4 ++-- drivers/perf/arm_dsu_pmu.c | 12 +----------- drivers/perf/arm_smmuv3_pmu.c | 6 +----- drivers/perf/cxl_pmu.c | 3 ++- drivers/perf/dwc_pcie_pmu.c | 5 +---- drivers/perf/fsl_imx8_ddr_perf.c | 3 ++- drivers/perf/fsl_imx9_ddr_perf.c | 3 ++- drivers/perf/hisilicon/hisi_pcie_pmu.c | 4 ++-- drivers/perf/hisilicon/hisi_uncore_pmu.c | 3 ++- drivers/perf/hisilicon/hns3_pmu.c | 4 ++-- drivers/perf/marvell_cn10k_ddr_pmu.c | 6 +----- drivers/perf/qcom_l2_pmu.c | 7 +------ drivers/perf/qcom_l3_pmu.c | 7 +------ drivers/perf/thunderx2_pmu.c | 4 ++-- drivers/perf/xgene_pmu.c | 4 ++-- 21 files changed, 36 insertions(+), 83 deletions(-)
[...]
Quoted 27 lines
drivers/perf/arm-ccn.c +0
-11@@ -713,7 +713,6 @@ static void arm_ccn_pmu_event_release(struct perf_event *event)static int arm_ccn_pmu_event_init (struct perf_event *event) {struct arm_ccn *ccn; -struct hw_perf_event *hw = &event->hw;u32 node_xp, type, event_id;int valid;int i;@@ -721,16 +720,6 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) ccn =pmu_to_arm_ccn (event->pmu); -if (hw->sample_period) { -dev_dbg (ccn->dev,"Sampling not supported!\n" ); -return -EOPNOTSUPP ; - } - -if (has_branch_stack (event)) { -dev_dbg (ccn->dev,"Can't exclude execution levels!\n" ); -return -EINVAL ; - } -
[...]
Quoted 15 lines
drivers/perf/arm_dsu_pmu.c +0
-6@@ -544,23 +544,12 @@ static int dsu_pmu_event_init(struct perf_event *event) {struct dsu_pmu *dsu_pmu =to_dsu_pmu (event->pmu); -/* We don't support sampling */ -if (is_sampling_event (event)) { -dev_dbg (dsu_pmu->pmu.dev,"Can't support sampling events\n" ); -return -EOPNOTSUPP ; - } -/* We cannot support task bound events */
drivers/perf/arm_dsu_pmu.c static int dsu_pmu_event_init(struct perf_event *event) · line 563
Quoted 10 lines
drivers/perf/arm_dsu_pmu.c +0
-5if (event->cpu <0 || event->attach_state &PERF_ATTACH_TASK ) {dev_dbg (dsu_pmu->pmu.dev,"Can't support per-task counters\n" );return -EINVAL ; } -if (has_branch_stack (event)) { -dev_dbg (dsu_pmu->pmu.dev,"Can't support filtering\n" ); -return -EINVAL ; - } -
I'm assuming that this and the other has_branch_stack() check were removed because branch stacks don't actually do anything unless sampling is enabled?
It's a small difference that there is now no error message if you ask for branch stacks, but it wouldn't have done anything anyway? I suppose this error message was also not applied very consistently across the different devices.
James
Robin Murphy
maintainerRe: [PATCH 05/10] drivers/perf: Use PERF_PMU_CAP_NO_SAMPLING consistently
Quoted 93 lines · James Clark
Quoted 29 lines · Robin Murphy
Our system PMUs fundamentally cannot support the current notion of sampling events, so now that the core capability has been clarified, apply it consistently and purge yet more boilerplate.
Signed-off-by Robin Murphy <[email protected]>--- drivers/perf/alibaba_uncore_drw_pmu.c | 6 +----- drivers/perf/amlogic/meson_ddr_pmu_core.c | 3 ++- drivers/perf/arm-cci.c | 3 ++- drivers/perf/arm-ccn.c | 12 +----------- drivers/perf/arm-cmn.c | 3 ++- drivers/perf/arm_cspmu/arm_cspmu.c | 17 ++++------------- drivers/perf/arm_dmc620_pmu.c | 4 ++-- drivers/perf/arm_dsu_pmu.c | 12 +----------- drivers/perf/arm_smmuv3_pmu.c | 6 +----- drivers/perf/cxl_pmu.c | 3 ++- drivers/perf/dwc_pcie_pmu.c | 5 +---- drivers/perf/fsl_imx8_ddr_perf.c | 3 ++- drivers/perf/fsl_imx9_ddr_perf.c | 3 ++- drivers/perf/hisilicon/hisi_pcie_pmu.c | 4 ++-- drivers/perf/hisilicon/hisi_uncore_pmu.c | 3 ++- drivers/perf/hisilicon/hns3_pmu.c | 4 ++-- drivers/perf/marvell_cn10k_ddr_pmu.c | 6 +----- drivers/perf/qcom_l2_pmu.c | 7 +------ drivers/perf/qcom_l3_pmu.c | 7 +------ drivers/perf/thunderx2_pmu.c | 4 ++-- drivers/perf/xgene_pmu.c | 4 ++-- 21 files changed, 36 insertions(+), 83 deletions(-)[...]
Quoted 27 lines
drivers/perf/arm-ccn.c +0
-11@@ -713,7 +713,6 @@ static void arm_ccn_pmu_event_release(struct perf_event *event)static int arm_ccn_pmu_event_init (struct perf_event *event) {struct arm_ccn *ccn; -struct hw_perf_event *hw = &event->hw;u32 node_xp, type, event_id;int valid;int i;@@ -721,16 +720,6 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) ccn =pmu_to_arm_ccn (event->pmu); -if (hw->sample_period) { -dev_dbg (ccn->dev,"Sampling not supported!\n" ); -return -EOPNOTSUPP ; - } - -if (has_branch_stack (event)) { -dev_dbg (ccn->dev,"Can't exclude execution levels!\n" ); -return -EINVAL ; - } -[...]
Quoted 15 lines
drivers/perf/arm_dsu_pmu.c +0
-6@@ -544,23 +544,12 @@ static int dsu_pmu_event_init(struct perf_event *event) {struct dsu_pmu *dsu_pmu =to_dsu_pmu (event->pmu); -/* We don't support sampling */ -if (is_sampling_event (event)) { -dev_dbg (dsu_pmu->pmu.dev,"Can't support sampling events\n" ); -return -EOPNOTSUPP ; - } -/* We cannot support task bound events */ drivers/perf/arm_dsu_pmu.c static int dsu_pmu_event_init(struct perf_event *event) · line 563
Quoted 10 lines
drivers/perf/arm_dsu_pmu.c +0
-5if (event->cpu <0 || event->attach_state &PERF_ATTACH_TASK ) {dev_dbg (dsu_pmu->pmu.dev,"Can't support per-task counters\n" );return -EINVAL ; } -if (has_branch_stack (event)) { -dev_dbg (dsu_pmu->pmu.dev,"Can't support filtering\n" ); -return -EINVAL ; - } -I'm assuming that this and the other
has_branch_stack()check were removed because branch stacks don't actually do anything unless sampling is enabled?
Quoted 4 lines
It's a small difference that there is now no error message if you ask for branch stacks, but it wouldn't have done anything anyway? I suppose this error message was also not applied very consistently across the different devices.
Right - the rarity of these checks, plus the fact that in both cases here they give a nonsensical debug message that has nothing whatsoever to do with the actual failing condition, seems to make it clear that they aren't realistically useful.
In general I don't see any good reason for a non-sampling event to be picky about the exact type of samples it isn't collecting.
Thanks,
Robin.
Robin Murphy
maintainerPATCH 6/10 drivers/perf: Clean up redundant per-task checks
In reply to Robin MurphyIt turns out that a while back, perf_event_alloc() grew the ability to properly refuse all per-task and cgroup events on behalf of uncore/system PMUs using perf_invalid_context, so that's a whole load more inconsistent boilerplate which can also go from our drivers. This includes a couple more cases of drivers foolishly checking event->cpu *after* overriding it with their own (necessarily valid) CPU...
--- drivers/perf/alibaba_uncore_drw_pmu.c | 5 ----- drivers/perf/amlogic/meson_ddr_pmu_core.c | 6 ------ drivers/perf/arm-cci.c | 6 ------ drivers/perf/arm-ccn.c | 4 ---- drivers/perf/arm-cmn.c | 5 ----- drivers/perf/arm_cspmu/arm_cspmu.c | 10 ---------- drivers/perf/arm_dmc620_pmu.c | 12 ------------ drivers/perf/arm_dsu_pmu.c | 6 ------ drivers/perf/arm_smmuv3_pmu.c | 5 ----- drivers/perf/cxl_pmu.c | 2 -- drivers/perf/dwc_pcie_pmu.c | 4 ---- drivers/perf/fsl_imx8_ddr_perf.c | 8 -------- drivers/perf/fsl_imx9_ddr_perf.c | 8 -------- drivers/perf/hisilicon/hisi_pcie_pmu.c | 3 --- drivers/perf/hisilicon/hisi_uncore_pmu.c | 15 --------------- drivers/perf/hisilicon/hns3_pmu.c | 3 --- drivers/perf/marvell_cn10k_ddr_pmu.c | 5 ----- drivers/perf/qcom_l2_pmu.c | 6 ------ drivers/perf/qcom_l3_pmu.c | 7 ------- drivers/perf/thunderx2_pmu.c | 10 ---------- drivers/perf/xgene_pmu.c | 9 --------- 21 files changed, 139 deletions(-)
drivers/perf/alibaba_uncore_drw_pmu.c +0 -5
@@ -535,11 +535,6 @@ static int ali_drw_pmu_event_init(struct perf_event *event)struct perf_event *sibling;struct device *dev = drw_pmu->pmu.dev; -if (event->attach_state &PERF_ATTACH_TASK ) { -dev_err (dev,"Per-task counter cannot allocate!\n" ); -return -EOPNOTSUPP ; - } - event->cpu = drw_pmu->irq->cpu; if (event->group_leader != event &&
drivers/perf/amlogic/meson_ddr_pmu_core.c +0 -6
@@ -121,12 +121,6 @@ static int meson_ddr_perf_event_init(struct perf_event *event)u64 config1 = event->attr.config1;u64 config2 = event->attr.config2; -if (event->attach_state &PERF_ATTACH_TASK ) -return -EOPNOTSUPP ; - -if (event->cpu <0 ) -return -EOPNOTSUPP ; -/* check if the number of parameters is too much */ if (event->attr.config !=ALL_CHAN_COUNTER_ID &&hweight64 (config1) +hweight64 (config2) >MAX_AXI_PORTS_OF_CHANNEL )
drivers/perf/arm-cci.c +0 -6
@@ -1312,10 +1312,6 @@ static int cci_pmu_event_init(struct perf_event *event)atomic_t *active_events = &cci_pmu->active_events;int err =0 ; -/* Shared by all CPUs, no meaningful state to sample */ -if (event->attach_state &PERF_ATTACH_TASK ) -return -EOPNOTSUPP ; -/* * Following the example set by other "uncore" PMUs, we accept any CPU * and rewrite its affinity dynamically rather than having perf core
@@ -1325,8 +1321,6 @@ static int cci_pmu_event_init(struct perf_event *event)* the event being installed into its context, so the PMU's CPU can't * change under our feet. */ -if (event->cpu <0 ) -return -EINVAL ; event->cpu = cci_pmu->cpu; event->destroy = hw_perf_event_destroy;
drivers/perf/arm-ccn.c +0 -4
@@ -720,10 +720,6 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) ccn =pmu_to_arm_ccn (event->pmu); -if (event->cpu <0 ) { -dev_dbg (ccn->dev,"Can't provide per-task data!\n" ); -return -EOPNOTSUPP ; - }/* * Many perf core operations (eg. events rotation) operate on a * single CPU context. This is obvious for CPU PMUs, where one
drivers/perf/arm-cmn.c +0 -5
@@ -1696,12 +1696,7 @@ static int arm_cmn_event_init(struct perf_event *event)bool bynodeid;u16 nodeid, eventid; -if (event->attach_state &PERF_ATTACH_TASK ) -return -EINVAL ; - event->cpu = cmn->cpu; -if (event->cpu <0 ) -return -EINVAL ; type =CMN_EVENT_TYPE (event);/* DTC events (i.e. cycles) already have everything they need */
drivers/perf/arm_cspmu/arm_cspmu.c +0 -10
@@ -676,16 +676,6 @@ static int arm_cspmu_event_init(struct perf_event *event) cspmu =to_arm_cspmu (event->pmu); -/* -* Following other "uncore" PMUs, we do not support sampling mode or -* attach to a task (per-process mode). -*/ -if (event->cpu <0 || event->attach_state &PERF_ATTACH_TASK ) { -dev_dbg (cspmu->pmu.dev, -"Can't support per-task counters\n" ); -return -EINVAL ; - } -/* * Make sure the CPU assignment is on one of the CPUs associated with * this PMU.
drivers/perf/arm_dmc620_pmu.c +0 -12
@@ -515,16 +515,6 @@ static int dmc620_pmu_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct perf_event *sibling; -/* -* DMC 620 PMUs are shared across all cpus and cannot -* support task bound and sampling events. -*/ -if (event->attach_state &PERF_ATTACH_TASK ) { -dev_dbg (dmc620_pmu->pmu.dev, -"Can't support per-task counters\n" ); -return -EOPNOTSUPP ; - } -/* * Many perf core operations (eg. events rotation) operate on a * single CPU context. This is obvious for CPU PMUs, where one
@@ -535,8 +525,6 @@ static int dmc620_pmu_event_init(struct perf_event *event)* processor. */ event->cpu = dmc620_pmu->irq->cpu; -if (event->cpu <0 ) -return -EINVAL ;/* * We can't atomically disable all HW counters so only one event allowed,
drivers/perf/arm_dsu_pmu.c +0 -6
@@ -544,12 +544,6 @@ static int dsu_pmu_event_init(struct perf_event *event) {struct dsu_pmu *dsu_pmu =to_dsu_pmu (event->pmu); -/* We cannot support task bound events */ -if (event->cpu <0 || event->attach_state &PERF_ATTACH_TASK ) { -dev_dbg (dsu_pmu->pmu.dev,"Can't support per-task counters\n" ); -return -EINVAL ; - } -if (!cpumask_test_cpu (event->cpu, &dsu_pmu->associated_cpus)) {dev_dbg (dsu_pmu->pmu.dev,"Requested cpu is not associated with the DSU\n" );
drivers/perf/arm_smmuv3_pmu.c +0 -5
@@ -401,11 +401,6 @@ static int smmu_pmu_event_init(struct perf_event *event)int group_num_events =1 ;u16 event_id; -if (event->cpu <0 ) { -dev_dbg (dev,"Per-task mode not supported\n" ); -return -EOPNOTSUPP ; - } -/* Verify specified event is supported on this PMU */ event_id =get_event (event); if (event_id < SMMU_PMCG_ARCH_MAX_EVENTS &&
drivers/perf/cxl_pmu.c +0 -2
@@ -571,8 +571,6 @@ static int cxl_pmu_event_init(struct perf_event *event)struct cxl_pmu_info *info =pmu_to_cxl_pmu_info (event->pmu);int rc; -if (event->attach_state &PERF_ATTACH_TASK ) -return -EOPNOTSUPP ;/* TODO: Validation of any filter */ /*
drivers/perf/dwc_pcie_pmu.c +0 -4
@@ -366,10 +366,6 @@ static int dwc_pcie_pmu_event_init(struct perf_event *event)struct perf_event *sibling;u32 lane; -/* We cannot support task bound events */ -if (event->cpu <0 || event->attach_state &PERF_ATTACH_TASK ) -return -EINVAL ; -if (event->group_leader != event && !is_software_event (event->group_leader))return -EINVAL ;
drivers/perf/fsl_imx8_ddr_perf.c +0 -8
@@ -398,14 +398,6 @@ static int ddr_perf_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct perf_event *sibling; -if (event->attach_state &PERF_ATTACH_TASK ) -return -EOPNOTSUPP ; - -if (event->cpu <0 ) { -dev_warn (pmu->dev,"Can't provide per-task data!\n" ); -return -EOPNOTSUPP ; - } -/* * We must NOT create groups containing mixed PMUs, although software * events are acceptable (for example to create a CCN group
drivers/perf/fsl_imx9_ddr_perf.c +0 -8
@@ -416,14 +416,6 @@ static int ddr_perf_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct perf_event *sibling; -if (event->attach_state &PERF_ATTACH_TASK ) -return -EOPNOTSUPP ; - -if (event->cpu <0 ) { -dev_warn (pmu->dev,"Can't provide per-task data!\n" ); -return -EOPNOTSUPP ; - } -/* * We must NOT create groups containing mixed PMUs, although software * events are acceptable (for example to create a CCN group
drivers/perf/hisilicon/hisi_pcie_pmu.c +0 -3
@@ -358,9 +358,6 @@ static int hisi_pcie_pmu_event_init(struct perf_event *event)else hwc->event_base =HISI_PCIE_CNT ; -if (event->attach_state &PERF_ATTACH_TASK ) -return -EOPNOTSUPP ; -if (!hisi_pcie_pmu_valid_filter (event, pcie_pmu))return -EINVAL ;
drivers/perf/hisilicon/hisi_uncore_pmu.c +0 -15
@@ -186,21 +186,6 @@ int hisi_uncore_pmu_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct hisi_pmu *hisi_pmu; -/* -* We do not support sampling as the counters are all -* shared by all CPU cores in a CPU die(SCCL). Also we -* do not support attach to a task(per-process mode) -*/ -if (event->attach_state &PERF_ATTACH_TASK ) -return -EOPNOTSUPP ; - -/* -* The uncore counters not specific to any CPU, so cannot -* support per-task -*/ -if (event->cpu <0 ) -return -EINVAL ; -/* * Validate if the events in group does not exceed the * available counters in hardware.
drivers/perf/hisilicon/hns3_pmu.c +0 -3
@@ -1236,9 +1236,6 @@ static int hns3_pmu_event_init(struct perf_event *event)int idx;int ret; -if (event->attach_state &PERF_ATTACH_TASK ) -return -EOPNOTSUPP ; - event->cpu = hns3_pmu->on_cpu; idx =hns3_pmu_get_event_idx (hns3_pmu);
drivers/perf/marvell_cn10k_ddr_pmu.c +0 -5
@@ -325,11 +325,6 @@ static int cn10k_ddr_perf_event_init(struct perf_event *event)struct cn10k_ddr_pmu *pmu =to_cn10k_ddr_pmu (event->pmu);struct hw_perf_event *hwc = &event->hw; -if (event->cpu <0 ) { -dev_warn (pmu->dev,"Can't provide per-task data!\n" ); -return -EOPNOTSUPP ; - } -/* We must NOT create groups containing mixed PMUs */ if (event->group_leader->pmu != event->pmu && !is_software_event (event->group_leader))
drivers/perf/qcom_l2_pmu.c +0 -6
@@ -442,12 +442,6 @@ static int l2_cache_event_init(struct perf_event *event)struct perf_event *sibling;struct l2cache_pmu *l2cache_pmu =to_l2cache_pmu (event->pmu); -if (event->cpu <0 ) { -dev_dbg_ratelimited (&l2cache_pmu->pdev->dev, -"Per-task mode not supported\n" ); -return -EOPNOTSUPP ; - } -if (((L2_EVT_GROUP (event->attr.config) >L2_EVT_GROUP_MAX ) || ((event->attr.config & ~L2_EVT_MASK ) !=0 )) && (event->attr.config !=L2CYCLE_CTR_RAW_CODE )) {
drivers/perf/qcom_l3_pmu.c +0 -7
@@ -480,13 +480,6 @@ static int qcom_l3_cache__event_init(struct perf_event *event)struct l3cache_pmu *l3pmu =to_l3cache_pmu (event->pmu);struct hw_perf_event *hwc = &event->hw; -/* -* Task mode not available, we run the counters as socket counters, -* not attributable to any CPU and therefore cannot attribute per-task. -*/ -if (event->cpu <0 ) -return -EINVAL ; -/* Validate the group */ if (!qcom_l3_cache__validate_event_group (event))return -EINVAL ;
drivers/perf/thunderx2_pmu.c +0 -10
@@ -574,16 +574,6 @@ static int tx2_uncore_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;struct tx2_uncore_pmu *tx2_pmu; -/* -* SOC PMU counters are shared across all cores. -* Therefore, it does not support per-process mode. -*/ -if (event->attach_state &PERF_ATTACH_TASK ) -return -EINVAL ; - -if (event->cpu <0 ) -return -EINVAL ; - tx2_pmu =pmu_to_tx2_pmu (event->pmu);if (tx2_pmu->cpu >= nr_cpu_ids)return -EINVAL ;
drivers/perf/xgene_pmu.c +0 -9
@@ -888,15 +888,6 @@ static int xgene_perf_event_init(struct perf_event *event)struct hw_perf_event *hw = &event->hw;struct perf_event *sibling; -/* -* SOC PMU counters are shared across all cores. -* Therefore, it does not support per-process mode. -*/ -if (event->attach_state &PERF_ATTACH_TASK ) -return -EINVAL ; - -if (event->cpu <0 ) -return -EINVAL ;/* * Many perf core operations (eg. events rotation) operate on a * single CPU context. This is obvious for CPU PMUs, where one
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
Robin Murphy
maintainerPATCH 7/10 perf: Define common uncore capabilities
In reply to Robin MurphyNearly all uncore/system PMUs share a common set of capbilities, so let's wrap those up in a single macro for ease of use.
--- include/linux/perf_event.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/perf_event.h +3 -0
@@ -293,6 +293,9 @@ struct perf_event_pmu_context;#define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100#define PERF_PMU_CAP_NO_COMMON_EVENTS 0x0200 +#define PERF_PMU_UNCORE_CAPS \ +(PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_COMMON_EVENTS) +struct perf_output_handle ;#define PMU_NULL_DEV ((void *)(~0UL))
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
Re: [PATCH 07/10] perf: Define common uncore capabilities
Quoted 13 lines · Robin Murphy
Nearly all uncore/system PMUs share a common set of capbilities, so let's wrap those up in a single macro for ease of use.
Signed-off-by Robin Murphy <[email protected]>--- include/linux/perf_event.h | 3 +++ 1 file changed, 3 insertions(+)include/linux/perf_event.h +0
-0
include/linux/perf_event.h struct perf_event_pmu_context; · line 298
Quoted 6 lines
include/linux/perf_event.h +3
-0@@ -293,6 +293,9 @@ struct perf_event_pmu_context;#define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100#define PERF_PMU_CAP_NO_COMMON_EVENTS 0x0200 +#define PERF_PMU_UNCORE_CAPS \ +(PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_COMMON_EVENTS) +
The most minor of nits: missing space before |. There is another one in another commit that triggers checkpatch but that line gets deleted anyway.
Quoted 3 lines
include/linux/perf_event.h +0
-0struct perf_output_handle ;#define PMU_NULL_DEV ((void *)(~0UL))
Robin Murphy
maintainerRe: [PATCH 07/10] perf: Define common uncore capabilities
Quoted 19 lines · James Clark
Quoted 16 lines · Robin Murphy
Nearly all uncore/system PMUs share a common set of capbilities, so let's wrap those up in a single macro for ease of use.
Signed-off-by Robin Murphy <[email protected]>--- include/linux/perf_event.h | 3 +++ 1 file changed, 3 insertions(+)include/linux/perf_event.h +0
-0@@ -293,6 +293,9 @@ struct perf_event_pmu_context;#define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100#define PERF_PMU_CAP_NO_COMMON_EVENTS 0x0200
Quoted 6 lines
include/linux/perf_event.h struct perf_event_pmu_context; · line 298
Quoted 3 lines
include/linux/perf_event.h +3
-0+#define PERF_PMU_UNCORE_CAPS \ +(PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_COMMON_EVENTS) +The most minor of nits: missing space before |. There is another one in another commit that triggers checkpatch but that line gets deleted anyway.
Bleh, thanks for the catch. And it seems that wasn't the only thing I inexplicably managed to mess up in the rename patch either... All fixed locally now.
Cheers,
Robin.
Quoted 4 lines
Quoted 4 lines
include/linux/perf_event.h +0
-0struct perf_output_handle ;#define PMU_NULL_DEV ((void *)(~0UL))
Robin Murphy
maintainerPATCH 8/10 drivers/perf: Use common uncore capabilities
In reply to Robin MurphyNow that we've ratified it, adopt PERF_PMU_UNCORE_CAPS.
--- drivers/perf/alibaba_uncore_drw_pmu.c | 4 +--- drivers/perf/amlogic/meson_ddr_pmu_core.c | 4 +--- drivers/perf/arm-cci.c | 4 +--- drivers/perf/arm-ccn.c | 4 +--- drivers/perf/arm-cmn.c | 4 +--- drivers/perf/arm_cspmu/arm_cspmu.c | 4 +--- drivers/perf/arm_dmc620_pmu.c | 4 +--- drivers/perf/arm_dsu_pmu.c | 4 +--- drivers/perf/arm_smmuv3_pmu.c | 4 +--- drivers/perf/cxl_pmu.c | 4 +--- drivers/perf/dwc_pcie_pmu.c | 4 +--- drivers/perf/fsl_imx8_ddr_perf.c | 4 +--- drivers/perf/fsl_imx9_ddr_perf.c | 4 +--- drivers/perf/hisilicon/hisi_pcie_pmu.c | 4 +--- drivers/perf/hisilicon/hisi_uncore_pmu.c | 4 +--- drivers/perf/hisilicon/hns3_pmu.c | 4 +--- drivers/perf/marvell_cn10k_ddr_pmu.c | 4 +--- drivers/perf/marvell_cn10k_tad_pmu.c | 4 +--- drivers/perf/qcom_l2_pmu.c | 4 +--- drivers/perf/qcom_l3_pmu.c | 4 +--- drivers/perf/thunderx2_pmu.c | 4 +--- drivers/perf/xgene_pmu.c | 4 +--- 22 files changed, 22 insertions(+), 66 deletions(-)
drivers/perf/alibaba_uncore_drw_pmu.c +1 -3
@@ -696,9 +696,7 @@ static int ali_drw_pmu_probe(struct platform_device *pdev) .stop = ali_drw_pmu_stop, .read = ali_drw_pmu_read, .attr_groups = ali_drw_pmu_attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; ret =perf_pmu_register (&drw_pmu->pmu, name,-1 );
drivers/perf/amlogic/meson_ddr_pmu_core.c +1 -3
@@ -483,9 +483,7 @@ int meson_ddr_pmu_create(struct platform_device *pdev) *pmu = (struct ddr_pmu ) { .pmu = { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | -PERF_PMU_CAP_NO_COMMON_EVENTS , + .capabilities =PERF_PMU_UNCORE_CAPS , .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = meson_ddr_perf_event_init,
drivers/perf/arm-cci.c +1 -3
@@ -1407,9 +1407,7 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev) .stop = cci_pmu_stop, .read = pmu_read, .attr_groups = pmu_attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; cci_pmu->plat_device = pdev;
drivers/perf/arm-ccn.c +1 -3
@@ -1257,9 +1257,7 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn) .read = arm_ccn_pmu_event_read, .pmu_enable = arm_ccn_pmu_enable, .pmu_disable = arm_ccn_pmu_disable, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, };/* No overflow interrupt? Have to use a timer instead. */
drivers/perf/arm-cmn.c +1 -3
@@ -2463,9 +2463,7 @@ static int arm_cmn_probe(struct platform_device *pdev) cmn->pmu = (struct pmu ) { .module =THIS_MODULE , .attr_groups = arm_cmn_attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | -PERF_PMU_CAP_NO_COMMON_EVENTS , + .capabilities =PERF_PMU_UNCORE_CAPS , .task_ctx_nr = perf_invalid_context, .pmu_enable = arm_cmn_pmu_enable, .pmu_disable = arm_cmn_pmu_disable,
drivers/perf/arm_cspmu/arm_cspmu.c +1 -3
@@ -1179,9 +1179,7 @@ static int arm_cspmu_register_pmu(struct arm_cspmu *cspmu) .stop = arm_cspmu_stop, .read = arm_cspmu_read, .attr_groups = (const struct attribute_group **)attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, };/* Hardware counter init */
drivers/perf/arm_dmc620_pmu.c +1 -3
@@ -657,9 +657,7 @@ static int dmc620_pmu_device_probe(struct platform_device *pdev) dmc620_pmu->pmu = (struct pmu ) { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | -PERF_PMU_CAP_NO_COMMON_EVENTS , + .capabilities =PERF_PMU_UNCORE_CAPS , .task_ctx_nr = perf_invalid_context, .event_init = dmc620_pmu_event_init, .add = dmc620_pmu_add,
drivers/perf/arm_dsu_pmu.c +1 -3
@@ -742,9 +742,7 @@ static int dsu_pmu_device_probe(struct platform_device *pdev) .read = dsu_pmu_read, .attr_groups = dsu_pmu_attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; rc =perf_pmu_register (&dsu_pmu->pmu, name,-1 );
drivers/perf/arm_smmuv3_pmu.c +1 -3
@@ -857,9 +857,7 @@ static int smmu_pmu_probe(struct platform_device *pdev) .stop = smmu_pmu_event_stop, .read = smmu_pmu_event_read, .attr_groups = smmu_pmu_attr_grps, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; smmu_pmu->reg_base =devm_platform_get_and_ioremap_resource (pdev,0 , &res_0);
drivers/perf/cxl_pmu.c +1 -3
@@ -864,9 +864,7 @@ static int cxl_pmu_probe(struct device *dev) .read = cxl_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = cxl_pmu_attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, };if (info->irq <=0 )
drivers/perf/dwc_pcie_pmu.c +1 -3
@@ -625,9 +625,7 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev) .parent = &pdev->dev, .module = THIS_MODULE, .attr_groups = dwc_pcie_attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, .task_ctx_nr = perf_invalid_context, .event_init = dwc_pcie_pmu_event_init, .add = dwc_pcie_pmu_event_add,
drivers/perf/fsl_imx8_ddr_perf.c +1 -3
@@ -640,9 +640,7 @@ static int ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, *pmu = (struct ddr_pmu ) { .pmu = (struct pmu ) { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | -PERF_PMU_CAP_NO_COMMON_EVENTS , + .capabilities =PERF_PMU_UNCORE_CAPS , .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = ddr_perf_event_init,
drivers/perf/fsl_imx9_ddr_perf.c +1 -3
@@ -517,9 +517,7 @@ static void ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, *pmu = (struct ddr_pmu ) { .pmu = (struct pmu ) { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | -PERF_PMU_CAP_NO_COMMON_EVENTS , + .capabilities =PERF_PMU_UNCORE_CAPS , .task_ctx_nr = perf_invalid_context, .attr_groups = attr_groups, .event_init = ddr_perf_event_init,
drivers/perf/hisilicon/hisi_pcie_pmu.c +1 -3
@@ -805,9 +805,7 @@ static int hisi_pcie_alloc_pmu(struct pci_dev *pdev, struct hisi_pcie_pmu *pcie_ .read = hisi_pcie_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = hisi_pcie_pmu_attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, };return 0 ;
drivers/perf/hisilicon/hisi_uncore_pmu.c +1 -3
@@ -530,9 +530,7 @@ void hisi_pmu_init(struct hisi_pmu *hisi_pmu, struct module *module) pmu->stop = hisi_uncore_pmu_stop; pmu->read = hisi_uncore_pmu_read; pmu->attr_groups = hisi_pmu->pmu_events.attr_groups; - pmu->capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | -PERF_PMU_CAP_NO_COMMON_EVENTS ; + pmu->capabilities =PERF_PMU_UNCORE_CAPS ; }EXPORT_SYMBOL_GPL (hisi_pmu_init);
drivers/perf/hisilicon/hns3_pmu.c +1 -3
@@ -1422,9 +1422,7 @@ static int hns3_pmu_alloc_pmu(struct pci_dev *pdev, struct hns3_pmu *hns3_pmu) .read = hns3_pmu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = hns3_pmu_attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, };return 0 ;
drivers/perf/marvell_cn10k_ddr_pmu.c +1 -3
@@ -643,9 +643,7 @@ static int cn10k_ddr_perf_probe(struct platform_device *pdev) ddr_pmu->pmu = (struct pmu ) { .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | -PERF_PMU_CAP_NO_COMMON_EVENTS , + .capabilities =PERF_PMU_UNCORE_CAPS , .task_ctx_nr = perf_invalid_context, .attr_groups = cn10k_attr_groups, .event_init = cn10k_ddr_perf_event_init,
drivers/perf/marvell_cn10k_tad_pmu.c +1 -3
@@ -317,9 +317,7 @@ static int tad_pmu_probe(struct platform_device *pdev) .module = THIS_MODULE, .attr_groups = tad_pmu_attr_groups, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, .task_ctx_nr = perf_invalid_context, .event_init = tad_pmu_event_init,
drivers/perf/qcom_l2_pmu.c +1 -3
@@ -897,9 +897,7 @@ static int l2_cache_pmu_probe(struct platform_device *pdev) .stop = l2_cache_event_stop, .read = l2_cache_event_read, .attr_groups = l2_cache_pmu_attr_grps, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; l2cache_pmu->num_counters =get_num_counters ();
drivers/perf/qcom_l3_pmu.c +1 -3
@@ -741,9 +741,7 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev) .read = qcom_l3_cache__event_read, .attr_groups = qcom_l3_cache_pmu_attr_grps, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; l3pmu->regs =devm_platform_get_and_ioremap_resource (pdev,0 , &memrc);
drivers/perf/thunderx2_pmu.c +1 -3
@@ -722,9 +722,7 @@ static int tx2_uncore_pmu_register( .start = tx2_uncore_event_start, .stop = tx2_uncore_event_stop, .read = tx2_uncore_event_read, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, }; tx2_pmu->pmu.name = devm_kasprintf(dev, GFP_KERNEL,
drivers/perf/xgene_pmu.c +1 -3
@@ -1098,9 +1098,7 @@ static int xgene_init_perf(struct xgene_pmu_dev *pmu_dev, char *name) .start = xgene_perf_start, .stop = xgene_perf_stop, .read = xgene_perf_read, - .capabilities =PERF_PMU_CAP_NO_EXCLUDE | -PERF_PMU_CAP_NO_SAMPLING | - PERF_PMU_CAP_NO_COMMON_EVENTS, + .capabilities = PERF_PMU_UNCORE_CAPS, };/* Hardware counter init */
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
Robin Murphy
maintainerPATCH 9/10 x86: Use common uncore PMU capabilities
In reply to Robin MurphySwitch the x86 uncore PMU drivers over to the new common capabilities, allowing to remove all the checks that perf core now takes care of.
--- arch/x86/events/amd/iommu.c | 17 +---------------- arch/x86/events/amd/power.c | 10 +--------- arch/x86/events/amd/uncore.c | 12 +++--------- arch/x86/events/intel/cstate.c | 16 +++------------- arch/x86/events/intel/uncore.c | 11 +---------- arch/x86/events/intel/uncore_snb.c | 20 +++----------------- arch/x86/events/msr.c | 9 +-------- arch/x86/events/rapl.c | 9 +-------- 8 files changed, 14 insertions(+), 90 deletions(-)
arch/x86/events/amd/iommu.c +1 -16
@@ -207,21 +207,6 @@ static int perf_iommu_event_init(struct perf_event *event) {struct hw_perf_event *hwc = &event->hw; -/* test the event attr type check for PMU enumeration */ -if (event->attr.type != event->pmu->type) -return -ENOENT ; - -/* -* IOMMU counters are shared across all cores. -* Therefore, it does not support per-process mode. -* Also, it does not support event sampling mode. -*/ -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) -return -EINVAL ; - -if (event->cpu <0 ) -return -EINVAL ; -/* update the hw_perf_event struct with the iommu config data */ hwc->conf = event->attr.config; hwc->conf1 = event->attr.config1;
@@ -412,7 +397,7 @@ static const struct pmu iommu_pmu __initconst = { .read = perf_iommu_read, .task_ctx_nr = perf_invalid_context, .attr_groups = amd_iommu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, };static __init int init_one_iommu (unsigned int idx)
arch/x86/events/amd/power.c +1 -9
@@ -124,14 +124,6 @@ static int pmu_event_init(struct perf_event *event) {u64 cfg = event->attr.config &AMD_POWER_EVENT_MASK ; -/* Only look at AMD power events. */ -if (event->attr.type != pmu_class.type) -return -ENOENT ; - -/* Unsupported modes and filters. */ -if (event->attr.sample_period) -return -EINVAL ; -if (cfg !=AMD_POWER_EVENTSEL_PKG )return -EINVAL ;
@@ -212,7 +204,7 @@ static struct pmu pmu_class = { .start = pmu_event_start, .stop = pmu_event_stop, .read = pmu_event_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, };
arch/x86/events/amd/uncore.c +3 -9
@@ -209,12 +209,6 @@ static int amd_uncore_event_init(struct perf_event *event)struct amd_uncore_ctx *ctx;struct hw_perf_event *hwc = &event->hw; -if (event->attr.type != event->pmu->type) -return -ENOENT ; - -if (event->cpu <0 ) -return -EINVAL ; - pmu =event_to_amd_uncore_pmu (event); ctx = *per_cpu_ptr (pmu->ctx, event->cpu);if (!ctx)
@@ -700,7 +694,7 @@ int amd_uncore_df_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, };
@@ -833,7 +827,7 @@ int amd_uncore_l3_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, };
@@ -958,7 +952,7 @@ int amd_uncore_umc_ctx_init(struct amd_uncore *uncore, unsigned int cpu) .start = amd_uncore_umc_start, .stop = amd_uncore_stop, .read = amd_uncore_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_SAMPLING, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, };
arch/x86/events/intel/cstate.c +3 -13
@@ -319,16 +319,6 @@ static int cstate_pmu_event_init(struct perf_event *event)u64 cfg = event->attr.config;int cpu; -if (event->attr.type != event->pmu->type) -return -ENOENT ; - -/* unsupported modes and filters */ -if (event->attr.sample_period)/* no sampling */ -return -EINVAL ; - -if (event->cpu <0 ) -return -EINVAL ; -if (event->pmu == &cstate_core_pmu) {if (cfg >=PERF_CSTATE_CORE_EVENT_MAX )return -EINVAL ;
@@ -530,7 +520,7 @@ static struct pmu cstate_core_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, };
@@ -545,7 +535,7 @@ static struct pmu cstate_pkg_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_SAMPLING| PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, };
@@ -560,7 +550,7 @@ static struct pmu cstate_module_pmu = { .start = cstate_pmu_event_start, .stop = cstate_pmu_event_stop, .read = cstate_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .module = THIS_MODULE, };
arch/x86/events/intel/uncore.c +1 -10
@@ -736,24 +736,15 @@ static int uncore_pmu_event_init(struct perf_event *event)struct hw_perf_event *hwc = &event->hw;int ret; -if (event->attr.type != event->pmu->type) -return -ENOENT ; - pmu =uncore_event_to_pmu (event);/* no device found for this pmu */ if (pmu->func_id <0 )return -ENOENT ; -/* Sampling not supported yet */ -if (hwc->sample_period) -return -EINVAL ; -/* * Place all uncore events for a particular physical package * onto a single cpu */ -if (event->cpu <0 ) -return -EINVAL ; box =uncore_pmu_to_box (pmu, event->cpu);if (!box || box->cpu <0 )return -EINVAL ;
@@ -919,7 +910,7 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu) .stop = uncore_pmu_event_stop, .read = uncore_pmu_event_read, .module = THIS_MODULE, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .attr_update = pmu->type->attr_update, }; }else {
arch/x86/events/intel/uncore_snb.c +3 -17
@@ -876,33 +876,19 @@ static int snb_uncore_imc_event_init(struct perf_event *event)u64 cfg = event->attr.config &SNB_UNCORE_PCI_IMC_EVENT_MASK ;int idx, base; -if (event->attr.type != event->pmu->type) -return -ENOENT ; - pmu =uncore_event_to_pmu (event);/* no device found for this pmu */ if (pmu->func_id <0 )return -ENOENT ; -/* Sampling not supported yet */ -if (hwc->sample_period) -return -EINVAL ; - -/* unsupported modes and filters */ -if (event->attr.sample_period)/* no sampling */ +/* check only supported bits are set */ +if (event->attr.config & ~SNB_UNCORE_PCI_IMC_EVENT_MASK )return -EINVAL ;/* * Place all uncore events for a particular physical package * onto a single cpu */ -if (event->cpu <0 ) -return -EINVAL ; - -/* check only supported bits are set */ -if (event->attr.config & ~SNB_UNCORE_PCI_IMC_EVENT_MASK ) -return -EINVAL ; - box =uncore_pmu_to_box (pmu, event->cpu);if (!box || box->cpu <0 )return -EINVAL ;
@@ -1013,7 +999,7 @@ static struct pmu snb_uncore_imc_pmu = { .start = uncore_pmu_event_start, .stop = uncore_pmu_event_stop, .read = uncore_pmu_event_read, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, };static struct intel_uncore_ops snb_uncore_imc_ops = {
arch/x86/events/msr.c +1 -8
@@ -204,13 +204,6 @@ static int msr_event_init(struct perf_event *event) {u64 cfg = event->attr.config; -if (event->attr.type != event->pmu->type) -return -ENOENT ; - -/* unsupported modes and filters */ -if (event->attr.sample_period)/* no sampling */ -return -EINVAL ; -if (cfg >=PERF_MSR_EVENT_MAX )return -EINVAL ;
@@ -296,7 +289,7 @@ static struct pmu pmu_msr = { .start = msr_event_start, .stop = msr_event_stop, .read = msr_event_update, - .capabilities = PERF_PMU_CAP_NO_SAMPLING | PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, .attr_update = attr_update, };
arch/x86/events/rapl.c +1 -8
@@ -328,17 +328,10 @@ static int rapl_pmu_event_init(struct perf_event *event)int bit, ret =0 ;struct rapl_pmu *pmu; -/* only look at RAPL events */ -if (event->attr.type != rapl_pmus->pmu.type) -return -ENOENT ; -/* check only supported bits are set */ if (event->attr.config & ~RAPL_EVENT_MASK )return -EINVAL ; -if (event->cpu <0 ) -return -EINVAL ; - event->event_caps |=PERF_EV_CAP_READ_ACTIVE_PKG ;if (!cfg || cfg >=NR_RAPL_DOMAINS +1 )
@@ -693,7 +686,7 @@ static int __init init_rapl_pmus(void) rapl_pmus->pmu.stop = rapl_pmu_event_stop; rapl_pmus->pmu.read = rapl_pmu_event_read; rapl_pmus->pmu.module =THIS_MODULE ; - rapl_pmus->pmu.capabilities =PERF_PMU_CAP_NO_EXCLUDE ; + rapl_pmus->pmu.capabilities =PERF_PMU_UNCORE_CAPS ;return 0 ; }
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
Robin Murphy
maintainerPATCH 10/10 ARM: Use common uncore PMU capabilities
In reply to Robin MurphySwitch the ARM system PMU drivers over to the new common capabilities, allowing to remove all the checks that perf core now takes care of.
--- arch/arm/mach-imx/mmdc.c | 16 +--------------- arch/arm/mm/cache-l2x0-pmu.c | 12 +----------- 2 files changed, 2 insertions(+), 26 deletions(-)
arch/arm/mach-imx/mmdc.c +1 -15
@@ -280,20 +280,6 @@ static int mmdc_pmu_event_init(struct perf_event *event)struct mmdc_pmu *pmu_mmdc =to_mmdc_pmu (event->pmu);int cfg = event->attr.config; -if (event->attr.type != event->pmu->type) -return -ENOENT ; - -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) -return -EOPNOTSUPP ; - -if (event->cpu <0 ) { -dev_warn (pmu_mmdc->dev,"Can't provide per-task data!\n" ); -return -EOPNOTSUPP ; - } - -if (event->attr.sample_period) -return -EINVAL ; -if (cfg <0 || cfg >=MMDC_NUM_COUNTERS )return -EINVAL ;
@@ -445,7 +431,7 @@ static int mmdc_pmu_init(struct mmdc_pmu *pmu_mmdc, .start = mmdc_pmu_event_start, .stop = mmdc_pmu_event_stop, .read = mmdc_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, }, .mmdc_base = mmdc_base, .dev = dev,
arch/arm/mm/cache-l2x0-pmu.c +1 -11
@@ -295,16 +295,6 @@ static int l2x0_pmu_event_init(struct perf_event *event) {struct hw_perf_event *hw = &event->hw; -if (event->attr.type != l2x0_pmu->type) -return -ENOENT ; - -if (is_sampling_event (event) || - event->attach_state &PERF_ATTACH_TASK ) -return -EINVAL ; - -if (event->cpu <0 ) -return -EINVAL ; -if (event->attr.config & ~L2X0_EVENT_CNT_CFG_SRC_MASK )return -EINVAL ;
@@ -524,7 +514,7 @@ static __init int l2x0_pmu_init(void) .del = l2x0_pmu_event_del, .event_init = l2x0_pmu_event_init, .attr_groups = l2x0_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, };l2x0_pmu_reset ();
Signature · 1 line
2.39.2.101.g768bb238c484.dirty
Re: [PATCH 10/10] ARM: Use common uncore PMU capabilities
Quoted 9 lines · Robin Murphy
Switch the ARM system PMU drivers over to the new common capabilities, allowing to remove all the checks that perf core now takes care of.
CC Russell King <[email protected]>CC Shawn Guo <[email protected]>CC Sascha Hauer <[email protected]>Signed-off-by Robin Murphy <[email protected]>--- arch/arm/mach-imx/mmdc.c | 16 +---------------
Quoted 70 lines
arch/arm/mm/cache-l2x0-pmu.c | 12 +----------- 2 files changed, 2 insertions(+), 26 deletions(-)arch/arm/mach-imx/mmdc.c +1
-15@@ -280,20 +280,6 @@ static int mmdc_pmu_event_init(struct perf_event *event)struct mmdc_pmu *pmu_mmdc =to_mmdc_pmu (event->pmu);int cfg = event->attr.config; -if (event->attr.type != event->pmu->type) -return -ENOENT ; - -if (is_sampling_event (event) || event->attach_state &PERF_ATTACH_TASK ) -return -EOPNOTSUPP ; - -if (event->cpu <0 ) { -dev_warn (pmu_mmdc->dev,"Can't provide per-task data!\n" ); -return -EOPNOTSUPP ; - } - -if (event->attr.sample_period) -return -EINVAL ; -if (cfg <0 || cfg >=MMDC_NUM_COUNTERS )return -EINVAL ;@@ -445,7 +431,7 @@ static int mmdc_pmu_init(struct mmdc_pmu *pmu_mmdc, .start = mmdc_pmu_event_start, .stop = mmdc_pmu_event_stop, .read = mmdc_pmu_event_update, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, }, .mmdc_base = mmdc_base, .dev = dev,arch/arm/mm/cache-l2x0-pmu.c +1
-11@@ -295,16 +295,6 @@ static int l2x0_pmu_event_init(struct perf_event *event) {struct hw_perf_event *hw = &event->hw; -if (event->attr.type != l2x0_pmu->type) -return -ENOENT ; - -if (is_sampling_event (event) || - event->attach_state &PERF_ATTACH_TASK ) -return -EINVAL ; - -if (event->cpu <0 ) -return -EINVAL ; -if (event->attr.config & ~L2X0_EVENT_CNT_CFG_SRC_MASK )return -EINVAL ;@@ -524,7 +514,7 @@ static __init int l2x0_pmu_init(void) .del = l2x0_pmu_event_del, .event_init = l2x0_pmu_event_init, .attr_groups = l2x0_pmu_attr_groups, - .capabilities = PERF_PMU_CAP_NO_EXCLUDE, + .capabilities = PERF_PMU_UNCORE_CAPS, };l2x0_pmu_reset ();Signature · 1 line
2.39.2.101.g768bb238c484.dirty
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 16 lines · Robin Murphy
Hi all,
Since this came up yet again recently, and it's an idea which has been nagging me for years, I decided it was time to see how hard it really would be to start shaving this yak. And it turns out to be refreshingly simple - the core code has quietly become capable of doing most of what we want, the one new functional addition is trivial (patch #2), and the resulting largely-mechanical cleanup seems a pretty nice win.
This series is focused on
drivers/perf/as that's where most mess is concentrated, but figured I'd include thearch/patches as well since they might be reasonable to land with the core changes, at least for x86 (FWIW I did also look at the powerpc drivers but they scared me and I ran away; sorry). The remaining stragglers elsewhere around the tree I'd come back to as a follow-up.
Quoted 8 lines
(And yes, I appreciate it's mid-merge-window already, but since I do have a tree-wide rename proposed here, may as well give the discussion a chance for a head start before -rc1...)
Thanks,
Robin.
Quoted 61 lines
Robin Murphy (10):
perf/alibaba_uncore_drw: Use correct CPU affinity
perf: Add capability for common event supportdrivers/perf: UsePERF_PMU_CAP_NO_COMMON_EVENTS
perf: RenamePERF_PMU_CAP_NO_INTERRUPTdrivers/perf: UsePERF_PMU_CAP_NO_SAMPLINGconsistentlydrivers/perf: Clean up redundant per-task checks
perf: Define common uncore capabilitiesdrivers/perf: Use common uncore capabilities
x86: Use common uncore PMU capabilities
ARM: Use common uncore PMU capabilitiesarch/arc/kernel/perf_event.c | 2 +- arch/arm/mach-imx/mmdc.c | 16 +------------- arch/arm/mm/cache-l2x0-pmu.c | 12 +--------- arch/csky/kernel/perf_event.c | 2 +- arch/powerpc/perf/8xx-pmu.c | 2 +- arch/powerpc/perf/hv-24x7.c | 2 +- arch/powerpc/perf/hv-gpci.c | 2 +- arch/powerpc/platforms/pseries/papr_scm.c | 2 +- arch/s390/kernel/perf_cpum_cf.c | 2 +- arch/sh/kernel/perf_event.c | 2 +- arch/x86/events/amd/iommu.c | 17 +------------- arch/x86/events/amd/power.c | 10 +-------- arch/x86/events/amd/uncore.c | 12 +++------- arch/x86/events/core.c | 2 +- arch/x86/events/intel/cstate.c | 16 +++----------- arch/x86/events/intel/uncore.c | 11 +-------- arch/x86/events/intel/uncore_snb.c | 20 +++-------------- arch/x86/events/msr.c | 9 +------- arch/x86/events/rapl.c | 9 +------- drivers/fpga/dfl-fme-perf.c | 2 +- drivers/perf/alibaba_uncore_drw_pmu.c | 27 +++-------------------- drivers/perf/amlogic/meson_ddr_pmu_core.c | 11 +-------- drivers/perf/arm-cci.c | 15 +------------ drivers/perf/arm-ccn.c | 20 +---------------- drivers/perf/arm-cmn.c | 10 +-------- drivers/perf/arm_cspmu/arm_cspmu.c | 27 ++--------------------- drivers/perf/arm_dmc620_pmu.c | 18 +-------------- drivers/perf/arm_dsu_pmu.c | 22 +----------------- drivers/perf/arm_pmu_platform.c | 2 +- drivers/perf/arm_smmuv3_pmu.c | 15 +------------ drivers/perf/arm_spe_pmu.c | 7 ++---- drivers/perf/cxl_pmu.c | 8 +------ drivers/perf/dwc_pcie_pmu.c | 13 +---------- drivers/perf/fsl_imx8_ddr_perf.c | 13 +---------- drivers/perf/fsl_imx9_ddr_perf.c | 13 +---------- drivers/perf/hisilicon/hisi_pcie_pmu.c | 10 +-------- drivers/perf/hisilicon/hisi_uncore_pmu.c | 20 +---------------- drivers/perf/hisilicon/hns3_pmu.c | 9 +------- drivers/perf/marvell_cn10k_ddr_pmu.c | 15 +------------ drivers/perf/marvell_cn10k_tad_pmu.c | 6 +---- drivers/perf/qcom_l2_pmu.c | 21 ++---------------- drivers/perf/qcom_l3_pmu.c | 21 +----------------- drivers/perf/riscv_pmu_sbi.c | 2 +- drivers/perf/thunderx2_pmu.c | 17 +------------- drivers/perf/xgene_pmu.c | 16 +------------- include/linux/perf_event.h | 6 ++++- kernel/events/core.c | 7 +++++- 47 files changed, 67 insertions(+), 456 deletions(-)