All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v3] libtracefs: Add APIs for data streaming
Date: Thu, 24 Jun 2021 12:45:42 -0400	[thread overview]
Message-ID: <20210624124542.5ca75fe3@oasis.local.home> (raw)
In-Reply-To: <20210624145101.87233-1-y.karadz@gmail.com>

On Thu, 24 Jun 2021 17:51:01 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> The new APIs can be used to dump the content of "trace_pipe" into a
> file or directly to "stdout". The "splice" system call is used to
> moves the data without copying. The new functionality is essentially
> identical to what 'trace-cmd show -p' does.
> 
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> 

So I did some investigations here, and found that splice() is not
guaranteed to work on a terminal output.

To overcome this, I decided to have the print create another pipe, and
pass that to the stream code. The if something was read, it would read
the pipe.

It required changing the return of the functions to return the amount
transferred, so that I can differentiate between "EOF" with nothing
read, and something read. Because I couldn't get the pipe to not block
on read if there was no content in it. :-/

Anyway, I submitted a v4 with the changes I made, and it appears to
work. I haven't tested it that much, so it may still have bugs.

We could optimize it to just use the splice output first (stream
first), and if that returns with EINVAL, which is the expected error on
a non functioning stdout, we could then switch to this alternate method.

Although, the stream would have read some of the pipe and lost the
data, which is not what we want, so a test of stdout would need to be
made with splice first. :-/

-- Steve

  reply	other threads:[~2021-06-24 16:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24 14:51 [PATCH v3] libtracefs: Add APIs for data streaming Yordan Karadzhov (VMware)
2021-06-24 16:45 ` Steven Rostedt [this message]
2021-06-25 13:17   ` Yordan Karadzhov
2021-06-25 13:46     ` Steven Rostedt
2021-06-25 13:57       ` Yordan Karadzhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210624124542.5ca75fe3@oasis.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=y.karadz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.