linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: James Clark <james.clark@arm.com>
Cc: linux-perf-users@vger.kernel.org,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf tests: Fix flaky test 'Object code reading'
Date: Fri, 24 Sep 2021 15:53:35 -0300	[thread overview]
Message-ID: <YU4er4mzHfa4+7Jg@kernel.org> (raw)
In-Reply-To: <20210906152238.3415467-1-james.clark@arm.com>

Em Mon, Sep 06, 2021 at 04:22:38PM +0100, James Clark escreveu:
> This test occasionally fails on aarch64 when a sample is taken in
> free@plt and it fails with "Bytes read differ from those read by
> objdump". This is because that symbol is near a section boundary in the
> elf file. Despite the -z option to always output zeros, objdump uses
> bfd_map_over_sections() to iterate through the elf file so it doesn't
> see outside of the sections where these zeros are and can't print them.
> 
> For example this boundary proceeds free@plt in libc with a gap of 48
> bytes between .plt and .text:
> 
>   objdump -d -z --start-address=0x23cc8 --stop-address=0x23d08 libc-2.30.so
> 
>   libc-2.30.so:     file format elf64-littleaarch64
> 
>   Disassembly of section .plt:
> 
>   0000000000023cc8 <*ABS*+0x7fd00@plt+0x8>:
>      23cc8:	91018210 	add	x16, x16, #0x60
>      23ccc:	d61f0220 	br	x17
> 
>   Disassembly of section .text:
> 
>   0000000000023d00 <abort@@GLIBC_2.17-0x98>:
>      23d00:	a9bf7bfd 	stp	x29, x30, [sp, #-16]!
>      23d04:	910003fd 	mov	x29, sp
> 
> Taking a sample in free@plt is very rare because it is so small, but the
> test can be forced to fail almost every time on any platform by linking
> the test with a shared library that has a single empty function and
> calling it in a loop.
> 
> The fix is to zero the buffers so that when there is a jump in the
> addresses output by objdump, zeros are already filled in between.

Thanks, applied.

- Arnaldo

 
> Signed-off-by: James Clark <james.clark@arm.com>
> ---
>  tools/perf/tests/code-reading.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
> index 9866cddebf23..9b4a765e4b73 100644
> --- a/tools/perf/tests/code-reading.c
> +++ b/tools/perf/tests/code-reading.c
> @@ -229,8 +229,8 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
>  			    struct thread *thread, struct state *state)
>  {
>  	struct addr_location al;
> -	unsigned char buf1[BUFSZ];
> -	unsigned char buf2[BUFSZ];
> +	unsigned char buf1[BUFSZ] = {0};
> +	unsigned char buf2[BUFSZ] = {0};
>  	size_t ret_len;
>  	u64 objdump_addr;
>  	const char *objdump_name;
> -- 
> 2.28.0

-- 

- Arnaldo

      reply	other threads:[~2021-09-24 18:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06 15:22 [PATCH] perf tests: Fix flaky test 'Object code reading' James Clark
2021-09-24 18:53 ` Arnaldo Carvalho de Melo [this message]

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=YU4er4mzHfa4+7Jg@kernel.org \
    --to=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=james.clark@arm.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --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).