From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAFDE1A08A6; Fri, 6 Jun 2025 20:01:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749240082; cv=none; b=OXMHUicJHlNzQMvT3FsyeZAGQlFQL3x2VbUUyd9UTwQq8e3QEiBkK1wOhahl052263CzthWWSEqEOEKnKosjPsNepYP/F2jG/jXhKeYGJDcKD7rWNSJJOiGlEVszLr1Y1x5BKuPho0N8DA1gIGv6MMzqtFEHkWSQovvQbLLI938= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749240082; c=relaxed/simple; bh=Sp4TNaHObF2aJO/x8zKPUqwQR3sTUTk9f8QtmlJIzoE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Hu4s6XMyy52Gb6vMKwuaWvN0WpdqvOya3Uz5F/vV/xAEgZAkoFK1V4BDnpyiauAzOx4sVCWKcFo2gcyC3H4aEeqD5mjggdptujyhBU9yoaWNPuCO3U20OFReCuB785NHx735BjrVRf6s8/rbszTXgBuryWuiuCukJzImBxUxDko= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aIRFdNx1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aIRFdNx1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FCF4C4CEEB; Fri, 6 Jun 2025 20:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749240081; bh=Sp4TNaHObF2aJO/x8zKPUqwQR3sTUTk9f8QtmlJIzoE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aIRFdNx1ZYWYPVJyYIZpkuh7pWg8MtiUcN3BFkZ/Af173WuQj0eoodHwq0pOEBpo1 DEtOPZ/xdS43nB59ej7ohAMpcn39hVQSNu8T77g2LiBqXwPXw9Vhj8fiEVq4+xq17v sSEpTUI3lIwdNxgMVJL/gC/MQ1BTbJm8EMbY1x9YL2byDNIgHEDYbSIjuUd9ulS9/X mQWC5ZFqwXcm4L2k/mqJ+rUXsbcSDV1sGP4sRESpiCXFnQxJMTyWcZ61VFXOY/6FDM CUQ216bnUeh+1M/ODIIIsByiv46gMShKdyvRjmid07C7RAHQNmpTbK+pf1bjjH/89A 7IMIOvtr56Erw== Date: Fri, 6 Jun 2025 13:01:18 -0700 From: Namhyung Kim To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , James Clark , Dapeng Mi , Thomas Richter , Veronika Molnarova , Chun-Tse Shao , Leo Yan , Hao Ge , Howard Chu , Weilin Wang , Levi Yun , "Dr. David Alan Gilbert" , Gautam Menghani , Tengda Wu , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH v4 03/10] perf parse-events: Add parse_uid_filter helper Message-ID: References: <20250604174545.2853620-1-irogers@google.com> <20250604174545.2853620-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Jun 06, 2025 at 11:13:10AM -0700, Ian Rogers wrote: > On Fri, Jun 6, 2025 at 10:41 AM Namhyung Kim wrote: > > > > Hi Ian, > > > > On Wed, Jun 04, 2025 at 10:45:37AM -0700, Ian Rogers wrote: > > > Add parse_uid_filter filter as a helper to parse_filter, that > > > constructs a uid filter string. As uid filters don't work with > > > tracepoint filters, add a is_possible_tp_filter function so the > > > tracepoint filter isn't attempted for tracepoint evsels. > > > > > > Signed-off-by: Ian Rogers > > > --- > > > tools/perf/util/parse-events.c | 33 ++++++++++++++++++++++++++++++++- > > > tools/perf/util/parse-events.h | 1 + > > > 2 files changed, 33 insertions(+), 1 deletion(-) > > > > > > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c > > > index d96adf23dc94..7f34e602fc08 100644 > > > --- a/tools/perf/util/parse-events.c > > > +++ b/tools/perf/util/parse-events.c > > > @@ -25,6 +25,7 @@ > > > #include "pmu.h" > > > #include "pmus.h" > > > #include "asm/bug.h" > > > +#include "ui/ui.h" > > > #include "util/parse-branch-options.h" > > > #include "util/evsel_config.h" > > > #include "util/event.h" > > > @@ -2561,6 +2562,12 @@ foreach_evsel_in_last_glob(struct evlist *evlist, > > > return 0; > > > } > > > > > > +/* Will a tracepoint filter work for str or should a BPF filter be used? */ > > > +static bool is_possible_tp_filter(const char *str) > > > +{ > > > + return strstr(str, "uid") == NULL; > > > +} > > > + > > > static int set_filter(struct evsel *evsel, const void *arg) > > > { > > > const char *str = arg; > > > @@ -2573,7 +2580,7 @@ static int set_filter(struct evsel *evsel, const void *arg) > > > return -1; > > > } > > > > > > - if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT) { > > > + if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT && is_possible_tp_filter(str)) { > > > if (evsel__append_tp_filter(evsel, str) < 0) { > > > fprintf(stderr, > > > "not enough memory to hold filter string\n"); > > > @@ -2609,6 +2616,30 @@ int parse_filter(const struct option *opt, const char *str, > > > (const void *)str); > > > } > > > > > > +int parse_uid_filter(struct evlist *evlist, uid_t uid) > > > > It failed to build on alpine 3.18. > > > > util/parse-events.h:48:45: error: unknown type name 'uid_t' > > 48 | int parse_uid_filter(struct evlist *evlist, uid_t uid); > > | ^~~~~ > > > > I'll add this. > > Thanks Namhyung! I see this in tmp.perf-tools-next so I'll assume > there's no need for a v5. Right, I've updated the branch with the fix. Thanks, Namhyung