From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753076AbdH2O0w (ORCPT ); Tue, 29 Aug 2017 10:26:52 -0400 Received: from terminus.zytor.com ([65.50.211.136]:39973 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751250AbdH2O0v (ORCPT ); Tue, 29 Aug 2017 10:26:51 -0400 Date: Tue, 29 Aug 2017 07:22:49 -0700 From: tip-bot for Peter Zijlstra Message-ID: Cc: mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, ak@linux.intel.com, peterz@infradead.org, torvalds@linux-foundation.org, hpa@zytor.com, bp@suse.de Reply-To: hpa@zytor.com, peterz@infradead.org, torvalds@linux-foundation.org, bp@suse.de, mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, ak@linux.intel.com In-Reply-To: <20170828104650.2u3rsim4jafyjzv2@hirez.programming.kicks-ass.net> References: <20170828104650.2u3rsim4jafyjzv2@hirez.programming.kicks-ass.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/x86: Fix caps/ for !Intel Git-Commit-ID: 5da382eb6ea37e2c49ef521c636d73f6ecc3fa81 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 5da382eb6ea37e2c49ef521c636d73f6ecc3fa81 Gitweb: http://git.kernel.org/tip/5da382eb6ea37e2c49ef521c636d73f6ecc3fa81 Author: Peter Zijlstra AuthorDate: Mon, 28 Aug 2017 12:46:50 +0200 Committer: Ingo Molnar CommitDate: Tue, 29 Aug 2017 15:09:25 +0200 perf/x86: Fix caps/ for !Intel 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 Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Andi Kleen Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner 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 --- arch/x86/events/core.c | 33 ++++++++++++++++++++++++++++----- arch/x86/events/intel/core.c | 14 ++------------ 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index d5f9809..73a6311 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -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, diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 8fa2abd..829e89c 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -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[] = {