[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YkMUq/qrzEg5Mj1N@google.com>
Date: Tue, 29 Mar 2022 16:16:11 +0200
From: "Steinar H. Gunderson" <sesse@...gle.com>
To: Adrian Hunter <adrian.hunter@...el.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf intel-pt: Synthesize cycle events
On Tue, Mar 29, 2022 at 02:31:14PM +0200, Steinar H. Gunderson wrote:
> int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r)
> {
> if (!sym_l || !sym_r)
> return cmp_null(sym_l, sym_r);
>
> if (sym_l == sym_r)
> return 0;
>
> if (sym_l->inlined || sym_r->inlined) {
> int ret = strcmp(sym_l->name, sym_r->name);
>
> if (ret)
> return ret;
> if ((sym_l->start <= sym_r->end) && (sym_l->end >= sym_r->start))
> return 0;
> }
>
> if (sym_l->start != sym_r->start)
> return (int64_t)(sym_r->start - sym_l->start);
Even fixing <= to <, I do get nonsensical results like an inlined
(and very small) destructor taking 50%+ of CPU time, and having a huge
call chain under it. It largely goes away (I'm not sure if it's perfect)
if I remove the entire if (sym_l->inlined || ... branch, but I guess
it's there for a reason.
Thinking about it, I wonder if this code breaks the entire tree
invariant of comparison being transitive. If left _or_ right is inlined,
it compares them by name, but if not, it compares them by address. So
you can have three symbols A, B (inline) and C, where A < B (on name),
B < C (on name) but C < A (on address; assuming C has a lower start
address than A). That doesn't look good to me.
I'm wondering if the right fix would be something like replacing the
entire if with something like
if (sym_l->inlined && sym_r->inlined &&
strcmp(sym_l->name, sym_r->name) == 0) &&
<keep [start,end) overlap test here>) {
return 0;
}
but I'm not sure.
/* Steinar */
Powered by blists - more mailing lists