Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932221AbcDFHJW (ORCPT ); Wed, 6 Apr 2016 03:09:22 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57922 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754676AbcDFHJU (ORCPT ); Wed, 6 Apr 2016 03:09:20 -0400 Date: Wed, 6 Apr 2016 00:09:05 -0700 From: tip-bot for Kan Liang Message-ID: Cc: jolsa@redhat.com, tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org, acme@redhat.com, ak@linux.intel.com, alexander.shishkin@linux.intel.com, kan.liang@intel.com, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, kan.liang@intel.com, ak@linux.intel.com, alexander.shishkin@linux.intel.com, acme@redhat.com, mingo@kernel.org, hpa@zytor.com, tglx@linutronix.de, jolsa@redhat.com In-Reply-To: <1459365375-14285-1-git-send-email-kan.liang@intel.com> References: <1459365375-14285-1-git-send-email-kan.liang@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Fix PMU term format max value calculation Git-Commit-ID: ac0e2cd555373ae6f8f3a3ad3fbbf5b6d1e7aaaa 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 Content-Length: 1898 Lines: 58 Commit-ID: ac0e2cd555373ae6f8f3a3ad3fbbf5b6d1e7aaaa Gitweb: http://git.kernel.org/tip/ac0e2cd555373ae6f8f3a3ad3fbbf5b6d1e7aaaa Author: Kan Liang AuthorDate: Wed, 30 Mar 2016 12:16:15 -0700 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 1 Apr 2016 18:46:24 -0300 perf tools: Fix PMU term format max value calculation Currently the max value of format is calculated by the bits number. It relies on the continuity of the format. However, uncore event format is not continuous. E.g. uncore qpi event format can be 0-7,21. If bit 21 is set, there is parsing issues as below. $ perf stat -a -e uncore_qpi_0/event=0x200002,umask=0x8/ event syntax error: '..pi_0/event=0x200002,umask=0x8/' \___ value too big for format, maximum is 511 This patch return the real max value by setting all possible bits to 1. Signed-off-by: Kan Liang Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Link: http://lkml.kernel.org/r/1459365375-14285-1-git-send-email-kan.liang@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/pmu.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index adef23b..bf34468 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -602,14 +602,13 @@ static void pmu_format_value(unsigned long *format, __u64 value, __u64 *v, static __u64 pmu_format_max_value(const unsigned long *format) { - int w; + __u64 w = 0; + int fbit; - w = bitmap_weight(format, PERF_PMU_FORMAT_BITS); - if (!w) - return 0; - if (w < 64) - return (1ULL << w) - 1; - return -1; + for_each_set_bit(fbit, format, PERF_PMU_FORMAT_BITS) + w |= (1ULL << fbit); + + return w; } /*