[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250331172759.115604-1-leo.yan@arm.com>
Date: Mon, 31 Mar 2025 18:27:59 +0100
From: Leo Yan <leo.yan@....com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
"Liang, Kan" <kan.liang@...ux.intel.com>,
James Clark <james.clark@...aro.org>,
linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Leo Yan <leo.yan@....com>
Subject: [PATCH] perf tests switch-tracking: Fix timestamp comparison
The test might fail on the Arm64 platform with the error:
perf test -vvv "Track with sched_switch"
Missing sched_switch events
The issue is caused by incorrect handling of timestamp comparisons. The
comparison result, a signed 64-bit value, was being directly cast to an
int, leading to incorrect sorting for sched events.
Fix this by explicitly returning 0, 1, or -1 based on whether the result
is zero, positive, or negative.
Fixes: d44bc5582972 ("perf tests: Add a test for tracking with sched_switch")
Signed-off-by: Leo Yan <leo.yan@....com>
---
tools/perf/tests/switch-tracking.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index 8df3f9d9ffd2..6b3aac283c37 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -264,7 +264,7 @@ static int compar(const void *a, const void *b)
const struct event_node *nodeb = b;
s64 cmp = nodea->event_time - nodeb->event_time;
- return cmp;
+ return cmp < 0 ? -1 : (cmp > 0 ? 1 : 0);
}
static int process_events(struct evlist *evlist,
--
2.34.1
Powered by blists - more mailing lists