[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aC_WFRe_4HjVPUrM@x1>
Date: Thu, 22 May 2025 22:57:41 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Leo Yan <leo.yan@....com>
Cc: 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
Subject: Re: [PATCH] perf tests switch-tracking: Fix timestamp comparison
On Thu, May 22, 2025 at 10:55:46PM -0300, Arnaldo Carvalho de Melo wrote:
> On Mon, Mar 31, 2025 at 06:27:59PM +0100, Leo Yan wrote:
> > 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>
>
> How can I reproduce this?
>
> Testing on a rpi5, 64-bit debian, this test passes:
>
> root@...pberrypi:~# uname -a
> Linux raspberrypi 6.12.25+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.12.25-1+rpt1 (2025-04-30) aarch64 GNU/Linux
> root@...pberrypi:~# perf test -vvv "Track with sched_switch" |& tail -50
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> cycles event
> sched_switch: cpu: 3 prev_tid 208750 next_tid 0
> sched_switch: cpu: 2 prev_tid 0 next_tid 195941
> sched_switch: cpu: 2 prev_tid 195941 next_tid 208748
> sched_switch: cpu: 2 prev_tid 208748 next_tid 0
> sched_switch: cpu: 3 prev_tid 0 next_tid 208750
> sched_switch: cpu: 3 prev_tid 208750 next_tid 34
> sched_switch: cpu: 3 prev_tid 34 next_tid 0
> sched_switch: cpu: 0 prev_tid 0 next_tid 208750
> sched_switch: cpu: 0 prev_tid 208750 next_tid 21
> sched_switch: cpu: 0 prev_tid 21 next_tid 0
> sched_switch: cpu: 1 prev_tid 0 next_tid 208750
> sched_switch: cpu: 1 prev_tid 208750 next_tid 24
> sched_switch: cpu: 1 prev_tid 24 next_tid 0
> sched_switch: cpu: 2 prev_tid 0 next_tid 208750
> sched_switch: cpu: 2 prev_tid 208750 next_tid 29
> sched_switch: cpu: 3 prev_tid 0 next_tid 208750
> sched_switch: cpu: 2 prev_tid 29 next_tid 0
> sched_switch: cpu: 3 prev_tid 208750 next_tid 34
> sched_switch: cpu: 3 prev_tid 34 next_tid 0
> sched_switch: cpu: 0 prev_tid 0 next_tid 208750
> sched_switch: cpu: 1 prev_tid 0 next_tid 208750
> sched_switch: cpu: 2 prev_tid 0 next_tid 208750
> sched_switch: cpu: 3 prev_tid 0 next_tid 208750
> 507 events recorded
> ---- end(0) ----
> 109: Track with sched_switch : Ok
> root@...pberrypi:~#
Further info:
acme@...pberrypi:~/git/perf-tools-next $ readelf -wi ~/bin/perf | head -40
Contents of the .debug_info section:
Compilation Unit @ offset 0:
Length: 0x79b (32-bit)
Version: 5
Unit Type: DW_UT_compile (1)
Abbrev Offset: 0
Pointer Size: 8
<0><c>: Abbrev Number: 22 (DW_TAG_compile_unit)
<d> DW_AT_producer : (indirect string, offset: 0x9401): GNU C99 12.2.0 -mlittle-endian -mabi=lp64 -ggdb3 -std=gnu99 -fPIC -fasynchronous-unwind-tables
<11> DW_AT_language : 12 (ANSI C99)
<12> DW_AT_name : (indirect line string, offset: 0): fd/array.c
<16> DW_AT_comp_dir : (indirect line string, offset: 0xb): /home/acme/git/perf-tools-next/tools/lib/api
<1a> DW_AT_low_pc : 0xf80a0
<22> DW_AT_high_pc : 0x650
<2a> DW_AT_stmt_list : 0
<2e> DW_AT_macros : 0
<1><32>: Abbrev Number: 9 (DW_TAG_typedef)
<33> DW_AT_name : (indirect string, offset: 0x44a1): size_t
<37> DW_AT_decl_file : 2
<38> DW_AT_decl_line : 214
<39> DW_AT_decl_column : 23
<3a> DW_AT_type : <0x3e>
<1><3e>: Abbrev Number: 5 (DW_TAG_base_type)
<3f> DW_AT_byte_size : 8
<40> DW_AT_encoding : 7 (unsigned)
<41> DW_AT_name : (indirect string, offset: 0x137b): long unsigned int
<1><45>: Abbrev Number: 23 (DW_TAG_pointer_type)
<46> DW_AT_byte_size : 8
<1><47>: Abbrev Number: 24 (DW_TAG_base_type)
<48> DW_AT_byte_size : 4
<49> DW_AT_encoding : 5 (signed)
<4a> DW_AT_name : int
<1><4e>: Abbrev Number: 5 (DW_TAG_base_type)
<4f> DW_AT_byte_size : 1
<50> DW_AT_encoding : 8 (unsigned char)
<51> DW_AT_name : (indirect string, offset: 0x18e6): unsigned char
<1><55>: Abbrev Number: 5 (DW_TAG_base_type)
<56> DW_AT_byte_size : 2
<57> DW_AT_encoding : 7 (unsigned)
acme@...pberrypi:~/git/perf-tools-next $
Powered by blists - more mailing lists