Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp548693pxu; Fri, 11 Dec 2020 08:26:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaqAKd5qKiANeRxYb3ovfDCR+zQSB/kv2o7eiXR3olbkq03i00i/NQRqaeBOmOxywspZSC X-Received: by 2002:a17:906:4e53:: with SMTP id g19mr11519322ejw.454.1607703992022; Fri, 11 Dec 2020 08:26:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607703992; cv=none; d=google.com; s=arc-20160816; b=Ap3kt2v/K9snrsU6TowE+7Nzgn+0L+KC5ToVxumGY30NlWnkmbIFrO6FR5Bh3eISIL txnx7kvIbicDxsWYuRlo0JpvNopRC9zHns0zhGyvV2fTRTvMyBIAANHo34YAV1e+MmZX cBtOQg2kD//RdjjUHdf4S/NDcRRRLe8ACb8hxvuZEE/Axbq0iMBDhSFXL40bDMPJdSOS 4J68S2fbrI9L653yp19nCnErc2bf16/SKv570/5p8arLnGxWqlq9WZcf+1UA8x7drPsI gWVnSdlrh0BhRru61COSdpDJj/aWgWY5jb5FrMq/whviNN/VuGdspoALVyF8TqmYL/ai Oh/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=piHL79usIKMcOdpURmr68KK8h5zWFby3qc0C02VieCg=; b=0QQFL5lJkrwlbNV6oEhnAoJkjLbXqbgd7MWvhftG+knCupo0XtMtwhwJ2ONy/G8awC hHTizI8p5YTEz8omhC7cPZpMELyb64lTgZDcK3dS4sQye8R65pSO3k93Gq6nA4Vx+9Ih cmEIFKgB32wDW17QEuS9gM2TSOr5J4HgtnuBHI+e0H/ddP71h8ZtlRwX7oNx8DRaxSmp Hn3nOFIKlogTyDqcVq3y4JcwZS2nIPEmTS+kG/Sht6SPE0uj8ollik5h70epjKIOCXQ8 1Kzv9LQ/ekAgchgtyor4JQbM9LIE7oyualTIKK5hl3PmH6dLLLRKEFMG6Nxe7iQ8MueT T/ZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z5si5578182ejj.549.2020.12.11.08.26.09; Fri, 11 Dec 2020 08:26:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395088AbgLKD2k (ORCPT + 99 others); Thu, 10 Dec 2020 22:28:40 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:33868 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405223AbgLKD2e (ORCPT ); Thu, 10 Dec 2020 22:28:34 -0500 Received: by mail-lj1-f196.google.com with SMTP id y16so9312553ljk.1 for ; Thu, 10 Dec 2020 19:28:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=piHL79usIKMcOdpURmr68KK8h5zWFby3qc0C02VieCg=; b=q94ycxFbgmhGCAkCMwFjH76LA4bdZ49JNdPlMy+br+MYY1Xs6TJdDh1ArM2WUexcdb GRoNgIJhgfyHg1PYhKIJ9i4NEZwvwMDanmU1pNWxL8KQh2DCErG6BoMkFuc+J7yhzGWh ArtZKEp+a/2UqyQ2v6ioLXS/mXJ5FMfZRvPj0XN26f5oWmQC4Ui1kHIx7SV0EygFMtaN iDUUJ45H2qHO//mTC7mCaRfwSIILOfPidq3eiIEm5ZurfN9qfX8nLHkCROr46lWZ5vEV JRn2CVvq+1Yas38qv75UfC1Ggy10TS1igfrpQAD6Bx3sG4J0To9Phzc53RO15XXj4Ho5 6+lQ== X-Gm-Message-State: AOAM533xKJqVcvtGZF6L6o8ne8/4C3qNjrbKzfsSN7y++mS7bnXkafub uxPQhjkx5rsYa3UDWF6OOqYVROf34pNCLv1Jk3s= X-Received: by 2002:a2e:8e81:: with SMTP id z1mr4083697ljk.23.1607657270977; Thu, 10 Dec 2020 19:27:50 -0800 (PST) MIME-Version: 1.0 References: <20201210204330.233864-1-jolsa@kernel.org> <20201210204330.233864-4-jolsa@kernel.org> In-Reply-To: <20201210204330.233864-4-jolsa@kernel.org> From: Namhyung Kim Date: Fri, 11 Dec 2020 12:27:39 +0900 Message-ID: Subject: Re: [PATCH 3/3] perf tools: Add evlist/evlist-verbose control commands To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian , Alexei Budankov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jiri, On Fri, Dec 11, 2020 at 5:43 AM Jiri Olsa wrote: > > Adding new control events to display all evlist events. > > The interface string for control file is 'evlist' and > 'evlist-verbose'. > > When evlist is received, perf will scan and print current > evlist into perf record terminal. > > When evlist-verbose is received perf will scan and print > current evlist details (like perf evlist -v) into perf > record terminal. > > Example session: > > terminal 1: > # mkfifo control ack perf.pipe > # perf record --control=fifo:control,ack -e 'sched:*' > > terminal 2: > # echo evlist > control > > terminal 1: > # perf record --control=fifo:control,ack -e 'sched:*' > ... > sched:sched_kthread_stop > sched:sched_kthread_stop_ret > sched:sched_waking > sched:sched_wakeup > sched:sched_wakeup_new > sched:sched_switch > sched:sched_migrate_task > sched:sched_process_free > sched:sched_process_exit > ... > > terminal 2: > # echo evlist-vebose > control > > terminal 1: > ... > sched:sched_kthread_stop: type: 2, size: 120, config: 0x145, \ > { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU \ > |PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: \ > 1, sample_id_all: 1, exclude_guest: 1 > sched:sched_kthread_stop_ret: type: 2, size: 120, config: 0x144 \ > , { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU \ > |PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, \ > sample_id_all: 1, exclude_guest: 1 > ... > > This new evlist command is handy to get real event names when > wildcards are used. > > The evlist-verbose is handy to check on actually enabled perf_event_attr > values. > > Signed-off-by: Jiri Olsa Acked-by: Namhyung Kim Thanks, Namhyung > --- > tools/perf/builtin-record.c | 2 ++ > tools/perf/builtin-stat.c | 2 ++ > tools/perf/util/evlist.c | 15 +++++++++++++++ > tools/perf/util/evlist.h | 4 ++++ > 4 files changed, 23 insertions(+) > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index 582b8fba012c..d40406880722 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -1951,6 +1951,8 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) > case EVLIST_CTL_CMD_UNSUPPORTED: > case EVLIST_CTL_CMD_ENABLE_EVSEL: > case EVLIST_CTL_CMD_DISABLE_EVSEL: > + case EVLIST_CTL_CMD_EVLIST: > + case EVLIST_CTL_CMD_EVLIST_VERBOSE: > default: > break; > } > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > index 6a21fb665008..425e2a8ebde6 100644 > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -592,6 +592,8 @@ static void process_evlist(struct evlist *evlist, unsigned int interval) > case EVLIST_CTL_CMD_UNSUPPORTED: > case EVLIST_CTL_CMD_ENABLE_EVSEL: > case EVLIST_CTL_CMD_DISABLE_EVSEL: > + case EVLIST_CTL_CMD_EVLIST: > + case EVLIST_CTL_CMD_EVLIST_VERBOSE: > default: > break; > } > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index 729c98d10628..571d2ad61f4a 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -24,6 +24,7 @@ > #include "bpf-event.h" > #include "util/string2.h" > #include "util/perf_api_probe.h" > +#include "util/evsel_fprintf.h" > #include > #include > #include > @@ -1931,6 +1932,12 @@ static int evlist__ctlfd_recv(struct evlist *evlist, enum evlist_ctl_cmd *cmd, > (sizeof(EVLIST_CTL_CMD_SNAPSHOT_TAG)-1))) { > *cmd = EVLIST_CTL_CMD_SNAPSHOT; > pr_debug("is snapshot\n"); > + } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_EVLIST_VERBOSE_TAG, > + (sizeof(EVLIST_CTL_CMD_EVLIST_VERBOSE_TAG)-1))) { > + *cmd = EVLIST_CTL_CMD_EVLIST_VERBOSE; > + } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_EVLIST_TAG, > + (sizeof(EVLIST_CTL_CMD_EVLIST_TAG)-1))) { > + *cmd = EVLIST_CTL_CMD_EVLIST; > } > } > > @@ -1954,6 +1961,7 @@ int evlist__ctlfd_ack(struct evlist *evlist) > > int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd) > { > + struct perf_attr_details details = { .verbose = false, }; > int err = 0; > char cmd_data[EVLIST_CTL_CMD_MAX_LEN]; > int ctlfd_pos = evlist->ctl_fd.pos; > @@ -1995,6 +2003,13 @@ int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd) > pr_info("failed: can't find '%s' event\n", evsel_name); > } > break; > + case EVLIST_CTL_CMD_EVLIST_VERBOSE: > + details.verbose = true; > + __fallthrough; > + case EVLIST_CTL_CMD_EVLIST: > + evlist__for_each_entry(evlist, evsel) > + evsel__fprintf(evsel, &details, stderr); > + break; > case EVLIST_CTL_CMD_SNAPSHOT: > break; > case EVLIST_CTL_CMD_ACK: > diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h > index e4e8ff8831a3..7892f084632d 100644 > --- a/tools/perf/util/evlist.h > +++ b/tools/perf/util/evlist.h > @@ -332,6 +332,8 @@ struct evsel *evlist__reset_weak_group(struct evlist *evlist, struct evsel *evse > #define EVLIST_CTL_CMD_SNAPSHOT_TAG "snapshot" > #define EVLIST_CTL_CMD_ENABLE_EVSEL_TAG "enable-" > #define EVLIST_CTL_CMD_DISABLE_EVSEL_TAG "disable-" > +#define EVLIST_CTL_CMD_EVLIST_TAG "evlist" > +#define EVLIST_CTL_CMD_EVLIST_VERBOSE_TAG "evlist-verbose" > > #define EVLIST_CTL_CMD_MAX_LEN 64 > > @@ -343,6 +345,8 @@ enum evlist_ctl_cmd { > EVLIST_CTL_CMD_DISABLE_EVSEL, > EVLIST_CTL_CMD_ACK, > EVLIST_CTL_CMD_SNAPSHOT, > + EVLIST_CTL_CMD_EVLIST, > + EVLIST_CTL_CMD_EVLIST_VERBOSE, > }; > > int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close); > -- > 2.26.2 >