Re: [PATCH V2 4/6] perf tools: Add FIFO file names as alternative options to --control

Jiri Olsa
2020-09-01T20:07:06Z

On Tue, Sep 01, 2020 at 12:37:56PM +0300, Adrian Hunter wrote:

SNIP

> + fd = open(s, O_RDWR | O_NONBLOCK | O_CLOEXEC);
> + if (fd < 0) {
> + pr_err("Failed to open '%s'\n", s);
> + ret = -errno;
> + goto out_free;
> + }
> + *ctl_fd = fd;
> + *ctl_fd_close = true;
> +
> + if (p && *++p) {
> + /* O_RDWR | O_NONBLOCK means the other end need not be open */
> + fd = open(p, O_RDWR | O_NONBLOCK | O_CLOEXEC);
> + if (fd < 0) {
> + pr_err("Failed to open '%s'\n", p);
> + ret = -errno;
> + goto out_free;
> + }
> + *ctl_fd_ack = fd;
> + }
> +
> +out_free:
> + free(s);
> + return ret;
> +}
> +
> +int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close)
> {
> char *comma = NULL, *endptr = NULL;
>
> if (strncmp(str, "fd:", 3))
> - return -EINVAL;
> + return evlist__parse_control_names(str, ctl_fd, ctl_fd_ack, ctl_fd_close);

could you please proactively set *ctl_fd_close = false in here,
so it's obvious.. also evlist__parse_control_fifo might be better
name, other that that it all looks great

we were recently asked to prvide faster intel_pt snapshot control
and we were thinking of putting input_pt support to libperf, but
your change might just fix this

for the patchset:

Acked-by: Jiri Olsa <jolsa@redhat.com>

Alexey, could you please check on this?

thanks,
jirka

>
> *ctl_fd = strtoul(&str[3], &endptr, 0);
> if (endptr == &str[3])

SNIP