Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2956689rdh; Wed, 27 Sep 2023 19:56:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7SiUqKZBp9/e/Tp5O+JAvhkqjRhE59HIjnlnO1ul+JMd6xb653efn317eKMDPlQvIylDi X-Received: by 2002:a05:6a20:93a7:b0:161:b5f9:e78d with SMTP id x39-20020a056a2093a700b00161b5f9e78dmr683599pzh.23.1695869815856; Wed, 27 Sep 2023 19:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695869815; cv=none; d=google.com; s=arc-20160816; b=jIgidxOBoE1QZAJbVYcNJpwXRKcModDNGyeKe30nEESDlxdtnshAysaiw0UsDasZ7N tiRyizAiSQnab1zNkuSjVHBnBmYXRyPQb9tQrR8scT+StqdzF+H2dW8h2ldCMzLdUnU/ YOgP4PHwX2tqSA1oo/NVXv/5X6xwXsRHEmgEGBSNU7AWuc1DxcJuM6ZCOVai98FB7rkh rgVO0m/xc9VpxdsQC1JcXVqRIvI0mOOBNr6bHWWu+MZhINOzLG8tspxKiyonqkJyr6Rn 4tERcspMG9FA2gh5UwRLH8qApic8fvoKE6Z+wv/cuxJTkZnHS1sCar8rY0bPeecCBHP5 WZlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=xLEFyFxvD6KViNnGR9L0+5bNYA79A2gbOhmLgb+y/zY=; fh=LAzuaSc0p1wnwz+gHbMkC6WBYQIe7a7P3Y5oH1rCbHk=; b=gqWLLxQTjT+YVQZT5OK9TQadTDeQsfnWBbDTjPyM6ArMR33vWGqkI8DeS0d20duZf8 gIqjbqf9BEB4AE7hyF+8M8V4tIC4OO1vzzsJr3iUvqeOVL60I8tAz/Tx5wNawUta/sM4 GT49+earwID1i0iJv+ME5E4DxGYE9I7TFI1O0d3QkwMUNIFsumpESKbPqEOd7N7hQTq7 xicQWQBadq55bivRrosQyPtwxKvZqUUIqWfpSgKwy8eYphIIuv8b/9LdthXupIRLlnrG V1IVlV5f/cEQE24RPXXx/K6pO10Op2KIPEKBnUpqrA9OLkBflHBQ2MWspqaMJWH97whK KTYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pFNf16Xp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id o24-20020a639218000000b005641ddd0309si5408476pgd.599.2023.09.27.19.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 19:56:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pFNf16Xp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CDC78801C92D; Wed, 27 Sep 2023 17:44:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229831AbjI1Aol (ORCPT + 99 others); Wed, 27 Sep 2023 20:44:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbjI1Aok (ORCPT ); Wed, 27 Sep 2023 20:44:40 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3613BF for ; Wed, 27 Sep 2023 17:44:38 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59f8315aabfso152233527b3.0 for ; Wed, 27 Sep 2023 17:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695861878; x=1696466678; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=xLEFyFxvD6KViNnGR9L0+5bNYA79A2gbOhmLgb+y/zY=; b=pFNf16Xp/YoRQvtzvCZXz7csn9MGJUPsacWcqOFvWa/RSSqOT3s//u+lffhHgbYwtm /zCuLKG/rxbynKYMoR7XU/xyU9evjemZ/76sIWKuaQyQE2nl5JV4JWsT10Xo0DHVioeg DIEWQ0RmVJTYGVcLMr+aurfIufYRg05fNbpkVS6BckrHNXd4DMJ0mHrucW5PIX8UTo2i 8XZmHzSEo+9b2YnWztouOQjwCUW+DUURYEuvRWDupGrTc06MZfj3qM2zTlg21qJ44UmS /0w6EQvwCsxkSFvaiyPZbwU6Gc4Ck0LgOrFPm/m+nue3EMIu11TFr5VCtuyPubsAg83E mObQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695861878; x=1696466678; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xLEFyFxvD6KViNnGR9L0+5bNYA79A2gbOhmLgb+y/zY=; b=huTtNLPiHDtg2RLYr5he6il9FKe76AL225cBUgt3wz+vFDRr8LFx01PSlu1kUbSu0W qRQmCLZdlg3fcS8WsWMe4+mabClSwt1oYajPB9Xn/q4yl/hC+JhocQ6vjfty3NEvLs+h knCFrE4quAFzELCRQwAcmauSL9Cn6WnIT+0ZlsSxI8ins67bQWyBSl28W7wz2ZJHr+q6 66Yic0u1/9JwqkaL4Xlruy1Pk1mGIYwwBVCFX749rcgfhWT5aIuwAecoK/RLKlXc62BY kneibCr7ZwUdPzsVn5VluE6bGdZTr3/+WrjP/mD0mF04+kViXNupmC1oo/2WudJx39Ph 9YkA== X-Gm-Message-State: AOJu0YyLE7lNSFtnJj2T5QbCW5IXV124f+xTYuU3N929W7xYxA76AsMy +hw4FYB0F4BI/J/9GTi6Q3QdfSBtFndJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:247a:7324:7470:3619]) (user=irogers job=sendgmr) by 2002:a05:6902:4b2:b0:d7e:8dee:7813 with SMTP id r18-20020a05690204b200b00d7e8dee7813mr56449ybs.8.1695861878129; Wed, 27 Sep 2023 17:44:38 -0700 (PDT) Date: Wed, 27 Sep 2023 17:44:31 -0700 Message-Id: <20230928004431.1926969-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Subject: [PATCH v1] perf parse-events: Fix for term values that are raw events From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Kan Liang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 17:44:45 -0700 (PDT) Raw events can be strings like 'r0xead' but the 0x is optional so they can also be 'read'. On IcelakeX uncore_imc_free_running has an event called 'read' which may be programmed as: ``` $ perf stat -e 'uncore_imc_free_running/event=read/' -a sleep 1 ``` However, the PE_RAW type isn't allowed on the right of a term, even though in this case we just want to interpret it as a string. This leads to the following error on IcelakeX: ``` $ perf stat -e 'uncore_imc_free_running/event=read/' -a sleep 1 event syntax error: '..nning/event=read/' \___ parser error Run 'perf list' for a list of valid events Usage: perf stat [] [] -e, --event event selector. use 'perf list' to list available events ``` Fix this by allowing raw types on the right of terms and treat them as strings, just as is already done for PE_LEGACY_CACHE. Make this consistent by just entirely removing name_or_legacy and always using name_or_raw that covers all three cases. Fixes: 6fd1e5191591 ("perf parse-events: Support PMUs for legacy cache events") Signed-off-by: Ian Rogers --- tools/perf/util/parse-events.y | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 4d9f3922a33d..de098caf0c1c 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -78,7 +78,7 @@ static void free_list_evsel(struct list_head* list_evsel) %type PE_MODIFIER_BP %type PE_EVENT_NAME %type PE_DRV_CFG_TERM -%type name_or_raw name_or_legacy +%type name_or_raw %destructor { free ($$); } %type event_term %destructor { parse_events_term__delete ($$); } @@ -669,8 +669,6 @@ event_term name_or_raw: PE_RAW | PE_NAME | PE_LEGACY_CACHE -name_or_legacy: PE_NAME | PE_LEGACY_CACHE - event_term: PE_RAW { @@ -685,7 +683,7 @@ PE_RAW $$ = term; } | -name_or_raw '=' name_or_legacy +name_or_raw '=' name_or_raw { struct parse_events_term *term; int err = parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, $1, $3, &@1, &@3); @@ -765,7 +763,7 @@ PE_TERM_HW $$ = term; } | -PE_TERM '=' name_or_legacy +PE_TERM '=' name_or_raw { struct parse_events_term *term; int err = parse_events_term__str(&term, $1, /*config=*/NULL, $3, &@1, &@3); -- 2.42.0.515.g380fc7ccd1-goog