]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
perf/x86: Fix caps/ for !Intel
authorPeter Zijlstra <peterz@infradead.org>
Mon, 28 Aug 2017 10:46:50 +0000 (12:46 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 29 Aug 2017 13:09:25 +0000 (15:09 +0200)
Move the 'max_precise' capability into generic x86 code where it
belongs. This fixes a sysfs splat on !Intel systems where we fail to set
x86_pmu_caps_group.atts.

Reported-and-tested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: hpa@zytor.com
Fixes: 22688d1c20f5 ("x86/perf: Export some PMU attributes in caps/ directory")
Link: http://lkml.kernel.org/r/20170828104650.2u3rsim4jafyjzv2@hirez.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/events/core.c
arch/x86/events/intel/core.c

index d5f98095a15503d2a46b860d7e4ad45a4a4f3d69..73a6311c8baa94fd5aadbf14af944670cf6fc195 100644 (file)
@@ -1757,10 +1757,7 @@ ssize_t x86_event_sysfs_show(char *page, u64 config, u64 event)
 }
 
 static struct attribute_group x86_pmu_attr_group;
-
-static struct attribute_group x86_pmu_caps_group = {
-       .name = "caps",
-};
+static struct attribute_group x86_pmu_caps_group;
 
 static int __init init_hw_perf_events(void)
 {
@@ -1808,7 +1805,14 @@ static int __init init_hw_perf_events(void)
                                   0, x86_pmu.num_counters, 0, 0);
 
        x86_pmu_format_group.attrs = x86_pmu.format_attrs;
-       x86_pmu_caps_group.attrs = x86_pmu.caps_attrs;
+
+       if (x86_pmu.caps_attrs) {
+               struct attribute **tmp;
+
+               tmp = merge_attr(x86_pmu_caps_group.attrs, x86_pmu.caps_attrs);
+               if (!WARN_ON(!tmp))
+                       x86_pmu_caps_group.attrs = tmp;
+       }
 
        if (x86_pmu.event_attrs)
                x86_pmu_events_group.attrs = x86_pmu.event_attrs;
@@ -2224,6 +2228,25 @@ static struct attribute_group x86_pmu_attr_group = {
        .attrs = x86_pmu_attrs,
 };
 
+static ssize_t max_precise_show(struct device *cdev,
+                                 struct device_attribute *attr,
+                                 char *buf)
+{
+       return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu_max_precise());
+}
+
+static DEVICE_ATTR_RO(max_precise);
+
+static struct attribute *x86_pmu_caps_attrs[] = {
+       &dev_attr_max_precise.attr,
+       NULL
+};
+
+static struct attribute_group x86_pmu_caps_group = {
+       .name = "caps",
+       .attrs = x86_pmu_caps_attrs,
+};
+
 static const struct attribute_group *x86_pmu_attr_groups[] = {
        &x86_pmu_attr_group,
        &x86_pmu_format_group,
index 8fa2abd9c8b6926586879bf5940d0ff1d15a75ce..829e89cfcee2deff8b937806b16dd573d736a895 100644 (file)
@@ -3820,19 +3820,9 @@ static ssize_t pmu_name_show(struct device *cdev,
 
 static DEVICE_ATTR_RO(pmu_name);
 
-static ssize_t max_precise_show(struct device *cdev,
-                                 struct device_attribute *attr,
-                                 char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu_max_precise());
-}
-
-static DEVICE_ATTR_RO(max_precise);
-
 static struct attribute *intel_pmu_caps_attrs[] = {
-       &dev_attr_pmu_name.attr,
-       &dev_attr_max_precise.attr,
-       NULL
+       &dev_attr_pmu_name.attr,
+       NULL
 };
 
 static struct attribute *intel_pmu_attrs[] = {