mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: roman.sudarikov@linux.intel.com
To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
	jolsa@redhat.com, namhyung@kernel.org,
	linux-kernel@vger.kernel.org, eranian@google.com,
	bgregg@netflix.com, ak@linux.intel.com,
	kan.liang@linux.intel.com
Cc: alexander.antonov@intel.com, roman.sudarikov@linux.intel.com
Subject: [PATCH v2 2/3] perf x86: Add compaction function for uncore attributes
Date: Tue, 10 Dec 2019 12:14:50 +0300	[thread overview]
Message-ID: <20191210091451.6054-3-roman.sudarikov@linux.intel.com> (raw)
In-Reply-To: <20191210091451.6054-1-roman.sudarikov@linux.intel.com>

From: Roman Sudarikov <roman.sudarikov@linux.intel.com>

In current design, there is an implicit assumption that array of pointers
to uncore type attributes is NULL terminated. However, not all attributes
are mandatory for each Uncore unit type, e.g. "events" is required for
IMC but doesn't exist for CHA. That approach correctly supports only one
optional attribute which also must be the last in the row.
The patch removes limitation by safely removing embedded NULL elements.

Co-developed-by: Alexander Antonov <alexander.antonov@intel.com>
Signed-off-by: Alexander Antonov <alexander.antonov@intel.com>
Signed-off-by: Roman Sudarikov <roman.sudarikov@linux.intel.com>
---
 arch/x86/events/intel/uncore.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
index 24e120289018..a05352c4fc01 100644
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -923,6 +923,22 @@ static void uncore_types_exit(struct intel_uncore_type **types)
 		uncore_type_exit(*types);
 }
 
+static void uncore_type_attrs_compaction(struct intel_uncore_type *type)
+{
+	int i, j;
+	int size = ARRAY_SIZE(type->attr_groups);
+
+	for (i = 0, j = 0; i < size; i++) {
+		if (!type->attr_groups[i])
+			continue;
+		if (i > j) {
+			type->attr_groups[j] = type->attr_groups[i];
+			type->attr_groups[i] = NULL;
+		}
+		j++;
+	}
+}
+
 static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
 {
 	struct intel_uncore_pmu *pmus;
@@ -980,6 +996,12 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
 		if (!type->get_topology(type) && !type->set_mapping(type))
 			type->mapping_group = &uncore_mapping_group;
 
+	/*
+	 * For optional attributes, we can safely remove embedded NULL
+	 * attr_groups elements.
+	 */
+	uncore_type_attrs_compaction(type);
+
 	return 0;
 
 err:
-- 
2.19.1


  parent reply	other threads:[~2019-12-10  9:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-10  9:14 [PATCH v2 0/3] perf x86: Exposing IO stack to IO PMON mapping through sysfs roman.sudarikov
2019-12-10  9:14 ` [PATCH v2 1/3] perf x86: Infrastructure for exposing an Uncore unit to PMON mapping roman.sudarikov
2019-12-10  9:14 ` roman.sudarikov [this message]
2019-12-10 10:37   ` [PATCH v2 2/3] perf x86: Add compaction function for uncore attributes Peter Zijlstra
2019-12-10 18:32     ` Sudarikov, Roman
2019-12-11 14:21     ` Sudarikov, Roman
2019-12-10  9:14 ` [PATCH v2 3/3] perf x86: Exposing an Uncore unit to PMON for Intel Xeon® server platform roman.sudarikov
2019-12-10 14:01   ` Liang, Kan

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=20191210091451.6054-3-roman.sudarikov@linux.intel.com \
    --to=roman.sudarikov@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.antonov@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bgregg@netflix.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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

all inboxes | Powered by JetHome®