Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2492289ybl; Thu, 9 Jan 2020 13:47:54 -0800 (PST) X-Google-Smtp-Source: APXvYqylGXKl6tpcNfStqI+kjAPdU/00LmSNa3oxQAuJQKKrSZatCllqAqc/77lDH5ICA4aboDLr X-Received: by 2002:a05:6830:194:: with SMTP id q20mr18853ota.92.1578606474454; Thu, 09 Jan 2020 13:47:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578606474; cv=none; d=google.com; s=arc-20160816; b=Qu1GNjLBI6kkTSf+UgkfTXvwXnvnlCMs/Fh4X4IE87Mz6Ra2ey0kuoc7Onfa5SMQ2I /6or68Eq18gOH8Kz5q0dIP67osuyTi2jYPklLOozCkcMrXfypG2df3/fvtpYSTyYxh4O NMFQORvLPTSPLdnnfyjD97RFaLWWHF0o77q+Rkd/4U6/9aJzKXqa1ggQJYOJY6/7PJl0 xFlytjPJMMovdqfhs/yaQLDL184GltXDDdsJvo6qbgM4LqEPWZwVIQ14G/V3/SbnpUP9 5v3J0bm7+sr9vwBPH1ZMCUuZD9lyD7oLABRRY+xq3RK7sXNoAuyogYFs37NafpWgMf7W bSKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ZbAF9d7fjB7aZO4keNV6FYG7yhXE6/ctJ0M/uR6RLjI=; b=TSWNFK6msz2jToQxqFvHl09X+5zDdwMWqrr/nT1/IZRiptHvHGvEC0DQ0d5M1kiTN1 e1z0ZS1KNtK18e2lbzMM5G+x56KO7RYtfDAtUF+jnPGgl4OVZo9hu2KX1mesimaQ3BfJ FmjuHdt4hvm7frGKdst2EnR/RbLcXoLNwtdKy37us7P2JyIW8zRNBkQQNXA/CHgFvlla R9RasBLniSJJcJAbZEL/VwN/X1lGUweW0UHRLTPPNfwT0QfoM/uryXgEZ4o7kOp4bXML L5bfsKNZsGHv6pIs/GTu8wtoWN6BUmqOFHkukrluYwtj8aPttp2m+OaNAl0gJybZkCpF aABQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="AC/NQy55"; 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 n203si4205591oia.112.2020.01.09.13.47.42; Thu, 09 Jan 2020 13:47:54 -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="AC/NQy55"; 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 S1728832AbgAIVqW (ORCPT + 99 others); Thu, 9 Jan 2020 16:46:22 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:23814 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725763AbgAIVqW (ORCPT ); Thu, 9 Jan 2020 16:46:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578606381; 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=ZbAF9d7fjB7aZO4keNV6FYG7yhXE6/ctJ0M/uR6RLjI=; b=AC/NQy55Tph1GZL0hgGWTMCqWxVo1kdDpPPwf7nPaUrIUgjsCVdMSumnYDcPNY78m2tAc0 yp1eOdO7VuEouXqxALyS2mSyxBK/fkAMil/Ajag8p7I/FsxYf2ZFSzXDqwSgsaU2wUaY8t W0k+OZbId2cUYtx3+4y+6Mk9QfJZKMI= 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-276--ATCng3CP3KnlYqAzwkAQA-1; Thu, 09 Jan 2020 16:46:17 -0500 X-MC-Unique: -ATCng3CP3KnlYqAzwkAQA-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 5709010054E3; Thu, 9 Jan 2020 21:46:16 +0000 (UTC) Received: from krava (ovpn-204-81.brq.redhat.com [10.40.204.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DD59620A6; Thu, 9 Jan 2020 21:46:13 +0000 (UTC) Date: Thu, 9 Jan 2020 22:46:11 +0100 From: Jiri Olsa To: Andres Freund Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Andi Kleen , Arnaldo Carvalho de Melo , Alexander Shishkin , Michael Petlan , Namhyung Kim , Peter Zijlstra , stable@vger.kernel.org Subject: Re: [PATCH] perf c2c: Fix sorting. Message-ID: <20200109214611.GC82989@krava> References: <20200109043030.233746-1-andres@anarazel.de> <20200109084822.GD52936@krava> <20200109170041.wgvxcci3mkjh4uee@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200109170041.wgvxcci3mkjh4uee@alap3.anarazel.de> 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 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, jirka