public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Andi Kleen <ak@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 6/9] perf/x86: Use update attribute groups for caps
Date: Sun, 12 May 2019 17:55:15 +0200	[thread overview]
Message-ID: <20190512155518.21468-7-jolsa@kernel.org> (raw)
In-Reply-To: <20190512155518.21468-1-jolsa@kernel.org>

Using the new pmu::update_attrs attribute group for
"caps" directory.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 arch/x86/events/core.c       |  8 --------
 arch/x86/events/intel/core.c | 25 ++++++++++++++++++++-----
 arch/x86/events/perf_event.h |  1 -
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index a7aa72afcc7f..7f1bb5fd1fc4 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -1821,14 +1821,6 @@ static int __init init_hw_perf_events(void)
 
 	x86_pmu_format_group.attrs = x86_pmu.format_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.events_sysfs_show)
 		x86_pmu_events_group.attrs = &empty_attrs;
 
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index fd7d36611e22..fff73623cf80 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -4402,6 +4402,12 @@ pebs_is_visible(struct kobject *kobj, struct attribute *attr, int i)
 	return x86_pmu.pebs ? attr->mode : 0;
 }
 
+static umode_t
+lbr_is_visible(struct kobject *kobj, struct attribute *attr, int i)
+{
+	return x86_pmu.lbr_nr ? attr->mode : 0;
+}
+
 static struct attribute_group group_events_td  = {
 	.name = "events",
 };
@@ -4416,10 +4422,23 @@ static struct attribute_group group_events_tsx = {
 	.is_visible = tsx_is_visible,
 };
 
+static struct attribute_group group_caps_gen = {
+	.name  = "caps",
+	.attrs = intel_pmu_caps_attrs,
+};
+
+static struct attribute_group group_caps_lbr = {
+	.name       = "caps",
+	.attrs	    = lbr_attrs,
+	.is_visible = lbr_is_visible,
+};
+
 static const struct attribute_group *attr_update[] = {
 	&group_events_td,
 	&group_events_mem,
 	&group_events_tsx,
+	&group_caps_gen,
+	&group_caps_lbr,
 	NULL,
 };
 
@@ -5046,12 +5065,8 @@ __init int intel_pmu_init(void)
 			x86_pmu.lbr_nr = 0;
 	}
 
-	x86_pmu.caps_attrs = intel_pmu_caps_attrs;
-
-	if (x86_pmu.lbr_nr) {
-		x86_pmu.caps_attrs = merge_attr(x86_pmu.caps_attrs, lbr_attrs);
+	if (x86_pmu.lbr_nr)
 		pr_cont("%d-deep LBR, ", x86_pmu.lbr_nr);
-	}
 
 	/*
 	 * Access extra MSR may cause #GP under certain circumstances.
diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
index 7dd91607b5fa..1e3a7d74ea49 100644
--- a/arch/x86/events/perf_event.h
+++ b/arch/x86/events/perf_event.h
@@ -631,7 +631,6 @@ struct x86_pmu {
 	int		attr_rdpmc_broken;
 	int		attr_rdpmc;
 	struct attribute **format_attrs;
-	struct attribute **caps_attrs;
 
 	ssize_t		(*events_sysfs_show)(char *page, u64 config);
 	const struct attribute_group **attr_update;
-- 
2.20.1


  parent reply	other threads:[~2019-05-12 15:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-12 15:55 [PATCHv2 0/9] perf/x86: Add update attribute groups Jiri Olsa
2019-05-12 15:55 ` [PATCH 1/9] sysfs: Add sysfs_update_groups function Jiri Olsa
2019-06-03 13:25   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 2/9] perf: Add attr_groups_update into struct pmu Jiri Olsa
2019-06-03 13:26   ` [tip:perf/core] perf/core: " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 3/9] perf/x86: Get rid of x86_pmu::event_attrs Jiri Olsa
2019-06-03 13:26   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 4/9] perf/x86: Use the new pmu::update_attrs attribute group Jiri Olsa
2019-06-03 13:27   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 5/9] perf/x86: Add is_visible attribute_group callback for base events Jiri Olsa
2019-06-03 13:28   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` Jiri Olsa [this message]
2019-06-03 13:28   ` [tip:perf/core] perf/x86: Use update attribute groups for caps tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 7/9] perf/x86: Use update attribute groups for extra format Jiri Olsa
2019-06-03 13:29   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 8/9] perf/x86/intel: Use update attributes for skylake format Jiri Olsa
2019-06-03 13:30   ` [tip:perf/core] " tip-bot for Jiri Olsa
2019-05-12 15:55 ` [PATCH 9/9] perf/x86: Use update attribute groups for default attributes Jiri Olsa
2019-05-13  9:35   ` Peter Zijlstra
2019-05-13 10:13     ` Jiri Olsa
2019-05-24 13:21     ` [PATCH] perf/x86/intel: Use is_visible callback for default group Jiri Olsa
2019-06-14 10:20       ` Jiri Olsa
2019-06-14 12:34         ` Peter Zijlstra
2019-06-17 14:40       ` [tip:perf/core] perf/x86/intel: Use ->is_visible " tip-bot for Jiri Olsa
2019-06-03 13:31   ` [tip:perf/core] perf/x86: Use update attribute groups for default attributes tip-bot for Jiri Olsa
2019-05-13  9:38 ` [PATCHv2 0/9] perf/x86: Add update attribute groups Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190512155518.21468-7-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox