linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Jiri Olsa <jolsa@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 03/11] Revert "perf tools: Fix PMU term format max value calculation"
Date: Wed, 17 Oct 2018 19:54:53 -0300	[thread overview]
Message-ID: <20181017225501.32150-4-acme@kernel.org> (raw)
In-Reply-To: <20181017225501.32150-1-acme@kernel.org>

From: Jiri Olsa <jolsa@kernel.org>

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 <mpetlan@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
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 <acme@redhat.com>
---
 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


  parent reply	other threads:[~2018-10-17 22:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-17 22:54 [GIT PULL 00/11] perf/urgent fixes Arnaldo Carvalho de Melo
2018-10-17 22:54 ` [PATCH 01/11] tools arch uapi: Sync the x86 kvm.h copy Arnaldo Carvalho de Melo
2018-10-17 22:54 ` [PATCH 02/11] tools headers uapi: Sync " Arnaldo Carvalho de Melo
2018-10-17 22:54 ` Arnaldo Carvalho de Melo [this message]
2018-10-17 22:54 ` [PATCH 04/11] perf vendor events intel: Fix wrong filter_band* values for uncore events Arnaldo Carvalho de Melo
2018-10-17 22:54 ` [PATCH 05/11] perf evsel: Store ids for events with their own cpus perf_event__synthesize_event_update_cpus Arnaldo Carvalho de Melo
2018-10-17 22:54 ` [PATCH 06/11] perf tools: Fix use of alternatives to find JDIR Arnaldo Carvalho de Melo
2018-10-17 22:54 ` [PATCH 07/11] perf tools: Fix tracing_path_mount proper path Arnaldo Carvalho de Melo
2018-10-17 22:54 ` [PATCH 08/11] perf cpu_map: Align cpu map synthesized events properly Arnaldo Carvalho de Melo
2018-10-17 22:54 ` [PATCH 09/11] perf report: Don't crash on invalid inline debug information Arnaldo Carvalho de Melo
2018-10-17 22:55 ` [PATCH 10/11] perf tools: Pass build flags to traceevent build Arnaldo Carvalho de Melo
2018-10-17 22:55 ` [PATCH 11/11] perf tools: Stop fallbacking to kallsyms for vdso symbols lookup Arnaldo Carvalho de Melo
2018-10-18  6:20   ` Adrian Hunter
2018-10-26 23:19     ` Vinicius Costa Gomes
2018-10-27 11:05       ` Jiri Olsa
2018-10-27 20:09         ` Vinicius Costa Gomes
2018-10-28 21:10           ` Jiri Olsa
2018-10-18  5:44 ` [GIT PULL 00/11] perf/urgent fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181017225501.32150-4-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).