Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp392821rwr; Wed, 26 Apr 2023 00:22:11 -0700 (PDT) X-Google-Smtp-Source: AKy350bO8w/x27T8+Hw/mrpMqwsa/Cud7pIs52j8hJKf7vN7xJyRRFSrvpRC6XO8wQ24SCanBz/J X-Received: by 2002:a17:90a:4597:b0:247:42bf:380e with SMTP id v23-20020a17090a459700b0024742bf380emr19620231pjg.4.1682493731263; Wed, 26 Apr 2023 00:22:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682493731; cv=none; d=google.com; s=arc-20160816; b=QHfJiKJpXMqs2WS+p90PoQojipWAjK3df/BfC8kxea1e7qw2IBQFmpEndKg+HT08P6 /9lAppUCcX7j6pS7HNwelvr5+I7iG93J9uxi8eTIt1uFnkfrs8fXTSltwMqc73GNCo73 SeLLeUG8CWoRwQb8W3lkkhWjM0vq2s+FfBtXhZVdx4LHo5YME72tSHG3IXd+5ud4NQo4 MAUmMp81dQYnYxB0aY72HAkpoYQ6zgAO5A5oAsTtEgwukWjy+sKG+g5FCp3EmWM/sGve PwwJ1fYMJoQQ5Z4Vuoq4KS6Ylacegfqz/BhJhn9izg4Fb+iycBg+lxiNEq63LSF+mV31 mf1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=mQ0x6N0RNGSt0AF/fHZKh2i20S0O9mJpVpnE3xtP9Qs=; b=M6WXWtgLRJZgizyetbazluXUOthXZxmQ4UUlZrFyJNV2CVRuTdOj+HLpbEfEFJ6E08 zHuX4+d7PysKv9PuV2rsoVrqed6NFs5zPN3h77Z2aCmL2dq46AUM0GxCODmv4eNGX9OE m9lQBeD4bNXaB07evHFz1EE+MxFEQabOsZuUHZPCt6206FAbwWP5dTkTNlIrb3xmFHAn +TR6G6JZsHBMEdiKicxDRd1rrt5KxPI04yL38bCUv31fWrplDzMVP+HsUTFZLmhkhc9A 1Vrsn41SVBlcRdNyNO9VWRVVqr5P6qPrYV32a+/XFmOIS6BCZUvpkP4a0TAO+nWCx/8q EHnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=dLfPuoZP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q1-20020a634301000000b00528595a1390si5413714pga.588.2023.04.26.00.21.59; Wed, 26 Apr 2023 00:22:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=dLfPuoZP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239953AbjDZHHs (ORCPT + 99 others); Wed, 26 Apr 2023 03:07:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239910AbjDZHHL (ORCPT ); Wed, 26 Apr 2023 03:07:11 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A79E49F4 for ; Wed, 26 Apr 2023 00:05:44 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-b9a25f6aa0eso1476619276.1 for ; Wed, 26 Apr 2023 00:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682492727; x=1685084727; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mQ0x6N0RNGSt0AF/fHZKh2i20S0O9mJpVpnE3xtP9Qs=; b=dLfPuoZPECVNAa8PJubrzET3fdMuNPpnEJhZwWXqjBenElR9cXO6ly6IIczs/OfWFq 8zQ0iFqlh+vakxj7BJ+u+aB8MWOX5vie45jmde2bTaJglKhPaaeN/JpYQSTP6CpW19Cf qsuOvULaFoWvN82XLXCYcH6+QgybmOwh+qxAky2avg0CHNN76ooZ5qHCyY+S3uzK7ZlO ZtQn7E3q1D4kf86EnVcWhbF/zq+gLO381XLBr+rPYfPl2ZtRxrPh/jONbn+++HhZJfgF 9jSccJ+XSOxtHZq1yMMH0uPYZ9zqxrSuDfcxcs1aVmpRf4cbjimlWfDB8REZCwk6dNA0 JlKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682492727; x=1685084727; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mQ0x6N0RNGSt0AF/fHZKh2i20S0O9mJpVpnE3xtP9Qs=; b=intW01jYlsaJ25PcoknzMjhiWerndcMQ1q74/qmFkyAiWom5fYCJhBtL9NoHr0L04G +Cv4VgdNlaHXXDNCW8NqcTbmpqOEcn6idEaIkdALhw5MHXI+tHHbmP2/alGzRYEULjZT Z/j0ctsEJPkLCMvciqJ8cBPHncWhsXKQBzlgPbaKiG/g6htfbTkT2znnBxalLMfxCs5o fWwSP3RavDCq1g6lhMr8IRE788f8M7u00mLY7ccDt/hU2tnkFBGMYK/f0AwE325XFyoE x/3+l72i+gg8aWvz9Alp29x+VhgkQaB8Xim8U9WsHLrAuMPbH8gc6qCkFSlaCde1F7uF LlYA== X-Gm-Message-State: AAQBX9dgO0Hs+/WDo+5litVa426nvIGkQ87irPR58toZ2mad/iwp823E FGC052ulVg2PT98AMVQUWril0Wfwit/F X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:144f:e890:2b29:48d9]) (user=irogers job=sendgmr) by 2002:a25:ccd6:0:b0:b8b:fe5f:2eaa with SMTP id l205-20020a25ccd6000000b00b8bfe5f2eaamr7789005ybf.2.1682492727239; Wed, 26 Apr 2023 00:05:27 -0700 (PDT) Date: Wed, 26 Apr 2023 00:00:42 -0700 In-Reply-To: <20230426070050.1315519-1-irogers@google.com> Message-Id: <20230426070050.1315519-33-irogers@google.com> Mime-Version: 1.0 References: <20230426070050.1315519-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog Subject: [PATCH v1 32/40] perf parse-events: Avoid error when assigning a legacy cache term From: Ian Rogers To: Arnaldo Carvalho de Melo , Kan Liang , Ahmad Yasin , Peter Zijlstra , Ingo Molnar , Stephane Eranian , Andi Kleen , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Florian Fischer , Rob Herring , Zhengjun Xing , John Garry , Kajol Jain , Sumanth Korikkar , Thomas Richter , Tiezhu Yang , Ravi Bangoria , Leo Yan , Yang Jihong , James Clark , Suzuki Poulouse , Kang Minchul , Athira Rajeev , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ian Rogers 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,T_SCC_BODY_TEXT_LINE,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 Avoid the parser error: ''' $ perf stat -e 'cycles/name=l1d/' true event syntax error: 'cycles/name=l1d/' \___ parser error ''' by combining the name and legacy cache cases in the parser. Signed-off-by: Ian Rogers --- tools/perf/tests/parse-events.c | 21 +++++++++++++++++++++ tools/perf/util/parse-events.y | 10 ++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 06042f450ece..c44f0ffa51c5 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -1495,6 +1495,16 @@ static int test__term_equal_term(struct evlist *evlist) return TEST_OK; } +static int test__term_equal_legacy(struct evlist *evlist) +{ + struct evsel *evsel = evlist__first(evlist); + + TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE); + TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)); + TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "l1d") == 0); + return TEST_OK; +} + #ifdef HAVE_LIBTRACEEVENT static int count_tracepoints(void) { @@ -1872,6 +1882,11 @@ static const struct evlist_test test__events[] = { .check = test__term_equal_term, /* 8 */ }, + { + .name = "cycles/name=l1d/", + .check = test__term_equal_legacy, + /* 9 */ + }, }; static const struct evlist_test test__events_pmu[] = { @@ -2059,6 +2074,12 @@ static const struct evlist_test test__events_pmu[] = { .check = test__term_equal_term, /* 0 */ }, + { + .name = "cpu/cycles,name=l1d/", + .valid = test__pmu_cpu_valid, + .check = test__term_equal_legacy, + /* 1 */ + }, }; struct terms_test { diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 0aaebc57748e..f4ee03b5976b 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -82,7 +82,7 @@ static void free_list_evsel(struct list_head* list_evsel) %type PE_EVENT_NAME %type PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE %type PE_DRV_CFG_TERM -%type name_or_raw +%type name_or_raw name_or_legacy %destructor { free ($$); } %type event_term %destructor { parse_events_term__delete ($$); } @@ -739,6 +739,8 @@ event_term name_or_raw: PE_RAW | PE_NAME | PE_LEGACY_CACHE +name_or_legacy: PE_NAME | PE_LEGACY_CACHE + event_term: PE_RAW { @@ -752,7 +754,7 @@ PE_RAW $$ = term; } | -name_or_raw '=' PE_NAME +name_or_raw '=' name_or_legacy { struct parse_events_term *term; @@ -826,7 +828,7 @@ PE_TERM_HW $$ = term; } | -PE_TERM '=' PE_NAME +PE_TERM '=' name_or_legacy { struct parse_events_term *term; @@ -872,7 +874,7 @@ PE_TERM $$ = term; } | -name_or_raw array '=' PE_NAME +name_or_raw array '=' name_or_legacy { struct parse_events_term *term; -- 2.40.1.495.gc816e09b53d-goog