From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19C22EB64DA for ; Tue, 13 Jun 2023 19:41:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230472AbjFMTlw (ORCPT ); Tue, 13 Jun 2023 15:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjFMTlt (ORCPT ); Tue, 13 Jun 2023 15:41:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 582E012A; Tue, 13 Jun 2023 12:41:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E0BE8635CD; Tue, 13 Jun 2023 19:41:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F0D5C433D9; Tue, 13 Jun 2023 19:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686685306; bh=G+owjEHHC7g39g4PWETjU0hB/g9AYANCMLxoyEgCrC0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XQgV+hhS+ECAleGYuB+CPLP0Ld5QU/bG4Psc4t5WopGZOaiJBSDvV8C9L5v23QgZz 4KpMLYzQQqV2anRTU6zZ8dKJc15z7BOm57JrrqfnoQjRm+9MXjxLIQ7EQM4BzWTbBl 3wTCD9MlL8l+daKEVE77kAlc7MXdlgC50WFJ+DzElyAtwyisqxZgMDNo/JBodCky/J qAbJlJPgVaoJnWT8/eban44iPYdwc35rzJ6toZGG8CahuS0e5NK5DpPyOiv8jIufZH 6WfZWpf1/7je0ezmbPoD3gnBhLYHG47HJ9MSL0z9oT+pJiLcoPgnCHoiKHkrG0LK6p WBcKBnBMrhECA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 2CD3E40692; Tue, 13 Jun 2023 16:41:43 -0300 (-03) Date: Tue, 13 Jun 2023 16:41:43 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Rob Herring , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] perf parse-events: Avoid string for PE_BP_COLON, PE_BP_SLASH Message-ID: References: <20230613182629.1500317-1-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230613182629.1500317-1-irogers@google.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Jun 13, 2023 at 11:26:29AM -0700, Ian Rogers escreveu: > There's no need to read the string ':' or '/' for PE_BP_COLON or > PE_BP_SLASH and doing so causes parse-events.y to leak memory. > > The original patch has a committer note about not using these tokens > presumably as yacc spotted they were a memory leak because no > %destructor could be run. Remove the unused token workaround as there > is now no value associated with these tokens. It looked like the compiler was the one warning (-Wother) about args not being used, didn't made it clear those were possible memory leaks :-\ util/parse-events.y:508.24-34: warning: unused value: $3 [-Wother] 508 | PE_PREFIX_MEM PE_VALUE PE_BP_SLASH PE_VALUE PE_BP_COLON PE_MODIFIER_BP opt_event_config Anyway, I'll apply and test your patch. - Arnaldo > Fixes: f0617f526cb0 ("perf parse: Allow config terms with breakpoints") > Signed-off-by: Ian Rogers > --- > tools/perf/util/parse-events.h | 4 ---- > tools/perf/util/parse-events.l | 4 ++-- > tools/perf/util/parse-events.y | 9 --------- > 3 files changed, 2 insertions(+), 15 deletions(-) > > diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h > index 5fdc1f33f57e..b0eb95f93e9c 100644 > --- a/tools/perf/util/parse-events.h > +++ b/tools/perf/util/parse-events.h > @@ -228,10 +228,6 @@ void parse_events_error__handle(struct parse_events_error *err, int idx, > void parse_events_error__print(struct parse_events_error *err, > const char *event); > > -static inline void parse_events_unused_value(const void *x __maybe_unused) > -{ > -} > - > #ifdef HAVE_LIBELF_SUPPORT > /* > * If the probe point starts with '%', > diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l > index 7629af3d5c7c..99335ec586ae 100644 > --- a/tools/perf/util/parse-events.l > +++ b/tools/perf/util/parse-events.l > @@ -315,13 +315,13 @@ r0x{num_raw_hex} { return str(yyscanner, PE_RAW); } > * are the same, so trailing context can be used disambiguate the two > * cases. > */ > -":"/{modifier_bp} { return str(yyscanner, PE_BP_COLON); } > +":"/{modifier_bp} { return PE_BP_COLON; } > /* > * The slash before memory length can get mixed up with the slash before > * config terms. Fortunately config terms do not start with a numeric > * digit, so trailing context can be used disambiguate the two cases. > */ > -"/"/{digit} { return str(yyscanner, PE_BP_SLASH); } > +"/"/{digit} { return PE_BP_SLASH; } > "/"/{non_digit} { BEGIN(config); return '/'; } > {num_dec} { return value(yyscanner, 10); } > {num_hex} { return value(yyscanner, 16); } > diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y > index 0c3d086cc22a..9f28d4b5502f 100644 > --- a/tools/perf/util/parse-events.y > +++ b/tools/perf/util/parse-events.y > @@ -80,8 +80,6 @@ static void free_list_evsel(struct list_head* list_evsel) > %type PE_LEGACY_CACHE > %type PE_MODIFIER_EVENT > %type PE_MODIFIER_BP > -%type PE_BP_COLON > -%type PE_BP_SLASH > %type PE_EVENT_NAME > %type PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE > %type PE_DRV_CFG_TERM > @@ -510,9 +508,6 @@ PE_PREFIX_MEM PE_VALUE PE_BP_SLASH PE_VALUE PE_BP_COLON PE_MODIFIER_BP opt_event > struct list_head *list; > int err; > > - parse_events_unused_value(&$3); > - parse_events_unused_value(&$5); > - > list = alloc_list(); > ABORT_ON(!list); > err = parse_events_add_breakpoint(_parse_state, list, > @@ -531,8 +526,6 @@ PE_PREFIX_MEM PE_VALUE PE_BP_SLASH PE_VALUE opt_event_config > struct list_head *list; > int err; > > - parse_events_unused_value(&$3); > - > list = alloc_list(); > ABORT_ON(!list); > err = parse_events_add_breakpoint(_parse_state, list, > @@ -550,8 +543,6 @@ PE_PREFIX_MEM PE_VALUE PE_BP_COLON PE_MODIFIER_BP opt_event_config > struct list_head *list; > int err; > > - parse_events_unused_value(&$3); > - > list = alloc_list(); > ABORT_ON(!list); > err = parse_events_add_breakpoint(_parse_state, list, > -- > 2.41.0.162.gfafddb0af9-goog > -- - Arnaldo