diff mbox series

[bpf,v3] bpftool: Enable line buffering for stdout

Message ID 20211220214528.GA11706@Mem (mailing list archive)
State Accepted
Delegated to: BPF
Headers show
Series [bpf,v3] bpftool: Enable line buffering for stdout | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: kuba@kernel.org; 7 maintainers not CCed: kuba@kernel.org songliubraving@fb.com netdev@vger.kernel.org yhs@fb.com john.fastabend@gmail.com kafai@fb.com kpsingh@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-PR fail PR summary
bpf/vmtest-bpf fail VM_Test

Commit Message

Paul Chaignon Dec. 20, 2021, 9:45 p.m. UTC
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 enabling line buffering on stdout for the whole bpftool binary.

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 v3:
  - Title changed from "bpftool: Flush tracelog output".
  - Enable line buffering for all of bpftool, as suggested by Andrii.
  - Rebased on bpf.
Changes in v2:
  - Resending to fix a format error.

 tools/bpf/bpftool/main.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Yonghong Song Dec. 21, 2021, 12:31 a.m. UTC | #1
On 12/20/21 1:45 PM, Paul Chaignon wrote:
> 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 enabling line buffering on stdout for the whole bpftool binary.
> 
> 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>

Acked-by: Yonghong Song <yhs@fb.com>
diff mbox series

Patch

diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index 28237d7cef67..8fbcff9d557d 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -400,6 +400,8 @@  int main(int argc, char **argv)
 	};
 	int opt, ret;
 
+	setlinebuf(stdout);
+
 	last_do_help = do_help;
 	pretty_output = false;
 	json_output = false;