Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1928705rdb; Tue, 5 Sep 2023 09:04:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExjU5/RqtD7NVJX90wEMI4ekar86fXDxooV1FB6HZhj3ucSJQMQFIsUwqM+ImYMTrvJS9Z X-Received: by 2002:a17:907:b0a:b0:9a1:b705:75d1 with SMTP id h10-20020a1709070b0a00b009a1b70575d1mr179873ejl.51.1693929879730; Tue, 05 Sep 2023 09:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693929879; cv=none; d=google.com; s=arc-20160816; b=PIi1p8/A6gs+xczbM9GAtVOBWRMnLw0tieoATO03uXV0c7NKSA0sACjrua/Pt4FRY+ 39rjlp3eF//7mQnrVI6OC59q/V1ueqom7pO9IXp8Fi3cLw7Ndv10ba2+nQ6AW9SOiNdf t92ufe8kz5z9tThnZTi9QxfvNOCgezJI3FKrgtjziUO/gI2OPhICvaG/l34ACungiT7p anclKgMC1IpkZoGhKd37WjEOyt6giZqPOmwH3y3g+YUdictIo6eRgDFppuAJDMiH3mSL YBVGR16lvhCuTZ8IARcGBp7YeYfT2M1x2gI01N6fUNcSPy7lZWIk2hDynEXYcM7fRutI uzPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=b/BqMC0QJE5KpiQSc7IaRpQnCrnleTMeBHkIOiDJRuA=; fh=IGjQ/rcs1iErNaSthFVQHNny4qv6ucn98yQpDVMnAQk=; b=EmYSyb8N9PkTAE3eKQu4SKfIbOhcxzkwdCQdfcFFEoFRv19YdQMbSIGctA46znzpxE qo7npZs7MfQUO12VEinVHfcsCIxb8kXxG+5B1CngyCoJTY/IrpeWG3PSv3W/zHdbfBiT rvRgbuYCsCkrS/sCu3ocIzgXXO9sHAiFqTHgeXHPdgEJCOy4+oAs7QMeOERYOv8bvgfJ UckxP9Bj0/5yUmFCzFFN01KiE2NGQdCW1y9e7ezrJ6DM4nIYE/W4dK9wa+FPkeMdBt+Y Mhg/77lLf4dcDBLd7sMfhZtYRl7EOY/IAq42y+qQMuvQ0CrOly3b+31Sm9jYR5dywQSR jFJg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rp26-20020a170906d97a00b00993690d17a2si7669439ejb.5.2023.09.05.09.04.27; Tue, 05 Sep 2023 09:04:39 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344552AbjIDPJt (ORCPT + 21 others); Mon, 4 Sep 2023 11:09:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235331AbjIDPJs (ORCPT ); Mon, 4 Sep 2023 11:09:48 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4EE15E5B; Mon, 4 Sep 2023 08:09:42 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C9E27143D; Mon, 4 Sep 2023 08:10:19 -0700 (PDT) Received: from [192.168.1.3] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 70DCF3F738; Mon, 4 Sep 2023 08:09:39 -0700 (PDT) Message-ID: Date: Mon, 4 Sep 2023 16:09:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v1 2/3] perf tools: Revert enable indices setting syntax for BPF map Content-Language: en-US To: Ian Rogers Cc: Arnaldo Carvalho de Melo , "coresight@lists.linaro.org" , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Eduard Zingerman , Kan Liang , Rob Herring , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Wang Nan , Wang ShaoBo , YueHaibing , He Kuang , Peter Zijlstra , Ingo Molnar , Mark Rutland References: <20230728001212.457900-1-irogers@google.com> <20230728001212.457900-3-irogers@google.com> <77361428-5970-5031-e204-7aefcd9cbebc@arm.com> From: James Clark In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 On 04/09/2023 15:56, Ian Rogers wrote: > On Mon, Sep 4, 2023 at 4:02 AM James Clark wrote: >> >> >> >> On 28/07/2023 01:12, Ian Rogers wrote: >>> This reverts commit e571e029bdbf ("perf tools: Enable indices setting >>> syntax for BPF map"). >>> >>> The reverted commit added a notion of arrays that could be set as >>> event terms for BPF events. The parsing hasn't worked over multiple >>> Linux releases. Given the broken nature of the parsing it appears the >>> code isn't in use, nor could I find a way for it to be used to add a >>> test. >>> >>> The original commit contains a test in the commit message, >>> however, running it yields: >>> ``` >>> $ perf record -e './test_bpf_map_3.c/map:channel.value[0,1,2,3...5]=101/' usleep 2 >>> event syntax error: '..pf_map_3.c/map:channel.value[0,1,2,3...5]=101/' >>> \___ parser error >>> Run 'perf list' for a list of valid events >>> >>> Usage: perf record [] [] >>> or: perf record [] -- [] >>> >>> -e, --event event selector. use 'perf list' to list available events >>> ``` >>> >>> Given the code can't be used this commit reverts and removes it. >>> >> >> Hi Ian, >> >> Unfortunately this revert breaks Coresight sink argument parsing. >> >> Before: >> >> $ perf record -e cs_etm/@tmc_etr0/ -- true >> [ perf record: Woken up 1 times to write data ] >> [ perf record: Captured and wrote 4.008 MB perf.data ] >> >> After: >> >> $ perf record -e cs_etm/@tmc_etr0/ -- true >> event syntax error: 'cs_etm/@tmc_etr0/' >> \___ parser error >> >> I can't really see how it's related to the array syntax that the commit >> messages mention, but it could either be that the revert wasn't applied >> cleanly or just some unintended side effect. >> >> We should probably add a cross platform parsing test for Coresight >> arguments, but I don't know whether we should just blindly revert the >> revert for now, or work on a new change that explicitly fixes the >> Coresight case. > > Agreed, I'll take a look. Any chance you could post the full error > message? I suspect there's a first error hiding in there too. > > Thanks, > Ian > No that seems to be the whole thing, running with -vvv and pasting everything: $ perf record -e cs_etm/@tmc_etr0/ -vvv -- true event syntax error: 'cs_etm/@tmc_etr0/' \___ parser error Run 'perf list' for a list of valid events Usage: perf record [] [] or: perf record [] -- [] -e, --event event selector. use 'perf list' to list available events I previously mentioned that this is a Coresight thing, but I saw that it may actually be the more generic "drv_str". Unless nothing other than Coresight is using it, then it's just a Coresight thing. >> Thanks >> James >> >>> Signed-off-by: Ian Rogers >>> --- >>> tools/perf/util/parse-events.c | 8 +-- >>> tools/perf/util/parse-events.l | 11 --- >>> tools/perf/util/parse-events.y | 122 --------------------------------- >>> 3 files changed, 1 insertion(+), 140 deletions(-) >>> >>> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c >>> index 02647313c918..0e2004511cf5 100644 >>> --- a/tools/perf/util/parse-events.c >>> +++ b/tools/perf/util/parse-events.c >>> @@ -800,13 +800,7 @@ parse_events_config_bpf(struct parse_events_state *parse_state, >>> >>> parse_events_error__handle(parse_state->error, idx, >>> strdup(errbuf), >>> - strdup( >>> -"Hint:\tValid config terms:\n" >>> -" \tmap:[].value=[value]\n" >>> -" \tmap:[].event=[event]\n" >>> -"\n" >>> -" \twhere is something like [0,3...5] or [all]\n" >>> -" \t(add -v to see detail)")); >>> + NULL); >>> return err; >>> } >>> } >>> diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l >>> index 99335ec586ae..d7d084cc4140 100644 >>> --- a/tools/perf/util/parse-events.l >>> +++ b/tools/perf/util/parse-events.l >>> @@ -175,7 +175,6 @@ do { \ >>> %x mem >>> %s config >>> %x event >>> -%x array >>> >>> group [^,{}/]*[{][^}]*[}][^,{}/]* >>> event_pmu [^,{}/]+[/][^/]*[/][^,{}/]* >>> @@ -251,14 +250,6 @@ non_digit [^0-9] >>> } >>> } >>> >>> -{ >>> -"]" { BEGIN(config); return ']'; } >>> -{num_dec} { return value(yyscanner, 10); } >>> -{num_hex} { return value(yyscanner, 16); } >>> -, { return ','; } >>> -"\.\.\." { return PE_ARRAY_RANGE; } >>> -} >>> - >>> { >>> /* >>> * Please update config_term_names when new static term is added. >>> @@ -302,8 +293,6 @@ r0x{num_raw_hex} { return str(yyscanner, PE_RAW); } >>> {lc_type}-{lc_op_result} { return lc_str(yyscanner, _parse_state); } >>> {lc_type}-{lc_op_result}-{lc_op_result} { return lc_str(yyscanner, _parse_state); } >>> {name_minus} { return str(yyscanner, PE_NAME); } >>> -\[all\] { return PE_ARRAY_ALL; } >>> -"[" { BEGIN(array); return '['; } >>> @{drv_cfg_term} { return drv_str(yyscanner, PE_DRV_CFG_TERM); } >>> } >>> >>> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y >>> index 454577f7aff6..5a90e7874c59 100644 >>> --- a/tools/perf/util/parse-events.y >>> +++ b/tools/perf/util/parse-events.y >>> @@ -64,7 +64,6 @@ static void free_list_evsel(struct list_head* list_evsel) >>> %token PE_LEGACY_CACHE >>> %token PE_PREFIX_MEM >>> %token PE_ERROR >>> -%token PE_ARRAY_ALL PE_ARRAY_RANGE >>> %token PE_DRV_CFG_TERM >>> %token PE_TERM_HW >>> %type PE_VALUE >>> @@ -108,11 +107,6 @@ static void free_list_evsel(struct list_head* list_evsel) >>> %type groups >>> %destructor { free_list_evsel ($$); } >>> %type tracepoint_name >>> -%destructor { free ($$.sys); free ($$.event); } >>> -%type array >>> -%type array_term >>> -%type array_terms >>> -%destructor { free ($$.ranges); } >>> %type PE_TERM_HW >>> %destructor { free ($$.str); } >>> >>> @@ -127,7 +121,6 @@ static void free_list_evsel(struct list_head* list_evsel) >>> char *sys; >>> char *event; >>> } tracepoint_name; >>> - struct parse_events_array array; >>> struct hardware_term { >>> char *str; >>> u64 num; >>> @@ -878,121 +871,6 @@ PE_TERM >>> >>> $$ = term; >>> } >>> -| >>> -name_or_raw array '=' name_or_legacy >>> -{ >>> - struct parse_events_term *term; >>> - int err = parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, $1, $4, &@1, &@4); >>> - >>> - if (err) { >>> - free($1); >>> - free($4); >>> - free($2.ranges); >>> - PE_ABORT(err); >>> - } >>> - term->array = $2; >>> - $$ = term; >>> -} >>> -| >>> -name_or_raw array '=' PE_VALUE >>> -{ >>> - struct parse_events_term *term; >>> - int err = parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, $1, $4, false, &@1, &@4); >>> - >>> - if (err) { >>> - free($1); >>> - free($2.ranges); >>> - PE_ABORT(err); >>> - } >>> - term->array = $2; >>> - $$ = term; >>> -} >>> -| >>> -PE_DRV_CFG_TERM >>> -{ >>> - struct parse_events_term *term; >>> - char *config = strdup($1); >>> - int err; >>> - >>> - if (!config) >>> - YYNOMEM; >>> - err = parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG, config, $1, &@1, NULL); >>> - if (err) { >>> - free($1); >>> - free(config); >>> - PE_ABORT(err); >>> - } >>> - $$ = term; >>> -} >>> - >>> -array: >>> -'[' array_terms ']' >>> -{ >>> - $$ = $2; >>> -} >>> -| >>> -PE_ARRAY_ALL >>> -{ >>> - $$.nr_ranges = 0; >>> - $$.ranges = NULL; >>> -} >>> - >>> -array_terms: >>> -array_terms ',' array_term >>> -{ >>> - struct parse_events_array new_array; >>> - >>> - new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges; >>> - new_array.ranges = realloc($1.ranges, >>> - sizeof(new_array.ranges[0]) * >>> - new_array.nr_ranges); >>> - if (!new_array.ranges) >>> - YYNOMEM; >>> - memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges, >>> - $3.nr_ranges * sizeof(new_array.ranges[0])); >>> - free($3.ranges); >>> - $$ = new_array; >>> -} >>> -| >>> -array_term >>> - >>> -array_term: >>> -PE_VALUE >>> -{ >>> - struct parse_events_array array; >>> - >>> - array.nr_ranges = 1; >>> - array.ranges = malloc(sizeof(array.ranges[0])); >>> - if (!array.ranges) >>> - YYNOMEM; >>> - array.ranges[0].start = $1; >>> - array.ranges[0].length = 1; >>> - $$ = array; >>> -} >>> -| >>> -PE_VALUE PE_ARRAY_RANGE PE_VALUE >>> -{ >>> - struct parse_events_array array; >>> - >>> - if ($3 < $1) { >>> - struct parse_events_state *parse_state = _parse_state; >>> - struct parse_events_error *error = parse_state->error; >>> - char *err_str; >>> - >>> - if (asprintf(&err_str, "Expected '%ld' to be less-than '%ld'", $3, $1) < 0) >>> - err_str = NULL; >>> - >>> - parse_events_error__handle(error, @1.first_column, err_str, NULL); >>> - YYABORT; >>> - } >>> - array.nr_ranges = 1; >>> - array.ranges = malloc(sizeof(array.ranges[0])); >>> - if (!array.ranges) >>> - YYNOMEM; >>> - array.ranges[0].start = $1; >>> - array.ranges[0].length = $3 - $1 + 1; >>> - $$ = array; >>> -} >>> >>> sep_dc: ':' | >>>