Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1227148imm; Wed, 17 Oct 2018 15:56:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV613GXgzDqXb9VSogWkEspDIPiCo3JqoKcfFKqx5aCFMHrPdkemiSmtnwREXBhfZFR+8A/H1 X-Received: by 2002:a63:a40a:: with SMTP id c10-v6mr26600905pgf.140.1539816972986; Wed, 17 Oct 2018 15:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816972; cv=none; d=google.com; s=arc-20160816; b=W/w0MBvR3I+EnwiHaB17F3qrO8qsO3j6iWv28wecsw7qn/WKVFyrgREXXUcJxczaTz 36Vndm72RrlOqLrU5A1Dfo9uY7vE94AK8mUE6X0eAUop8mOeftxO8J8QoG2jGfPSoHRp Y3Dtngm+0wwFcuizgTJ/a3djdOm909MHIq6koL62oraNkN36BWkbA46Tw3t61m6xzdvW Me1UFJbYteHnmqmWUJ9bKF/8Yxqv5Avc6ms+UFSJMdw2KO//6B3o6cS5VjOprI3CCs+c fpd4q+rU3vT3BVDs7rknSFl22kXHBo6WgtxE+DoUW2vdsuqzmg8SECzzLVJB0WkHD6jq wMMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=bTXWXT4WP/Z4jwkCOekY8XSndwLnDHZ91QTP/6iUBq4=; b=FuFqwYiewGX0SEUTThP1gnRZXxrj2GbRigKBj7vEJCKtv2TxxXesVdpIicGFIsNbZY TGSWsTJySMJqKBKmGTcVKjjmOeK+0Qt26+1mxzwR15FYxmoPr2LThBGbcc3YHXMVof9s f55MG14vHldZkPdnATD6/UKmTuAIvrVzffHbB39F1Ff1CX+30pZOS5gdx1OP5R33HQ3Q wqs4y/D5a7rIM6oqHi3/2Mk9dRVx7yTRDN0a0iwXlu8QuHt4z0T5RJ7EuCd6DgDR2VCt nmwiLI8KJfieKo3p5KYaxJR8VumJCgofnqkHoi4GenhgKaUH6HqTuyZRI5ac1TZgeHe5 WlSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VyEGMhrB; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bf12-v6si18034337plb.22.2018.10.17.15.55.57; Wed, 17 Oct 2018 15:56:12 -0700 (PDT) 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=@kernel.org header.s=default header.b=VyEGMhrB; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727640AbeJRGxY (ORCPT + 99 others); Thu, 18 Oct 2018 02:53:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:41890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbeJRGxY (ORCPT ); Thu, 18 Oct 2018 02:53:24 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5835621479; Wed, 17 Oct 2018 22:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539816930; bh=nQRzyft1tm4Z80dXsaBl5A/uAphA8Sk12OFAMu4qOWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VyEGMhrBlvb+HQO3sWq6zmiB3OQfYi1G+uc0PmWYRjmO34aSMvry2qtEtFr1g2IfR GneQSSZ/gNPN4AnVPT1YqO9kkn/a4iSzusLDJCe0BtYyM7g2tpyubuE7/KbqGsd6UP GSsjwc2L+WEW/PjEo51W7bk9OVCqvdHPlmwXidg8= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Jiri Olsa , Alexander Shishkin , Andi Kleen , Kan Liang , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 03/11] Revert "perf tools: Fix PMU term format max value calculation" Date: Wed, 17 Oct 2018 19:54:53 -0300 Message-Id: <20181017225501.32150-4-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181017225501.32150-1-acme@kernel.org> References: <20181017225501.32150-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa This reverts commit ac0e2cd555373ae6f8f3a3ad3fbbf5b6d1e7aaaa. Michael reported an issue with oversized terms values assignment and I noticed there was actually a misunderstanding of the max value check in the past. The above commit's changelog says: 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 But there's no issue there, because the event value is distributed along the value defined by the format. Even if the format defines separated bit, the value is treated as a continual number, which should follow the format definition. In above case it's 9-bit value with last bit separated: $ cat uncore_qpi_0/format/event config:0-7,21 Hence the value 0x200002 is correctly reported as format violation, because it exceeds 9 bits. It should have been 0x102 instead, which sets the 9th bit - the bit 21 of the format. $ perf stat -vv -a -e uncore_qpi_0/event=0x102,umask=0x8/ Using CPUID GenuineIntel-6-2D ... ------------------------------------------------------------ perf_event_attr: type 10 size 112 config 0x200802 sample_type IDENTIFIER ... Reported-by: Michael Petlan Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Kan Liang Cc: Namhyung Kim Cc: Peter Zijlstra Fixes: ac0e2cd55537 ("perf tools: Fix PMU term format max value calculation") Link: http://lkml.kernel.org/r/20181003072046.29276-1-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/pmu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index afd68524ffa9..7799788f662f 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -930,13 +930,14 @@ static void pmu_format_value(unsigned long *format, __u64 value, __u64 *v, static __u64 pmu_format_max_value(const unsigned long *format) { - __u64 w = 0; - int fbit; - - for_each_set_bit(fbit, format, PERF_PMU_FORMAT_BITS) - w |= (1ULL << fbit); + int w; - return w; + w = bitmap_weight(format, PERF_PMU_FORMAT_BITS); + if (!w) + return 0; + if (w < 64) + return (1ULL << w) - 1; + return -1; } /* -- 2.14.4