mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
perf tools: Consolidate close_control_option()'s into one function
Consolidate control option fifo closing into one function. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Suggested-by: Alexey Budankov <alexey.budankov@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lore.kernel.org/lkml/20200903122937.25691-1-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
9818923634
commit
ee7fe31e6e
@@ -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 @@ out:
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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"),
|
||||
@@ -2410,7 +2400,7 @@ out:
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user