From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752487AbdHNRqX (ORCPT ); Mon, 14 Aug 2017 13:46:23 -0400 Received: from terminus.zytor.com ([65.50.211.136]:35819 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751427AbdHNRqV (ORCPT ); Mon, 14 Aug 2017 13:46:21 -0400 Date: Mon, 14 Aug 2017 10:43:59 -0700 From: tip-bot for Andi Kleen Message-ID: Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, acme@redhat.com, jolsa@kernel.org, tglx@linutronix.de, ak@linux.intel.com, hpa@zytor.com Reply-To: hpa@zytor.com, ak@linux.intel.com, jolsa@kernel.org, tglx@linutronix.de, acme@redhat.com, linux-kernel@vger.kernel.org, mingo@kernel.org In-Reply-To: <20170724234015.5165-4-andi@firstfloor.org> References: <20170724234015.5165-4-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf stat: Fix saved values rbtree lookup Git-Commit-ID: 5e97665f91d343b5bcf1f92249e45e18987ffd00 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 5e97665f91d343b5bcf1f92249e45e18987ffd00 Gitweb: http://git.kernel.org/tip/5e97665f91d343b5bcf1f92249e45e18987ffd00 Author: Andi Kleen AuthorDate: Mon, 24 Jul 2017 16:40:03 -0700 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 11 Aug 2017 10:42:52 -0300 perf stat: Fix saved values rbtree lookup The stat shadow saved values rbtree is indexed by a pointer. Fix the comparison function: - We cannot return a pointer delta as an int because that loses bits on 64bit. - Doing pointer arithmetic on the struct pointer only works if the objects are spaced by the multiple of the object size, which is not guaranteed for individual malloc'ed object Replace it with a proper comparison. This fixes various problems with values not being found. Signed-off-by: Andi Kleen Acked-by: Jiri Olsa Link: http://lkml.kernel.org/r/20170724234015.5165-4-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/stat-shadow.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 719d6cb..a04cf56 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -70,7 +70,11 @@ static int saved_value_cmp(struct rb_node *rb_node, const void *entry) return a->ctx - b->ctx; if (a->cpu != b->cpu) return a->cpu - b->cpu; - return a->evsel - b->evsel; + if (a->evsel == b->evsel) + return 0; + if ((char *)a->evsel < (char *)b->evsel) + return -1; + return +1; } static struct rb_node *saved_value_new(struct rblist *rblist __maybe_unused,