Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp815225ybl; Wed, 8 Jan 2020 06:22:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwFSkv4Ss35flwqmomgz1skP1SR/RFcOSRZjSt346Fu9PCP57+4TfVmZv38xoBWpOamh6x+ X-Received: by 2002:aca:110a:: with SMTP id 10mr3218352oir.130.1578493332603; Wed, 08 Jan 2020 06:22:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578493332; cv=none; d=google.com; s=arc-20160816; b=wSRAu5UPXR/e4F98CtjSkMyLLcFS77YJQNRDSasLDp9dfuqTUgArsFUH9/jvPIXj0J IYlbMBDmj/Vywb5JWJ4o1btFShQJ+FE38ugLpsGY5UcGTAI1jVyR2NOH0Fze0dkjCUYM FNd/q8JcMIHzy8GdKSvJLHKzW9DKrj9pqcCgDSRd6b8hJidvdTZpNeiOWFgSuz1eaaeH Jj4a7BtJ6O9F7cW4xY6CD/tMkEcGgHjXP0WPzmiOavXRKLSNNsvWsd+CS3CWdWWyTLYm raO1EaaXrjtlC7wY3tZLeMw4PnX0qTtfqaEWUJyx/1ZeJhZL9o74fayNawWtohP0hT9R 83AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=v5QuWl/+PY9Q73jf1DmwSNtvySHIXxjomMZ599Y61vs=; b=MsbUMj5CJMzDGpenhER6D/lSyMFyMCjeI2LjJqcsMRAjOrnln7+KS0ev/iB3LWwT/T 5TRSKJ2r6gOBk5HES0D5TA0UMN4hzJTqc0q/CSHNmjYQANrwNrFHG/zsoSHAJenHjIkQ VWY4lEY86mgSPFYDiQQ0HKBWRQ0hdWMfCQXsm0VXlEOfKl0NpEXct4iBvk0OvywV+4Ke S/x/JeP/48CmpzCOBxK4R2joga2Xnzuw/L2wxYl+TZPtrYDSXn3MG23x/yFFgYT6pVqT +6Q/dnd/wWMOcS9Q3oNw7v2gxHpOqIyz7VQMG6nVXd6djyL5k+Qj00ZggSZ79iBh9xvi osQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QUXDBnIj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m9si1732096oie.148.2020.01.08.06.22.00; Wed, 08 Jan 2020 06:22:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QUXDBnIj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727472AbgAHNUm (ORCPT + 99 others); Wed, 8 Jan 2020 08:20:42 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41008 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726087AbgAHNUm (ORCPT ); Wed, 8 Jan 2020 08:20:42 -0500 Received: by mail-pl1-f193.google.com with SMTP id bd4so1124268plb.8 for ; Wed, 08 Jan 2020 05:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=v5QuWl/+PY9Q73jf1DmwSNtvySHIXxjomMZ599Y61vs=; b=QUXDBnIjggHMVJ1vjZpL/09PJRr5wQywtvlcmjwyKrqWWWGWiwU5NxbjeLnMyBAY9V g5SA+SUvHxX+SSscvqxP3XIX6+f/Aunh5tFRmsirpJNJiyg2gR79d2oHhzrbGVqTjtd4 q1X6JSeYUKiYxYmh7BI9zzt7b2IaEWdYnBHfpjkh6o10WdHpuvCXMtmv/40VmC3N5d3x jwRP/woqdBple+tDNX4J2cdROe9K4g0pAdnR4KhXN/IabZbp9hPn70PW8fMbN3xMAnp5 yV9J4pmZD3rGsAZfKMunsARQMl9gsX/VzJciQhfb5Y8bDtRAQd6dMvSRVDPOkKi1Xu8G WZcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=v5QuWl/+PY9Q73jf1DmwSNtvySHIXxjomMZ599Y61vs=; b=XcgC9HkYYzQ+XJ0rsMyhFE/Mr64X7KgY5bJidnoQIPCIN2uiTVc+bvJ65wQ5pip+Dz Bxk21E40VT7R6h0gENsHjVMkh+E/f2yKpOkhIzD8AxavxZDvHvRpFaix/zct7Lbsm2L/ QxB7uZlgzLFgh7/rwwy07Ttr8ZB7q/O2fr2G/6+gl7x3vkcafmAkTEyifmaYbhssfr5e kM2iBEDTBkg2u1HE5a/REC3wil+D9qo3S7Kw7eMAN6p86WVDWHJ0t3CbW0OwviEgKkF8 32ZRg0d626F0Fgygb/zNOc9JyNLqKLAWyRREaKPx6e8ZzZYr25HLcUN/OOjmUZvfqbbK O8DA== X-Gm-Message-State: APjAAAWmUiqkzft4hqBTpOrzjx1d1JRiyKBeV5/qQlrWohclhKwdACsv il24FJsEjGDBS6mvDn5jfqh+Kw== X-Received: by 2002:a17:902:8bc6:: with SMTP id r6mr4105919plo.53.1578489641346; Wed, 08 Jan 2020 05:20:41 -0800 (PST) Received: from leoy-ThinkPad-X240s (li519-153.members.linode.com. [66.175.222.153]) by smtp.gmail.com with ESMTPSA id p185sm3669828pfg.61.2020.01.08.05.20.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Jan 2020 05:20:40 -0800 (PST) Date: Wed, 8 Jan 2020 21:20:28 +0800 From: Leo Yan To: Jiri Olsa Cc: Mathieu Poirier , Arnaldo Carvalho de Melo , Jiri Olsa , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Namhyung Kim , Ian Rogers , Andi Kleen , Adrian Hunter , Linux Kernel Mailing List , Mike Leach , Suzuki K Poulose Subject: Re: [PATCH v3] perf parse: Copy string to perf_evsel_config_term Message-ID: <20200108132028.GC7797@leoy-ThinkPad-X240s> References: <20200107120310.9632-1-leo.yan@linaro.org> <20200108102212.GA360164@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200108102212.GA360164@krava> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mathieu, Jiri, On Wed, Jan 08, 2020 at 11:22:12AM +0100, Jiri Olsa wrote: > On Tue, Jan 07, 2020 at 02:45:27PM -0700, Mathieu Poirier wrote: [...] > > Many thanks for digging into this and stepping forward to provide a > > solution - it is much appreciated. My pleasure! After think again, we do need to add CoreSight test into perf test ASAP, thus we can pay attention for the failure at the early time. This is another topic, let's fistly focus on resolve this issue. > > > Fixes: 1dc925568f01 ("perf parse: Add a deep delete for parse event terms") > > > Suggested-by: Jiri Olsa > > > Signed-off-by: Leo Yan > > > --- > > > tools/perf/util/evsel.c | 2 ++ > > > tools/perf/util/evsel_config.h | 2 ++ > > > tools/perf/util/parse-events.c | 56 +++++++++++++++++++++------------- > > > 3 files changed, 39 insertions(+), 21 deletions(-) > > > > > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > > > index a69e64236120..ab9925cc1aa7 100644 > > > --- a/tools/perf/util/evsel.c > > > +++ b/tools/perf/util/evsel.c > > > @@ -1265,6 +1265,8 @@ static void perf_evsel__free_config_terms(struct evsel *evsel) > > > > > > list_for_each_entry_safe(term, h, &evsel->config_terms, list) { > > > list_del_init(&term->list); > > > + if (term->free_str) > > > + free(term->val.str); > > > > This will do the trick but we can definitely do better. > > > > Part of his comments on V2, Jiri hinted that we should move to a > > common perf_evsel_config_term::str to replace {callgraph, drv_cfg, > > branch}, something that will work because we have > > perf_evsel_config_term::type. That means functions > > apply_config_terms() and cs_etm_set_sink_attr() need to be modified > > but the changes are quite small and well worth for the benefit they'll > > carry. > > > > With that the above becomes neat and clean. > > I wonder if there was some reason for keeping the variables > like that for every type and not just one per type as we did > 'struct parse_events_term' > > if the change is possible, the code would be cleaner, let's see ;-) Thanks for the suggestion, I hope to do right thing in next spin :) I tried to only use val.num and val.str in perf_evsel_config_term in my local code, same with the struct parse_events_term, it does work and the effort is not big. Will send out patches soon (will use two patches, one is for refactoring, another is for fixing regression). Thanks, Leo Yan