All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qi Liu <liuqi115@huawei.com>
To: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <will@kernel.org>
Cc: <linuxarm@huawei.com>, Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: [PATCH v4 1/7] perf: Add EVENT_ATTR_ID to simplify event attributes
Date: Wed, 9 Jun 2021 14:40:57 +0800	[thread overview]
Message-ID: <1623220863-58233-2-git-send-email-liuqi115@huawei.com> (raw)
In-Reply-To: <1623220863-58233-1-git-send-email-liuqi115@huawei.com>

Similar EVENT_ATTR macros are defined in many PMU drivers,
like Arm PMU driver, Arm SMMU PMU driver. So add a generic
macro to simplify code.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
 include/linux/perf_event.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index f5a6a2f..2d510ad 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1576,6 +1576,12 @@ static struct perf_pmu_events_attr _var = {				    \
 	.event_str	= _str,						    \
 };
 
+#define PMU_EVENT_ATTR_ID(_name, _show, _id)				\
+	(&((struct perf_pmu_events_attr[]) {				\
+		{ .attr = __ATTR(_name, 0444, _show, NULL),		\
+		  .id = _id, }						\
+	})[0].attr.attr)
+
 #define PMU_FORMAT_ATTR(_name, _format)					\
 static ssize_t								\
 _name##_show(struct device *dev,					\
-- 
2.7.4


WARNING: multiple messages have this Message-ID (diff)
From: Qi Liu <liuqi115@huawei.com>
To: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <will@kernel.org>
Cc: <linuxarm@huawei.com>, Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: [PATCH v4 1/7] perf: Add EVENT_ATTR_ID to simplify event attributes
Date: Wed, 9 Jun 2021 14:40:57 +0800	[thread overview]
Message-ID: <1623220863-58233-2-git-send-email-liuqi115@huawei.com> (raw)
In-Reply-To: <1623220863-58233-1-git-send-email-liuqi115@huawei.com>

Similar EVENT_ATTR macros are defined in many PMU drivers,
like Arm PMU driver, Arm SMMU PMU driver. So add a generic
macro to simplify code.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
 include/linux/perf_event.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index f5a6a2f..2d510ad 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1576,6 +1576,12 @@ static struct perf_pmu_events_attr _var = {				    \
 	.event_str	= _str,						    \
 };
 
+#define PMU_EVENT_ATTR_ID(_name, _show, _id)				\
+	(&((struct perf_pmu_events_attr[]) {				\
+		{ .attr = __ATTR(_name, 0444, _show, NULL),		\
+		  .id = _id, }						\
+	})[0].attr.attr)
+
 #define PMU_FORMAT_ATTR(_name, _format)					\
 static ssize_t								\
 _name##_show(struct device *dev,					\
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-06-09  6:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09  6:40 [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Qi Liu
2021-06-09  6:40 ` Qi Liu
2021-06-09  6:40 ` Qi Liu [this message]
2021-06-09  6:40   ` [PATCH v4 1/7] perf: Add EVENT_ATTR_ID " Qi Liu
2021-06-09  6:40 ` [PATCH v4 2/7] drivers/perf: Simplify EVENT ATTR macro in SMMU PMU driver Qi Liu
2021-06-09  6:40   ` Qi Liu
2021-06-09  6:40 ` [PATCH v4 3/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l2_pmu.c Qi Liu
2021-06-09  6:40   ` Qi Liu
2021-06-09  6:41 ` [PATCH v4 4/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l3_pmu.c Qi Liu
2021-06-09  6:41   ` Qi Liu
2021-06-09  6:41 ` [PATCH v4 5/7] drivers/perf: Simplify EVENT ATTR macro in xgene_pmu.c Qi Liu
2021-06-09  6:41   ` Qi Liu
2021-06-09  6:41 ` [PATCH v4 6/7] drivers/perf: Simplify EVENT ATTR macro in fsl_imx8_ddr_perf.c Qi Liu
2021-06-09  6:41   ` Qi Liu
2021-06-09  6:41 ` [PATCH v4 7/7] arm64: perf: Simplify EVENT ATTR macro in perf_event.c Qi Liu
2021-06-09  6:41   ` Qi Liu
2021-06-11 16:15 ` [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Will Deacon
2021-06-11 16:15   ` Will Deacon

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=1623220863-58233-2-git-send-email-liuqi115@huawei.com \
    --to=liuqi115@huawei.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.