Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1541729pxk; Fri, 4 Sep 2020 12:00:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZgzn3/XFqXWskRNr6R65fWi0nqItqBWdXTBEjpe6xLc/qgrL1miQ0zGHYdEkmCIKeLsz/ X-Received: by 2002:a17:906:4305:: with SMTP id j5mr9301527ejm.102.1599246037300; Fri, 04 Sep 2020 12:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599246037; cv=none; d=google.com; s=arc-20160816; b=ZC7oRR9IDd6WkmuTGxgvS8JPAUptz4PvF9MefF3J5T51KNCq1v4zAKB4WUDd1GsKHN pazwHVgwQbOnYAlxeY/qKgpj71m01qW5qsOI1Lb0jdsII3NmWTo+r6EHL7A/aW7ZYiX0 301fCCfDXuehzy9kS1RLA+K4lmytVe90hzPCsaDKR4mVtauy1iXFUL5HPW6OuLNRTGCy 4hD1LPaqlpKeeNDao/Rj7GjtX5cK0LdSt3nvL8+QulsnD8Gr/s4q95HdP3wr1vNTbmHZ 0V4Jrzm/8h9tAWMYl6uzuRs2SAVJx9yoQkwowiCaPs1lIbLCZAHKueBLcCbUTeylRkNb xI1g== 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=qWpjORYVtNLHPwV60u/YlsN9QYOhcdU3CbHzoQ03HHo=; b=lv8lPCZepKGnxlpO9Sk05PKCbVw2xpo9BRmLjsxUJNV3mByhkMrsTVq+Nw9aAta/wy Txnh7laDgYCINfmAndZhbZrOyor1ii65E0g4rM87FTy4psHcY1nw1y9w/Seyx7Nn7M1p V8q0HjhPYErT2UDB92xYrbk3hTxlKFE7Q0+3iHPco7yYjPxcs/ssL3AnTCPoub1b4cP7 YGBF0yvMva2M3bjZTF/a7VbphvqGpckyx/2l/HCdjDxEYCGqjvNM2yjJE6i8Pu54xhz6 K0AhuYiZxKz4FhHC5a+cDqRV+rbR+HyMWH9QuFN/HUjl62o9JfNXvBeO5OJqTnmsv+Lr p3JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EtsZ2ZZE; 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 q25si4308172edt.60.2020.09.04.12.00.12; Fri, 04 Sep 2020 12:00:37 -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=EtsZ2ZZE; 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 S1727044AbgIDS47 (ORCPT + 99 others); Fri, 4 Sep 2020 14:56:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:43074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbgIDS47 (ORCPT ); Fri, 4 Sep 2020 14:56:59 -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 D712D20665; Fri, 4 Sep 2020 18:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599245818; bh=vi4wMcAnFlI7LP1Bsr5719yNonx1AiQkc7yCppe6TcE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EtsZ2ZZEPg1daImFEtJfC7roPo1epvE0FUhWXX1L2vyRfX1ner0GfebjNeZZOB9qM tlEJJWeaHk6sMuZRlV5YN5jltYX6Pd6k5XIH5EhE8GvzoTjAKgSo3Xs3ZqjWW+MbLq QCTZ11lTAxssqRbXd6Zh74DY28NHTGchysXba2nA= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 01DBB40D3D; Fri, 4 Sep 2020 15:56:55 -0300 (-03) Date: Fri, 4 Sep 2020 15:56:55 -0300 From: Arnaldo Carvalho de Melo To: Adrian Hunter Cc: Jiri Olsa , Andi Kleen , Alexey Budankov , Namhyung Kim , linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf tools: Consolidate close_control_option()'s into one function Message-ID: <20200904185655.GC3752059@kernel.org> References: <20200903122937.25691-1-adrian.hunter@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200903122937.25691-1-adrian.hunter@intel.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 Thu, Sep 03, 2020 at 03:29:37PM +0300, Adrian Hunter escreveu: > Consolidate control option fifo closing into one function. > > Signed-off-by: Adrian Hunter > --- Applied and added this: Suggested-by: Alexey Budankov Thanks, - Arnaldo > > This patch is on top of patch: > "perf tools: Add FIFO file names as alternative options to --control" > > > tools/perf/builtin-record.c | 12 +----------- > tools/perf/builtin-stat.c | 12 +----------- > tools/perf/util/evlist.c | 10 ++++++++++ > tools/perf/util/evlist.h | 1 + > 4 files changed, 13 insertions(+), 22 deletions(-) > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index 476b34ff3152..9db3901e6561 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -2253,16 +2253,6 @@ static int parse_control_option(const struct option *opt, > return evlist__parse_control(str, &opts->ctl_fd, &opts->ctl_fd_ack, &opts->ctl_fd_close); > } > > -static void close_control_option(struct record_opts *opts) > -{ > - if (opts->ctl_fd_close) { > - opts->ctl_fd_close = false; > - close(opts->ctl_fd); > - if (opts->ctl_fd_ack >= 0) > - close(opts->ctl_fd_ack); > - } > -} > - > static void switch_output_size_warn(struct record *rec) > { > u64 wakeup_size = evlist__mmap_size(rec->opts.mmap_pages); > @@ -2849,7 +2839,7 @@ int cmd_record(int argc, const char **argv) > symbol__exit(); > auxtrace_record__free(rec->itr); > out_opts: > - close_control_option(&rec->opts); > + evlist__close_control(rec->opts.ctl_fd, rec->opts.ctl_fd_ack, &rec->opts.ctl_fd_close); > return err; > } > > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > index 21424ed0734b..68d4bdf15635 100644 > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -1051,16 +1051,6 @@ static int parse_control_option(const struct option *opt, > return evlist__parse_control(str, &config->ctl_fd, &config->ctl_fd_ack, &config->ctl_fd_close); > } > > -static void close_control_option(struct perf_stat_config *config) > -{ > - if (config->ctl_fd_close) { > - config->ctl_fd_close = false; > - close(config->ctl_fd); > - if (config->ctl_fd_ack >= 0) > - close(config->ctl_fd_ack); > - } > -} > - > static struct option stat_options[] = { > OPT_BOOLEAN('T', "transaction", &transaction_run, > "hardware transaction statistics"), > @@ -2408,7 +2398,7 @@ int cmd_stat(int argc, const char **argv) > > metricgroup__rblist_exit(&stat_config.metric_events); > runtime_stat_delete(&stat_config); > - close_control_option(&stat_config); > + evlist__close_control(stat_config.ctl_fd, stat_config.ctl_fd_ack, &stat_config.ctl_fd_close); > > return status; > } > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index e72ff7e78dec..ee7b576d3b12 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -1802,6 +1802,16 @@ int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *c > return 0; > } > > +void evlist__close_control(int ctl_fd, int ctl_fd_ack, bool *ctl_fd_close) > +{ > + if (*ctl_fd_close) { > + *ctl_fd_close = false; > + close(ctl_fd); > + if (ctl_fd_ack >= 0) > + close(ctl_fd_ack); > + } > +} > + > int evlist__initialize_ctlfd(struct evlist *evlist, int fd, int ack) > { > if (fd == -1) { > diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h > index 91d1da6e1fe3..bc38a53f6a1a 100644 > --- a/tools/perf/util/evlist.h > +++ b/tools/perf/util/evlist.h > @@ -376,6 +376,7 @@ enum evlist_ctl_cmd { > }; > > int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close); > +void evlist__close_control(int ctl_fd, int ctl_fd_ack, bool *ctl_fd_close); > int evlist__initialize_ctlfd(struct evlist *evlist, int ctl_fd, int ctl_fd_ack); > int evlist__finalize_ctlfd(struct evlist *evlist); > bool evlist__ctlfd_initialized(struct evlist *evlist); > -- > 2.17.1 > -- - Arnaldo