Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5412725ybl; Tue, 14 Jan 2020 08:31:23 -0800 (PST) X-Google-Smtp-Source: APXvYqzoDVdJV/2e0aon+EF4HQu54yVSmAlJ1jw7N6G0wXeHOM6X9DynzDYtfwApjxhXMaLTJn9y X-Received: by 2002:aca:4782:: with SMTP id u124mr17410052oia.93.1579019483489; Tue, 14 Jan 2020 08:31:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579019483; cv=none; d=google.com; s=arc-20160816; b=nl6sgpVnKuoubExP/HarisXbkmi6tSj2F+XPRrlxZpdTgec/37tH4zBAu66upqPZOU 7itG0w9bp9iuHShDUQwzJiFW1rXM1xtTq5yCFhofcazaH/QfE3fQgjQTGZOmwsIhYdFs o+kBlYivEJAE2Li2QJSVplDD0VvkU327g5LpzRjB4A5yO2usW5WyRgTK1WYqXWso7jPb LjXsbClZx6fggphJs/PimwNXalpf2lSG22liIDWqpK7ZPLoxcce+KxO2CmPM+HtuFkC6 RraN6JxIsheZjbHSPuPfbMS0iS26vu0pPDqVp9C4MNU10V3O1K9SscEzGYHMAFdWUlAY NP9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=IPYT5vQh2Yd4w7szH352o1kr3SakRWqAyBbk7sSmaIs=; b=lufirSggpINmAKJdFssQJ4dWWmthrr/PiKVo8+4L6OccRUZPnVLuXHsfu4dKN6NE5n IIqP9eCExq/AXRiHzLYgr7yho2Sdk9NdV/IY6qipGkjwP35KQbnX9KX77X+ANNxSI1s5 ESayUmny08acwICWOExUHqis458El4u4m32vHFHaEOs7CNDpeY6NvbRbEnN4isWPMlur Qzo53cg4/YV3XSQBXh8OOQfqdXRsBlwkfQ8AeoPRYBAiEQ3nahW+gIZQZPqth6bbqXzL jiwiqwhjIUuqWuWHr0rg3OGA4wQ5+4d5Tvon+2AXQlP3Y05BiWnRaLyrPhAtakLkRaUR s8fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZATTa1i1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14si9106722oti.33.2020.01.14.08.31.12; Tue, 14 Jan 2020 08:31:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZATTa1i1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728689AbgANQ3E (ORCPT + 99 others); Tue, 14 Jan 2020 11:29:04 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53941 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725904AbgANQ3E (ORCPT ); Tue, 14 Jan 2020 11:29:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579019343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IPYT5vQh2Yd4w7szH352o1kr3SakRWqAyBbk7sSmaIs=; b=ZATTa1i1ovuqN7g7acAoF8nX1tK2R9PgT10vbIVVEEcGyhG/+ouKzm2R/5O9QZKsNDlq6b nzqxlLQx9p+cEk2bvt5uV9/ZxEqOrW9VhvPPhNUkiP+We7V+dAnHpB9VSd3VUlIOwGnjaf +BNEZBS7xjOnHGbP2i4Pp5oFQKyFalM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-139-jZQy2EB5PPidwbylHzvu8Q-1; Tue, 14 Jan 2020 11:29:02 -0500 X-MC-Unique: jZQy2EB5PPidwbylHzvu8Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63A771143798; Tue, 14 Jan 2020 16:29:00 +0000 (UTC) Received: from sandy.ghostprotocols.net (ovpn-112-20.phx2.redhat.com [10.3.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C395550A8F; Tue, 14 Jan 2020 16:28:59 +0000 (UTC) Received: by sandy.ghostprotocols.net (Postfix, from userid 1000) id 78A26119; Tue, 14 Jan 2020 13:28:55 -0300 (BRT) Date: Tue, 14 Jan 2020 13:28:55 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Andres Freund , linux-kernel@vger.kernel.org, Jiri Olsa , Andi Kleen , Alexander Shishkin , Michael Petlan , Namhyung Kim , Peter Zijlstra , stable@vger.kernel.org Subject: Re: [PATCH] perf c2c: Fix sorting. Message-ID: <20200114162855.GD3115@redhat.com> References: <20200109043030.233746-1-andres@anarazel.de> <20200109084822.GD52936@krava> <20200109170041.wgvxcci3mkjh4uee@alap3.anarazel.de> <20200109214611.GC82989@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200109214611.GC82989@krava> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Thanks, applied. - Arnaldo