From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: "Vanderson M . do Rosario" <vandersonmr2@gmail.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 1/1] tcg: add perfmap and jitdump
Date: Tue, 18 Oct 2022 04:22:47 +0200 [thread overview]
Message-ID: <39000ad459f08256c95d3add81cab7549528fa57.camel@linux.ibm.com> (raw)
In-Reply-To: <cd7d0223-f539-982b-cc52-96b9c2f7b1ad@linaro.org>
On Fri, 2022-10-14 at 07:35 +1100, Richard Henderson wrote:
> On 10/12/22 22:18, Ilya Leoshkevich wrote:
> > Add ability to dump /tmp/perf-<pid>.map and jit-<pid>.dump.
> > The first one allows the perf tool to map samples to each
> > individual
> > translation block. The second one adds the ability to resolve
> > symbol
> > names, line numbers and inspect JITed code.
> >
> > Example of use:
> >
> > perf record qemu-x86_64 -perfmap ./a.out
> > perf report
> >
> > or
> >
> > perf record -k 1 qemu-x86_64 -jitdump ./a.out
> > perf inject -j -i perf.data -o perf.data.jitted
> > perf report -i perf.data.jitted
> >
> > Co-developed-by: Vanderson M. do Rosario <vandersonmr2@gmail.com>
> > Co-developed-by: Alex Bennée <alex.bennee@linaro.org>
> > Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
>
> I think I remember this, and the question that was never answered
> was:
>
> > @@ -1492,6 +1493,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
> > }
> > tb->tc.size = gen_code_size;
> >
> > + perf_report_code(gen_code_buf, gen_code_size, tb->icount, tb-
> > >pc);
>
> When do_tb_flush is called, everything that is recorded in perfmap is
> invalidated.
> How do you tell perf about that?
>
>
> r~
>
I don't think we should handle this altogether. Perf already knows how
to handle overlapping addresses:
$ cat main.c
#include <dlfcn.h>
#include <stdio.h>
int main()
{
void *d = dlopen("./lib1.so", RTLD_NOW);
void (*f)(void) = dlsym(d, "f");
printf("%p\n", f);
f();
dlclose(d);
d = dlopen("./lib2.so", RTLD_NOW);
f = dlsym(d, "f");
printf("%p\n", f);
f();
dlclose(d);
}
$ cat 1.c
static volatile int i = 0;
void f(void) {
while (i < 1000000000) {
i++;
}
}
$ gcc -o main -O3 -g main.c -ldl
$ gcc -o lib1.so -shared -fPIC -O3 -g 1.c
$ cp 1.c 2.c
$ gcc -o lib2.so -shared -fPIC -O3 -g 2.c
$ perf record ./main
0x7f47925eb100
0x7f47925eb100
$ perf report
49.96% main lib1.so [.] f
49.92% main lib2.so [.] f
Note that there is "load" event - PERF_RECORD_MMAP2, but no "unload"
event. The old mappings are simply discarded by
maps__fixup_overlappings() when something new is mapped.
In our case this means that as soon as we JIT new code, perf will see
that it replaced the one that was flushed. Until then it will live with
stale mappings, but there is no harm in that, since they are not
executed.
next prev parent reply other threads:[~2022-10-18 2:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 5:18 [PATCH RFC 0/1] tcg: add perfmap and jitdump Ilya Leoshkevich
2022-10-12 5:18 ` [PATCH 1/1] " Ilya Leoshkevich
2022-10-13 20:35 ` Richard Henderson
2022-10-18 2:22 ` Ilya Leoshkevich [this message]
2022-10-28 8:39 ` Christian Borntraeger
2022-11-07 11:04 ` Alex Bennée
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=39000ad459f08256c95d3add81cab7549528fa57.camel@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=alex.bennee@linaro.org \
--cc=borntraeger@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=vandersonmr2@gmail.com \
/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).