Linux Perf Users
 help / color / mirror / Atom feed
From: Dapeng Mi <dapeng1.mi@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Kan Liang <kan.liang@linux.intel.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Dapeng Mi <dapeng1.mi@intel.com>,
	Dapeng Mi <dapeng1.mi@linux.intel.com>
Subject: [PATCH 1/2] perf x86/topdown: Make topdown metrics comparators be symmetric
Date: Fri, 11 Oct 2024 11:02:06 +0000	[thread overview]
Message-ID: <20241011110207.1032235-1-dapeng1.mi@linux.intel.com> (raw)

The commit "3b5edc0421e2 (perf x86/topdown: Don't move topdown metric
 events in group)" modifies topdown metrics comparator to move topdown
metrics events which are not in same group with previous event. But it
just modifies the 2nd comparator and causes the comparators become
asymmetric.

Thus modify the 1st topdown metrics comparator and make the two
comparators be symmetric, and refine the comments as well.

Suggested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
---
 tools/perf/arch/x86/util/evlist.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/perf/arch/x86/util/evlist.c b/tools/perf/arch/x86/util/evlist.c
index 438e4639fa89..447a734e591c 100644
--- a/tools/perf/arch/x86/util/evlist.c
+++ b/tools/perf/arch/x86/util/evlist.c
@@ -52,7 +52,7 @@ int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs)
 	 *          3,015,058      cycles
 	 *    <not supported>      topdown-retiring
 	 *
-	 * if slots event and topdown metrics events are in two groups, the group which
+	 * If slots event and topdown metrics events are in two groups, the group which
 	 * has topdown metrics events must contain only the topdown metrics event,
 	 * otherwise topdown metrics event can't be regrouped correctly as well, e.g.
 	 *
@@ -69,13 +69,16 @@ int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs)
 			return -1;
 		if (arch_is_topdown_slots(rhs))
 			return 1;
-		/* Followed by topdown events. */
-		if (arch_is_topdown_metrics(lhs) && !arch_is_topdown_metrics(rhs))
-			return -1;
+
 		/*
-		 * Move topdown events forward only when topdown events
-		 * are not in same group with previous event.
+		 * Move topdown metrics events forward only when topdown metrics
+		 * events are not in same group with previous slots event. If
+		 * topdown metrics events are already in same group with slots
+		 * event, do nothing.
 		 */
+		if (arch_is_topdown_metrics(lhs) && !arch_is_topdown_metrics(rhs) &&
+		    lhs->core.leader != rhs->core.leader)
+			return -1;
 		if (!arch_is_topdown_metrics(lhs) && arch_is_topdown_metrics(rhs) &&
 		    lhs->core.leader != rhs->core.leader)
 			return 1;

base-commit: 57fb40d40f9543213ffadb04d07cfb2ba46edc26
-- 
2.40.1


             reply	other threads:[~2024-10-11  8:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11 11:02 Dapeng Mi [this message]
2024-10-11 11:02 ` [PATCH 2/2] perf x86/topdown: Refine helper arch_is_topdown_metrics() Dapeng Mi
2024-10-16 17:37   ` Namhyung Kim
2024-10-16 17:55     ` Ian Rogers
2024-10-16 17:56 ` [PATCH 1/2] perf x86/topdown: Make topdown metrics comparators be symmetric Ian Rogers
2024-10-17 16:39 ` Namhyung Kim

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=20241011110207.1032235-1-dapeng1.mi@linux.intel.com \
    --to=dapeng1.mi@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dapeng1.mi@intel.com \
    --cc=irogers@google.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --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