Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1763799ybz; Thu, 16 Apr 2020 15:15:43 -0700 (PDT) X-Google-Smtp-Source: APiQypIbR8NuIoiiSVnB48r4sI/PIXeynepyICGr1GCACKlm2op7ZgQnJ0YOAy+JQPm36mM+xQnX X-Received: by 2002:a17:906:b7da:: with SMTP id fy26mr166692ejb.327.1587075343419; Thu, 16 Apr 2020 15:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587075343; cv=none; d=google.com; s=arc-20160816; b=yud1rZOIJGGWeMZo/rBhZgjd0KzEcfwTucBbHBCnH7ECbKgXU9WlHWWoGFhWYfDZ1I GdWqmUdqOBvIrBkrYE043RnNb3FAM07IowrOczTE/DXD9isbUaDQ47hL0ZeYGRw2czSm zWZWPHMr2f6wg57DniE0yTQ1LCNvVSkMsXpPsr/KhZZyCTTNr3XdCHDw0RLTnbpIQfvK wQ0hUKDJR1nFVqB+ZsRuwxOerBYYgf4sPIRFFxkaXZE6qmT2CXB1J9MFZ34Zo6qoYnks wYbD/ljiUiz1zZ+UenyadSCGm2dBsAo3qdnfesbG0+Pde4ba1+UKzhmn9ADX1amPUnWX ZI4g== 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 :message-id:date:subject:cc:to:from; bh=dLwBE6QX5Q5o2u+XPoo/WGP8APLJA0U3i2GeYL85XVE=; b=AeePGCya72FJpglwShycphRmpdN5HidBxe27CvATNXyn1hGaaJbCfmSGRHwtA/WlYX Op/ptOqJ0rsKa4dgpOxKqfIUEjYjqGNlkAaONdqHCWjGi4lCCcxhUOKFgFtos6rfw6Bz ND6J3XPfYtoVI9WYGP94jmho9WtnmQzz6iMOmG268QfXPvkdvRQiYB5Sx1/iuegULckq uaajYvI0QGcDlUNniFCDgd8jmJKZyF7NlZt3ETHL2RERihfaoHaeLtodNfBhSgF5ZAPx dFZtDWsg+x4D7dmAuey4fGZgsTGfCE+TuyFbSKWxezCSgwnZ1aUPC5fijGRk5XzV1hhC qZzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id k3si14227664edk.571.2020.04.16.15.15.20; Thu, 16 Apr 2020 15:15:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728963AbgDPWOU convert rfc822-to-8bit (ORCPT + 99 others); Thu, 16 Apr 2020 18:14:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:57887 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728918AbgDPWOU (ORCPT ); Thu, 16 Apr 2020 18:14:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-406-iy6EfzOFMNWUpHa7q905TA-1; Thu, 16 Apr 2020 18:14:11 -0400 X-MC-Unique: iy6EfzOFMNWUpHa7q905TA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29A19800D53; Thu, 16 Apr 2020 22:14:09 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.195.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B9AE1000325; Thu, 16 Apr 2020 22:14:06 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Thomas Richter , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Sumanth Korikkar , Vasily Gorbik Subject: [PATCH] perf tools: Add support to specify rXXX event withing pmu Date: Fri, 17 Apr 2020 00:14:05 +0200 Message-Id: <20200416221405.437788-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa The current rXXXX event specification creates event under PERF_TYPE_RAW pmu type. This change allows to use rXXXX within pmu syntax, so it's type is used via following syntax: -e 'cpu/r3c/' -e 'cpum_cf/r0/' The XXXX number goes directly to perf_event_attr::config the same way as in '-e rXXXX' event. The perf_event_attr::type is filled with pmu type. Requested-by: Thomas Richter Signed-off-by: Jiri Olsa --- tools/perf/Documentation/perf-list.txt | 5 +++++ tools/perf/tests/parse-events.c | 17 ++++++++++++++++- tools/perf/util/parse-events.l | 1 + tools/perf/util/parse-events.y | 9 +++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt index cb23667531ab..376a50b3452d 100644 --- a/tools/perf/Documentation/perf-list.txt +++ b/tools/perf/Documentation/perf-list.txt @@ -115,6 +115,11 @@ raw encoding of 0x1A8 can be used: perf stat -e r1a8 -a sleep 1 perf record -e r1a8 ... +It's also possible to use pmu syntax: + + perf record -e r1a8 -a sleep 1 + perf record -e cpu/r1a8/ ... + You should refer to the processor specific documentation for getting these details. Some of them are referenced in the SEE ALSO section below. diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 091c3aeccc27..902bd9d591a0 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -1356,6 +1356,16 @@ static int test__checkevent_complex_name(struct evlist *evlist) return 0; } +static int test__checkevent_raw_pmu(struct evlist *evlist) +{ + struct evsel *evsel = evlist__first(evlist); + + TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries); + TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type); + TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config); + return 0; +} + static int test__sym_event_slash(struct evlist *evlist) { struct evsel *evsel = evlist__first(evlist); @@ -1750,7 +1760,12 @@ static struct evlist_test test__events_pmu[] = { .name = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp", .check = test__checkevent_complex_name, .id = 3, - } + }, + { + .name = "software/r1a/", + .check = test__checkevent_raw_pmu, + .id = 4, + }, }; struct terms_test { diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index baa48f28d57d..c589fc42f058 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -286,6 +286,7 @@ no-overwrite { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOOVERWRITE); } percore { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_PERCORE); } aux-output { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT); } aux-sample-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE); } +r{num_raw_hex} { return raw(yyscanner); } , { return ','; } "/" { BEGIN(INITIAL); return '/'; } {name_minus} { return str(yyscanner, PE_NAME); } diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 94f8bcd83582..e879eb257874 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -706,6 +706,15 @@ event_term } event_term: +PE_RAW +{ + struct parse_events_term *term; + + ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_CONFIG, + NULL, $1, false, &@1, NULL)); + $$ = term; +} +| PE_NAME '=' PE_NAME { struct parse_events_term *term; -- 2.25.2