All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Andres Freund <andres@anarazel.de>,
	linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Michael Petlan <mpetlan@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH] perf c2c: Fix sorting.
Date: Tue, 14 Jan 2020 13:28:55 -0300	[thread overview]
Message-ID: <20200114162855.GD3115@redhat.com> (raw)
In-Reply-To: <20200109214611.GC82989@krava>

Em Thu, Jan 09, 2020 at 10:46:11PM +0100, Jiri Olsa escreveu:
> On Thu, Jan 09, 2020 at 09:00:41AM -0800, Andres Freund wrote:
> 
> SNIP
> 
> > > >  tools/perf/builtin-c2c.c | 10 ++++++----
> > > >  1 file changed, 6 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> > > > index e69f44941aad..f2e9d2b1b913 100644
> > > > --- a/tools/perf/builtin-c2c.c
> > > > +++ b/tools/perf/builtin-c2c.c
> > > > @@ -595,8 +595,8 @@ tot_hitm_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
> > > >  {
> > > >  	struct c2c_hist_entry *c2c_left;
> > > >  	struct c2c_hist_entry *c2c_right;
> > > > -	unsigned int tot_hitm_left;
> > > > -	unsigned int tot_hitm_right;
> > > > +	uint64_t tot_hitm_left;
> > > > +	uint64_t tot_hitm_right;
> > > 
> > > that change looks right, but I can't see how that could
> > > happened because of change in Fixes: tag
> > > 
> > > was the return statement of this function:
> > > 
> > >         return tot_hitm_left - tot_hitm_right;
> > > 
> > > considered to be 'unsigned int' and then converted to int64_t,
> > > which would treat negative 'unsigned int' as big positive 'int64_t'?
> > 
> > Correct. So e.g. when comparing 1 and 2 tot_hitm, we'd get (int64_t)
> > UINT_MAX as a result, which is obviously wrong. However, due to
> > hist_entry__sort() returning int at the time, this was masked, as the
> > int64_t was cast to int. Thereby again yielding a negative number for
> > the comparisons of hist_entry__sort()'s result.  After
> > hist_entry__sort() was fixed however, there never could be negative
> > return values (but 0's are possible) of hist_entry__sort() for c2c.
> 
> I see.. ok
> 
> Acked-by: Jiri Olsa <jolsa@redhat.com>

Thanks, applied.

- Arnaldo


  reply	other threads:[~2020-01-14 16:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-09  4:30 [PATCH] perf c2c: Fix sorting Andres Freund
2020-01-09  8:48 ` Jiri Olsa
2020-01-09 17:00   ` Andres Freund
2020-01-09 21:46     ` Jiri Olsa
2020-01-14 16:28       ` Arnaldo Carvalho de Melo [this message]
2020-01-09  9:58 ` Michael Petlan
2020-01-09 13:18   ` Arnaldo Carvalho de Melo
2020-01-09 13:22     ` Jiri Olsa
2020-01-20  8:27 ` [tip: perf/core] perf c2c: Fix return type for histogram sorting comparision functions tip-bot2 for Andres Freund

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=20200114162855.GD3115@redhat.com \
    --to=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andres@anarazel.de \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpetlan@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.