Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3439480imu; Sun, 11 Nov 2018 15:07:41 -0800 (PST) X-Google-Smtp-Source: AJdET5eye4bI0ijCqwdIOQnPn2HenxsaY2EHQ39b8oHeqf8F93is9H6A9MMx4krrYodmLXICSGCV X-Received: by 2002:a63:cc12:: with SMTP id x18mr10856079pgf.33.1541977661311; Sun, 11 Nov 2018 15:07:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977661; cv=none; d=google.com; s=arc-20160816; b=CD3xpMe0C7g1l+uXQ4x9HLPFZEuYpoRoWx6dE8VXzmY+XJH8E34SH50RX0ChnXZk9S yDGA+GVIP+M2lbLmR5mze7zw24pfWXO52zibUrI25/0ynXUTFAS6QVklepZbFChdlqJX 8RNPG0aA53OXMQ7W+vSROxe2H/3Ld9AR1UAGXPxD9VCVsLiNt5pFcEJD7M2oi1OLjfRb r1i/LtGvYUFdPowtQNdq+PPNj1mkLLn/FkmMf5CufZrp8TjfSjT2U9zeIjnXTwHEGalA gQYP6X9/J5642nDb04k+0hrjANu5qPbgGZVK5H0QRFDU6KGFpuOEApP5Pz0HqUIRhZ+l 8bJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ImkdfienPNlSP+5LqpVG53YhA3YNwBeGFlTiXKMuM+k=; b=QqDCV61AwULY8ZKtoSHd2BSW8Lzh1V6+uvqjto3EC3eY2iVStjpCI4IodWnqrIXNay H2T/5G6PJwww8I0GSd6Q4vvZeCIMp1wws7qIJrvyfSpBf/u1in/L58vlfiw8RIvtS3a9 IMLNrKFRFOXkv2UXOfiIRVh/pGkMYsUMxdvZf/0RJaDuwSqIhjSNBxElIWlf4p9vLQ+Z qhTMkPzM27jzxUHR4ZPJKcVqp+/inrVlBCbaysnXmQ693A8/Cl+r1vGVLL7ZPxqxCk6m YAUhAzieCZWJ2+fjquCq+BxmhQjz81KQ1sYLY5+PDygnqhcOBI1ULEUbNxvOVbWGCz0c NWtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ho4SYECV; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8-v6si14860282pgc.286.2018.11.11.15.07.26; Sun, 11 Nov 2018 15:07:41 -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=@kernel.org header.s=default header.b=Ho4SYECV; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389904AbeKLI5P (ORCPT + 99 others); Mon, 12 Nov 2018 03:57:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:51232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390307AbeKLIWK (ORCPT ); Mon, 12 Nov 2018 03:22:10 -0500 Received: from localhost (unknown [206.108.79.134]) (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 A2A0D223CB; Sun, 11 Nov 2018 22:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975532; bh=SA5wglS37YMdRV0bkI4/WhytO1h/7NNmgQ3I7JM4W/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ho4SYECV8L583Cw7+KSmRV1sAEnmf0y07eRDYZaZ0r95mPEfeM17FhnPuaROmc7XZ +xnENwXrSq+4LER1ZA5TGotgpPBHOf1x+x58LPGsH+ht/exee0rhR66le6jErml23e eNwR4aD0yZahv6suRYHu8pfPReh3EGVmILioskbc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Petlan , Jiri Olsa , Alexander Shishkin , Andi Kleen , Kan Liang , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.14 026/222] Revert "perf tools: Fix PMU term format max value calculation" Date: Sun, 11 Nov 2018 14:22:03 -0800 Message-Id: <20181111221650.640645838@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiri Olsa [ Upstream commit 1b9caa10b31dda0866f4028e4bfb923fb6e4072f ] 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 Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/pmu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -754,13 +754,14 @@ static void pmu_format_value(unsigned lo static __u64 pmu_format_max_value(const unsigned long *format) { - __u64 w = 0; - int fbit; + int w; - for_each_set_bit(fbit, format, PERF_PMU_FORMAT_BITS) - w |= (1ULL << fbit); - - return w; + w = bitmap_weight(format, PERF_PMU_FORMAT_BITS); + if (!w) + return 0; + if (w < 64) + return (1ULL << w) - 1; + return -1; } /*