From 4c2d20813df82245ba50fb7f409f12f25bdf9e0d Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Thu, 22 Oct 2020 10:22:56 +0800 Subject: [PATCH 2186/2944] Intel: perf/x86: Use update attribute groups for default attributes to #31064126 commit 6a9f4efe78af6069a11946c64d3d4c86cb42046b upstream Backport summary: backport to kernel 4.19.57 for ICX perf topdown support Using the new pmu::update_attrs attribute group for default attributes - freeze_on_smi, allow_tsx_force_abort. Signed-off-by: Jiri Olsa Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Greg Kroah-Hartman Cc: Linus Torvalds Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Gleixner Link: https://lkml.kernel.org/r/20190512155518.21468-10-jolsa@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Yunying Sun Signed-off-by: Peng Wang Reviewed-by: Artie Ding --- arch/x86/events/core.c | 34 ---------------------------------- arch/x86/events/intel/core.c | 9 +++++---- arch/x86/events/perf_event.h | 3 --- 3 files changed, 5 insertions(+), 41 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index f831f54..e4e91f4 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -1647,32 +1647,6 @@ static void __init pmu_check_apic(void) .attrs = NULL, }; -/* Merge two pointer arrays */ -__init struct attribute **merge_attr(struct attribute **a, struct attribute **b) -{ - struct attribute **new; - int j, i; - - for (j = 0; a && a[j]; j++) - ; - for (i = 0; b && b[i]; i++) - j++; - j++; - - new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL); - if (!new) - return NULL; - - j = 0; - for (i = 0; a && a[i]; i++) - new[j++] = a[i]; - for (i = 0; b && b[i]; i++) - new[j++] = b[i]; - new[j] = NULL; - - return new; -} - ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr, char *page) { struct perf_pmu_events_attr *pmu_attr = \ @@ -1853,14 +1827,6 @@ static int __init init_hw_perf_events(void) if (!x86_pmu.events_sysfs_show) x86_pmu_events_group.attrs = &empty_attrs; - if (x86_pmu.attrs) { - struct attribute **tmp; - - tmp = merge_attr(x86_pmu_attr_group.attrs, x86_pmu.attrs); - if (!WARN_ON(!tmp)) - x86_pmu_attr_group.attrs = tmp; - } - pmu.attr_update = x86_pmu.attr_update; pr_info("... version: %d\n", x86_pmu.version); diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 068185e..949505d 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3708,8 +3708,6 @@ static int intel_pmu_check_period(struct perf_event *event, u64 value) .check_period = intel_pmu_check_period, }; -static struct attribute *intel_pmu_attrs[]; - static __initconst const struct x86_pmu intel_pmu = { .name = "Intel", .handle_irq = intel_pmu_handle_irq, @@ -3741,8 +3739,6 @@ static int intel_pmu_check_period(struct perf_event *event, u64 value) .format_attrs = intel_arch3_formats_attr, .events_sysfs_show = intel_event_sysfs_show, - .attrs = intel_pmu_attrs, - .cpu_prepare = intel_pmu_cpu_prepare, .cpu_starting = intel_pmu_cpu_starting, .cpu_dying = intel_pmu_cpu_dying, @@ -4164,6 +4160,10 @@ static ssize_t pmu_name_show(struct device *cdev, .is_visible = exra_is_visible, }; +static struct attribute_group group_default = { + .attrs = intel_pmu_attrs, +}; + static const struct attribute_group *attr_update[] = { &group_events_td, &group_events_mem, @@ -4172,6 +4172,7 @@ static ssize_t pmu_name_show(struct device *cdev, &group_caps_lbr, &group_format_extra, &group_format_extra_skl, + &group_default, NULL, }; diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index d6e4118b..db9f980 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -619,7 +619,6 @@ struct x86_pmu { const struct attribute_group **attr_update; unsigned long attr_freeze_on_smi; - struct attribute **attrs; /* * CPU Hotplug hooks @@ -902,8 +901,6 @@ static inline void set_linear_ip(struct pt_regs *regs, unsigned long ip) ssize_t x86_event_sysfs_show(char *page, u64 config, u64 event); ssize_t intel_event_sysfs_show(char *page, u64 config); -struct attribute **merge_attr(struct attribute **a, struct attribute **b); - ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr, char *page); ssize_t events_ht_sysfs_show(struct device *dev, struct device_attribute *attr, -- 1.8.3.1