BPF List
 help / color / mirror / Atom feed
From: Paul Chaignon <paul@isovalent.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, Quentin Monnet <quentin@isovalent.com>
Subject: [PATCH bpf v2] bpftool: Flush tracelog output
Date: Fri, 17 Dec 2021 15:11:40 +0100	[thread overview]
Message-ID: <20211217141140.GA26351@Mem> (raw)

The output of bpftool prog tracelog is currently buffered, which is
inconvenient when piping the output into other commands. A simple
tracelog | grep will typically not display anything. This patch fixes it
by flushing the tracelog output after each line from the trace_pipe file.

Fixes: 30da46b5dc3a ("tools: bpftool: add a command to dump the trace pipe")
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Paul Chaignon <paul@isovalent.com>
---
Changes in v2:
  - Resending to fix a format error.

 tools/bpf/bpftool/tracelog.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/bpf/bpftool/tracelog.c b/tools/bpf/bpftool/tracelog.c
index e80a5c79b38f..b310229abb07 100644
--- a/tools/bpf/bpftool/tracelog.c
+++ b/tools/bpf/bpftool/tracelog.c
@@ -158,6 +158,7 @@ int do_tracelog(int argc, char **argv)
 			jsonw_string(json_wtr, buff);
 		else
 			printf("%s", buff);
+		fflush(stdout);
 	}
 
 	fclose(trace_pipe_fd);
-- 
2.25.1


             reply	other threads:[~2021-12-17 14:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 14:11 Paul Chaignon [this message]
2021-12-17 16:51 ` [PATCH bpf v2] bpftool: Flush tracelog output Andrii Nakryiko
2021-12-20 21:48   ` Paul Chaignon

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=20211217141140.GA26351@Mem \
    --to=paul@isovalent.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=quentin@isovalent.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox