Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp861493ybk; Wed, 20 May 2020 14:02:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXWP7XsrvhVB7lhDCjp/vjE0UlBjmwboz/IsODlYUVxt4wE/CQ6K3NEy0foeeNCV0/Ev8/ X-Received: by 2002:a05:6402:687:: with SMTP id f7mr4933394edy.277.1590008521182; Wed, 20 May 2020 14:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590008521; cv=none; d=google.com; s=arc-20160816; b=yDSWJDbZDk74PM9CdFcUDvp9TxAtM6MjxV7mLotaEhW/ABq9wg3FboXZIbkDqbJY8l ZYtAaaLQg59qKfnFO3RjCpuPAxUHzmTXbdFaloSeL7H67s+1DWsgyIpkTcHazWTUBkvi ABWwDPOg+DhP8A7vza9T15iUn6Smq6HuO+HK78NgZK6UDoOqAvEDauiMuVslO1LpoEP/ P8txjdaRoKGx3DS/yHCDjukkCrFDFPDhxuVjpLTye6t0SIpMWDMnfhUlodAj4DfYl5ID lsWKmO9ps6F53OT5saaTKkDQ/NdErq9JOGQtTklM5/9OQl8r/4fviz9nZqw00qsUtuOB 3D3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ZKhnf7PdZK+uhWM7JCCholwfM5s85kyz6f7QmjL+eSA=; b=P1s7qjQcWfzWsNWIl2NydLn1dnlUFfiAreIwx4a8ww74ijWqhAdVs9SbdnWVySEv6f ZmEUFfGRKhDnguaD3qtVYwRNxATm8Zg/MHZV154oDnWfTBebN3SB+887KmSfKbQpFtVN neUxCKjxNvEHOseNlsYfLZ9pZepBtytSOUjEEEFSqbv6cWtk2dud8ZQIA/7mDdB+Fd1r u/Zxlt9f5WwhCqpY25tcWjwwG+am+bE7aeVF5rp44UjMA3x8baV6bnl3m9qU24oXZPOA VWlyDUexHchc7CUuNBbDgrLC96X+Gck76sYgf5DRWFfevaog5aLkjhXvs6ryRbZvthHm 34Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bJyJcZvk; 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 o25si2242450ejx.662.2020.05.20.14.01.38; Wed, 20 May 2020 14:02:01 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=bJyJcZvk; 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 S1728183AbgETU7p (ORCPT + 99 others); Wed, 20 May 2020 16:59:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:59044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728180AbgETU7n (ORCPT ); Wed, 20 May 2020 16:59:43 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9E73520758; Wed, 20 May 2020 20:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590008382; bh=cSZ3Z6xbm0qHdC2Xdd4hiTxmk5VZQtJFQqZpQGd27Tw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bJyJcZvk0+x9lSpU8GCPbcmNFNtUF7MxRW44vYHH9cckOkVPctXDu7BgmDzeZroi7 Rr+VLRLQt52wT3QGSUe5gXDkfxD2rlbnrmtLTJPF7qZc85/tJ4nqxUDuEzxlbJ7ah3 ibJlLVmQgkj9OATZvx/PKniu/mIRzho/2iTrv7Bs= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 9F17040AFD; Wed, 20 May 2020 17:59:40 -0300 (-03) Date: Wed, 20 May 2020 17:59:40 -0300 From: Arnaldo Carvalho de Melo To: Changbin Du Cc: Jiri Olsa , Peter Zijlstra , Ingo Molnar , Namhyung Kim , Steven Rostedt , linux-kernel@vger.kernel.org Subject: Re: [PATCH 05/19] perf ftrace: add option '-l/--list-functions' to list available functions Message-ID: <20200520205940.GS32678@kernel.org> References: <20200510150628.16610-1-changbin.du@gmail.com> <20200510150628.16610-6-changbin.du@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200510150628.16610-6-changbin.du@gmail.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sun, May 10, 2020 at 11:06:14PM +0800, Changbin Du escreveu: > This adds an option '-l/--list-functions' to list all available functions > which is read from tracing file 'available_filter_functions'. Here, in 'perf probe' we have: [acme@five perf]$ perf probe -F tcp_* | head tcp_abort tcp_ack tcp_ack_update_rtt.isra.0 tcp_add_backlog tcp_add_reno_sack tcp_adjust_pcount tcp_alloc_md5sig_pool tcp_any_retrans_done.part.0 tcp_assign_congestion_control tcp_bpf_clone [acme@five perf]$ perf probe -h -F Usage: perf probe [] 'PROBEDEF' ['PROBEDEF' ...] or: perf probe [] --add 'PROBEDEF' [--add 'PROBEDEF' ...] or: perf probe [] --del '[GROUP:]EVENT' ... or: perf probe --list [GROUP:]EVENT ... or: perf probe [] --line 'LINEDESC' or: perf probe [] --vars 'PROBEPOINT' or: perf probe [] --funcs -F, --funcs <[FILTER]> Show potential probe-able functions. [acme@five perf]$ So I think we should align with this. - Arnaldo > Signed-off-by: Changbin Du > --- > tools/perf/builtin-ftrace.c | 43 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c > index 1d30c2d5f88b..8133d910d5d8 100644 > --- a/tools/perf/builtin-ftrace.c > +++ b/tools/perf/builtin-ftrace.c > @@ -33,6 +33,7 @@ struct perf_ftrace { > struct evlist *evlist; > struct target target; > const char *tracer; > + bool list_avail_functions; > struct list_head filters; > struct list_head notrace; > struct list_head graph_funcs; > @@ -142,6 +143,43 @@ static int write_tracing_option_file(const char *name, const char *val) > return ret; > } > > +static int read_tracing_file_to_stdout(const char *name) > +{ > + char buf[4096]; > + char *file; > + int fd; > + int ret = -1; > + > + file = get_tracing_file(name); > + if (!file) { > + pr_debug("cannot get tracing file: %s\n", name); > + return -1; > + } > + > + fd = open(file, O_RDONLY); > + if (fd < 0) { > + pr_debug("cannot open tracing file: %s: %s\n", > + name, str_error_r(errno, buf, sizeof(buf))); > + goto out; > + } > + > + /* read contents to stdout */ > + while (true) { > + int n = read(fd, buf, sizeof(buf)); > + if (n <= 0) > + goto out_close; > + if (fwrite(buf, n, 1, stdout) != 1) > + goto out_close; > + } > + ret = 0; > + > +out_close: > + close(fd); > +out: > + put_tracing_file(file); > + return ret; > +} > + > static int reset_tracing_cpu(void); > static void reset_tracing_filters(void); > > @@ -332,6 +370,9 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) > signal(SIGCHLD, sig_handler); > signal(SIGPIPE, sig_handler); > > + if (ftrace->list_avail_functions) > + return read_tracing_file_to_stdout("available_filter_functions"); > + > if (reset_tracing_files(ftrace) < 0) { > pr_err("failed to reset ftrace\n"); > goto out; > @@ -483,6 +524,8 @@ int cmd_ftrace(int argc, const char **argv) > NULL > }; > const struct option ftrace_options[] = { > + OPT_BOOLEAN('L', "list-functions", &ftrace.list_avail_functions, > + "List available functions to filter"), > OPT_STRING('p', "pid", &ftrace.target.pid, "pid", > "trace on existing process id"), > OPT_INCR('v', "verbose", &verbose, > -- > 2.25.1 > -- - Arnaldo