linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Leo Yan <leo.yan@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>,
	Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"Liang, Kan" <kan.liang@linux.intel.com>,
	James Clark <james.clark@linaro.org>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf tests switch-tracking: Fix timestamp comparison
Date: Thu, 22 May 2025 22:57:41 -0300	[thread overview]
Message-ID: <aC_WFRe_4HjVPUrM@x1> (raw)
In-Reply-To: <aC_Vn95vYqcXul03@x1>

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@arm.com>
> 
> How can I reproduce this?
> 
> Testing on a rpi5, 64-bit debian, this test passes:
> 
> root@raspberrypi:~# 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@raspberrypi:~# 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@raspberrypi:~#

Further info:

acme@raspberrypi:~/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@raspberrypi:~/git/perf-tools-next $

  reply	other threads:[~2025-05-23  1:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31 17:27 [PATCH] perf tests switch-tracking: Fix timestamp comparison Leo Yan
2025-03-31 20:18 ` Ian Rogers
2025-04-01  9:14   ` Leo Yan
2025-04-01 19:54     ` Ian Rogers
2025-04-02  9:05       ` Leo Yan
2025-05-16 15:31         ` Leo Yan
2025-05-20  1:52           ` Namhyung Kim
2025-05-23  1:49             ` Arnaldo Carvalho de Melo
2025-05-23  1:51               ` Arnaldo Carvalho de Melo
2025-05-23  1:55 ` Arnaldo Carvalho de Melo
2025-05-23  1:57   ` Arnaldo Carvalho de Melo [this message]
2025-05-23  8:10     ` Leo Yan
2025-05-23 16:52       ` Ian Rogers
2025-05-23 17:12       ` Arnaldo Carvalho de Melo
2025-05-27  9:49         ` Leo Yan
2025-05-28 13:08           ` Arnaldo Carvalho de Melo

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=aC_WFRe_4HjVPUrM@x1 \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=kan.liang@linux.intel.com \
    --cc=leo.yan@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).