Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp769168pxb; Fri, 22 Apr 2022 10:44:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwt6w5jrtWcssyYMYsRI4QhQzCy8CgwTibhhvpI6Vf8RbSFPJQoU8LRUm9Ns6kC1P6I/8Vy X-Received: by 2002:a65:614e:0:b0:380:bfd9:d4ea with SMTP id o14-20020a65614e000000b00380bfd9d4eamr4784242pgv.92.1650649492403; Fri, 22 Apr 2022 10:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650649492; cv=none; d=google.com; s=arc-20160816; b=ZIzzsKqgGfUrl1xWGf+uGkWU5Op/YMervK7nuTNF4z9d0sfRNUbCJoyBhaWya/cZsZ RJDDciuDa36xpi1mBKSm/dn78iq6Kg97hhPZymQy19MrIdg4KpOylNXkMVNgBM2GmHw9 x2Hi2L28f0N+9JmRq4I5HYwhX5ipAmvcPcdIRzBNJ9E448M9VRWZEgqTCw7jSrlBD8ST xvKASl0jJDCbnmQK1X5PHTRHOFYfLYIJ4lUrkXqQ5ob15qTZFBpI5uMholAw5mIiZEV4 p4V6TuOm1djsAyjPc2wz0fr0mgz3lZEXHeuz5WR1S2DY22Yb9G/+XjYjJ6WoS+LFPKT1 5VVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FFD0zJH3oQBc5g1c9IYGllUm7Oj0kW7RTHQnKod1w+I=; b=iZkLk68p21L8YS57HgnKxuntWQT3AnJ5vOT62sC0zze99BYnMUZluWklgfhXQNkRRY lVGu506FdvuRxfLagkBfzUnL6KHDCjGH3hVT7M7FE3iwiyDP12nvbGfclmL4ovrvmavB qUAv1QcMUbdqITPix9aS1rd8+LTHTVjaJuinSGL1TKcBZ1K4A8VarKrHlsmrVjF6wt15 gTFt3gBkYCU0FIgDHyu1vhN1YXEQjahkTYYrhcPIwCYx6kzuv6TMOiraTCU5pRf8c2A7 4sqAupWmNklG0P9NkcpRQlx5ORsRSvwhAFIEr6RUCoXquCX8UhtYLebCrbdzQvTnDa40 1UYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EwkFaQT8; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b2-20020a056a000cc200b0050a95333298si8623961pfv.252.2022.04.22.10.44.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 10:44:52 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EwkFaQT8; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 29C47ECCDE; Fri, 22 Apr 2022 10:31:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381340AbiDTSJ6 (ORCPT + 99 others); Wed, 20 Apr 2022 14:09:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbiDTSJ5 (ORCPT ); Wed, 20 Apr 2022 14:09:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E78F37AB7; Wed, 20 Apr 2022 11:07:10 -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 1A28A61B43; Wed, 20 Apr 2022 18:07:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F660C385A1; Wed, 20 Apr 2022 18:07:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650478029; bh=TdM5BU0+ICe7KTGSl1+zI9cfvMnKCVZWmb80Ruo/cyE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EwkFaQT81bWV9nhOemEHQRnS5yMJ76v2mL+4lHNVGgB9Ff8a/ewyGowgACD2Nz5KZ sa1DUsVrscqeOOE2NYS/hDjMOCJPyd01408szUoLUO1Rc3owql6nEY4RAROJvvWxHn Dx8LRGskwmDYn0TZk7Zp8PuleltHYXDbdND9YBEYFb+tQHA7DOSJwWIVR6mUCYAF1K iW54uFjHgUc6hpkAI/nAoJl6JY/gTgA6JEAg76+jD+KCTcmfSV3uzWcUYXa4jZTwrs 1wbk+kt5EFLeL3zhkvQu92yM0yQcowwWzJsOhTWxwKGCl82dw34slUAthVXV6zJIJE wvCyOE4d2K0rw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id E9A65400B1; Wed, 20 Apr 2022 15:07:05 -0300 (-03) Date: Wed, 20 Apr 2022 15:07:05 -0300 From: Arnaldo Carvalho de Melo To: Florian Fischer Cc: Xing Zhengjun , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Peter Zijlstra , Ingo Molnar Subject: Re: [PATCH v5] perf list: print all available tool events Message-ID: References: <20220420174244.1741958-1-florian.fischer@muhq.space> <20220420174244.1741958-2-florian.fischer@muhq.space> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220420174244.1741958-2-florian.fischer@muhq.space> X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 Em Wed, Apr 20, 2022 at 07:42:44PM +0200, Florian Fischer escreveu: > Introduce names for the new tool events 'user_time' and 'system_time'. > > $ perf list > ... > duration_time [Tool event] > user_time [Tool event] > system_time [Tool event] > ... Thanks, applied and tested. - Arnaldo > Signed-off-by: Florian Fischer > --- > tools/perf/util/evsel.c | 19 ++++++++++------ > tools/perf/util/evsel.h | 1 + > tools/perf/util/parse-events.c | 40 +++++++++++++++++++++++++++++----- > 3 files changed, 47 insertions(+), 13 deletions(-) > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index 2a1729e7aee4..d38722560e80 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -597,6 +597,17 @@ static int evsel__sw_name(struct evsel *evsel, char *bf, size_t size) > return r + evsel__add_modifiers(evsel, bf + r, size - r); > } > > +const char *evsel__tool_names[PERF_TOOL_MAX] = { > + "duration_time", > + "user_time", > + "system_time", > +}; > + > +static int evsel__tool_name(enum perf_tool_event ev, char *bf, size_t size) > +{ > + return scnprintf(bf, size, "%s", evsel__tool_names[ev]); > +} > + > static int __evsel__bp_name(char *bf, size_t size, u64 addr, u64 type) > { > int r; > @@ -723,12 +734,6 @@ static int evsel__raw_name(struct evsel *evsel, char *bf, size_t size) > return ret + evsel__add_modifiers(evsel, bf + ret, size - ret); > } > > -static int evsel__tool_name(char *bf, size_t size) > -{ > - int ret = scnprintf(bf, size, "duration_time"); > - return ret; > -} > - > const char *evsel__name(struct evsel *evsel) > { > char bf[128]; > @@ -754,7 +759,7 @@ const char *evsel__name(struct evsel *evsel) > > case PERF_TYPE_SOFTWARE: > if (evsel->tool_event) > - evsel__tool_name(bf, sizeof(bf)); > + evsel__tool_name(evsel->tool_event, bf, sizeof(bf)); > else > evsel__sw_name(evsel, bf, sizeof(bf)); > break; > diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h > index 7e2209b47b39..45d674812239 100644 > --- a/tools/perf/util/evsel.h > +++ b/tools/perf/util/evsel.h > @@ -262,6 +262,7 @@ extern const char *evsel__hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX][EVSEL__MAX_ALI > extern const char *evsel__hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX][EVSEL__MAX_ALIASES]; > extern const char *evsel__hw_names[PERF_COUNT_HW_MAX]; > extern const char *evsel__sw_names[PERF_COUNT_SW_MAX]; > +extern const char *evsel__tool_names[PERF_TOOL_MAX]; > extern char *evsel__bpf_counter_events; > bool evsel__match_bpf_counter_events(const char *name); > > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c > index 064ec368a90b..937f6c9434a2 100644 > --- a/tools/perf/util/parse-events.c > +++ b/tools/perf/util/parse-events.c > @@ -154,6 +154,21 @@ struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = { > }, > }; > > +struct event_symbol event_symbols_tool[PERF_TOOL_MAX] = { > + [PERF_TOOL_DURATION_TIME] = { > + .symbol = "duration_time", > + .alias = "", > + }, > + [PERF_TOOL_USER_TIME] = { > + .symbol = "user_time", > + .alias = "", > + }, > + [PERF_TOOL_SYSTEM_TIME] = { > + .symbol = "system_time", > + .alias = "", > + }, > +}; > + > #define __PERF_EVENT_FIELD(config, name) \ > ((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT) > > @@ -3058,21 +3073,34 @@ int print_hwcache_events(const char *event_glob, bool name_only) > return evt_num; > } > > -static void print_tool_event(const char *name, const char *event_glob, > +static void print_tool_event(const struct event_symbol *syms, const char *event_glob, > bool name_only) > { > - if (event_glob && !strglobmatch(name, event_glob)) > + if (syms->symbol == NULL) > + return; > + > + if (event_glob && !(strglobmatch(syms->symbol, event_glob) || > + (syms->alias && strglobmatch(syms->alias, event_glob)))) > return; > + > if (name_only) > - printf("%s ", name); > - else > + printf("%s ", syms->symbol); > + else { > + char name[MAX_NAME_LEN]; > + if (syms->alias && strlen(syms->alias)) > + snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); > + else > + strlcpy(name, syms->symbol, MAX_NAME_LEN); > printf(" %-50s [%s]\n", name, "Tool event"); > - > + } > } > > void print_tool_events(const char *event_glob, bool name_only) > { > - print_tool_event("duration_time", event_glob, name_only); > + // Start at 1 because the first enum entry symbols no tool event > + for (int i = 1; i < PERF_TOOL_MAX; ++i) { > + print_tool_event(event_symbols_tool + i, event_glob, name_only); > + } > if (pager_in_use()) > printf("\n"); > } > -- > 2.36.0 -- - Arnaldo