Re: [RFC PATCH v9 11/11] trace-cmd: Add splice() recording from FIFO without additional pipe buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2019-04-03 at 16:11 +0300, Slavomir Kaslev wrote:
> On Wed, 2019-04-03 at 08:55 -0400, Steven Rostedt wrote:
> > On Tue,  2 Apr 2019 16:45:40 +0300
> > Slavomir Kaslev <kaslevs@xxxxxxxxxx> wrote:
> > 
> > > +/*
> > > + * Returns -1 on error.
> > > + *          or bytes of data read.
> > > + */
> > > +static long direct_splice_data(struct tracecmd_recorder
> > > *recorder)
> > > +{
> > > +	struct pollfd pfd = {
> > > +		.fd = recorder->trace_fd,
> > > +		.events = POLLIN,
> > > +	};
> > > +	long read;
> > > +	int ret;
> > > +
> > > +	ret = poll(&pfd, 1, POLL_TIMEOUT_MS);
> > > +	if (ret < 0)
> > > +		return -1;
> > > +
> > > +	if (!(pfd.revents | POLLIN))
> > > +		return 0;
> > 
> > Why the polling code, and not just block on splice?
> 
> To work around older kernels that don't have the splice(2)
> O_NONBLOCKING fix[1] for pipes.
> 
> An alternative would be to configure SIGINT not to auto restart
> syscalls (which is the default afaik). Then splice(2) will return
> EAGAIN and will can restart it with SPLICE_F_NONBLOCK flag on.
  ^EINTR

> 
> [1] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ee5e001196d1345b8fee25925ff5f1d67936081e




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux