Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1768076ybl; Thu, 9 Jan 2020 01:04:31 -0800 (PST) X-Google-Smtp-Source: APXvYqxG3q049djXhDfY8pOtImL8FbAPTvkHVr+1nfa7hrWGR91TSzNhVue6zLhG9LUsfJkcRtC/ X-Received: by 2002:a05:6830:1d59:: with SMTP id p25mr7943861oth.308.1578560671535; Thu, 09 Jan 2020 01:04:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578560671; cv=none; d=google.com; s=arc-20160816; b=BphLdP42E2tP4eJzmu++kfozyYZE64RIsEs48iTNII4IRaW4D1yzpMUWPbgJL/ogWz 2AHvL+CxAREwrrDtvXKNj6i4rN2Lrdg5l71h5EJ+xUtsQW9ocyD3jQdEPFHfgLMlRYe/ /8j+0VT9omRfQjsOm26Su3TirVuARE7PXPEIB19ts3Yj46bJNUDmTiceYo9uo1N2vEXH thXEV7fSli8roVitHyprdJSMFujc413kP4yWB3id9M8a7oO09umRw5NN1GclOj3xGR5y Rxcz+eRJt2ozHPZKD478v2EtwL/Bdr51IqQrLv590rsC/E3F9+sAqNPPbu/8rdtGYCMt BJlA== 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=7gUnYXOKmpS/NEpT+R2hURrL5sPZKcFBzwobZVjhnkk=; b=uGskZyTC1z97w94Jad+7Uk5jLBAIdM8qbTpWDSGYvSi9X3JX1aLi3BWg1DyoFULwxM yoyYI3LouyY9LYPeEGpvAMqj2wCwRMqpAnmOnHFDkcDpERxwLzFZD/sBHRf8KqSm68N5 NtR31Ttem/9/wiY8fOiOcRT9a/7cn0r7Njg7HMXu/2raQzHwqqrDx7ZrDqdNudbG/3oH dv6MPWGBfPo/mAVOPFWSRZTu0vfAURxqgVZfSy15Nc48ELkEdvtly6BJupf9TQM8FOSz y5Yb4lcoEIxb2s8YKymUW2QXjipu2OGx9E1MVAIhVQgQrmvIfOBBixeNsbKNRSh2PXWC PMSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NJBHtW0x; 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 l12si3158320oib.254.2020.01.09.01.04.19; Thu, 09 Jan 2020 01:04:31 -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=NJBHtW0x; 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 S1728720AbgAIIsd (ORCPT + 99 others); Thu, 9 Jan 2020 03:48:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:48838 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728448AbgAIIsd (ORCPT ); Thu, 9 Jan 2020 03:48:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578559711; 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=7gUnYXOKmpS/NEpT+R2hURrL5sPZKcFBzwobZVjhnkk=; b=NJBHtW0xn5JCsHSIrKofmXfYHFcT/Cj7wYlK/MRvwsGAL9dzFHl2TWBcsr0awMLL7fsUJ6 fpW3LAChVTAht3vZQyRLppbzV4IvVo5et+MZPceHpsF+jgXJNkR75JO5yCDxWdmHxxhmhH BLuoRudaTt8ErKUjjD/OpYdur4i1b/8= 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-405-CnYy1Ns1Od6kEkzjCocMXg-1; Thu, 09 Jan 2020 03:48:28 -0500 X-MC-Unique: CnYy1Ns1Od6kEkzjCocMXg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AAA79107ACC4; Thu, 9 Jan 2020 08:48:26 +0000 (UTC) Received: from krava (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA83A10013A7; Thu, 9 Jan 2020 08:48:24 +0000 (UTC) Date: Thu, 9 Jan 2020 09:48:22 +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: <20200109084822.GD52936@krava> References: <20200109043030.233746-1-andres@anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200109043030.233746-1-andres@anarazel.de> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 08, 2020 at 08:30:30PM -0800, Andres Freund wrote: > Commit 722ddfde366f ("perf tools: Fix time sorting") changed - > correctly so - hist_entry__sort to return int64. Unfortunately several > of the builtin-c2c.c comparison routines only happened to work due the > cast caused by the wrong return type. > > This causes meaningless ordering of both the cacheline list, and the > cacheline details page. E.g a simple > perf c2c record -a sleep 3 > perf c2c report > will result in cacheline table like > ================================================= > Shared Data Cache Line Table > ================================================= > # > # ----------- Cacheline ---------- Total Tot ----- LLC Load Hitm ----- ---- Store Reference ---- --- Load Dram ---- LLC Total ----- Core Load Hit ----- -- LLC Load Hit -- > # Index Address Node PA cnt records Hitm Total Lcl Rmt Total L1Hit L1Miss Lcl Rmt Ld Miss Loads FB L1 L2 Llc Rmt > # ..... .................. .... ...... ....... ....... ....... ....... ....... ....... ....... ....... ........ ........ ....... ....... ....... ....... ....... ........ ........ > # > 0 0x7f0d27ffba00 N/A 0 52 0.12% 13 6 7 12 12 0 0 7 14 40 4 16 0 0 0 > 1 0x7f0d27ff61c0 N/A 0 6353 14.04% 1475 801 674 779 779 0 0 718 1392 5574 1299 1967 0 115 0 > 2 0x7f0d26d3ec80 N/A 0 71 0.15% 16 4 12 13 13 0 0 12 24 58 1 20 0 9 0 > 3 0x7f0d26d3ec00 N/A 0 98 0.22% 23 17 6 19 19 0 0 6 12 79 0 40 0 10 0 > i.e. with the list not being ordered by Total Hitm. > > Fixes: 722ddfde366f ("perf tools: Fix time sorting") > Signed-off-by: Andres Freund > Cc: Jiri Olsa > Cc: Andi Kleen > Cc: Arnaldo Carvalho de Melo > Cc: Alexander Shishkin > Cc: Michael Petlan > Cc: Namhyung Kim > Cc: Peter Zijlstra > Cc: stable@vger.kernel.org # v3.16+ > --- > 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'? thanks, jirka > > c2c_left = container_of(left, struct c2c_hist_entry, he); > c2c_right = container_of(right, struct c2c_hist_entry, he); > @@ -629,7 +629,8 @@ __f ## _cmp(struct perf_hpp_fmt *fmt __maybe_unused, \ > \ > c2c_left = container_of(left, struct c2c_hist_entry, he); \ > c2c_right = container_of(right, struct c2c_hist_entry, he); \ > - return c2c_left->stats.__f - c2c_right->stats.__f; \ > + return (uint64_t) c2c_left->stats.__f - \ > + (uint64_t) c2c_right->stats.__f; \ > } > > #define STAT_FN(__f) \ > @@ -682,7 +683,8 @@ ld_llcmiss_cmp(struct perf_hpp_fmt *fmt __maybe_unused, > c2c_left = container_of(left, struct c2c_hist_entry, he); > c2c_right = container_of(right, struct c2c_hist_entry, he); > > - return llc_miss(&c2c_left->stats) - llc_miss(&c2c_right->stats); > + return (uint64_t) llc_miss(&c2c_left->stats) - > + (uint64_t) llc_miss(&c2c_right->stats); > } > > static uint64_t total_records(struct c2c_stats *stats) > -- > 2.25.0.rc1 >