diff mbox series

[v2] trace-cmd stat: Add sub-buffer size

Message ID 20240108184123.62f9be6b@gandalf.local.home (mailing list archive)
State Accepted
Commit b86599e459618f858d5d596ac3854a8c529fad84
Headers show
Series [v2] trace-cmd stat: Add sub-buffer size | expand

Commit Message

Steven Rostedt Jan. 8, 2024, 11:41 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Show the sub-buffer size if the file system supports it and it is different
than the architecture page size.

This requires libtracefs 1.8, so update the Makefile with that
requirement.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
Changes since v1: https://lore.kernel.org/linux-trace-devel/20231228222008.2742615a@rorschach.local.home

- Added requirement of libtracefs version 1.8 in Makefile and meson.build.

 Makefile              | 2 +-
 meson.build           | 2 +-
 tracecmd/trace-stat.c | 7 +++++++
 3 files changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 7058159cf51b..5429859760af 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@  export LIBTRACECMD_VERSION
 VERSION_FILE = ltc_version.h
 
 LIBTRACEEVENT_MIN_VERSION = 1.5
-LIBTRACEFS_MIN_VERSION = 1.6
+LIBTRACEFS_MIN_VERSION = 1.8
 
 MAKEFLAGS += --no-print-directory
 
diff --git a/meson.build b/meson.build
index fbdf016f67a7..aadfe277b5be 100644
--- a/meson.build
+++ b/meson.build
@@ -25,7 +25,7 @@  htmldir = join_paths(prefixdir, get_option('htmldir'))
 conf = configuration_data()
 
 libtraceevent_dep = dependency('libtraceevent', version: '>= 1.5.0', required: true)
-libtracefs_dep = dependency('libtracefs', version: '>= 1.6.0', required: true)
+libtracefs_dep = dependency('libtracefs', version: '>= 1.8.0', required: true)
 
 threads_dep = dependency('threads', required: true)
 dl_dep = cc.find_library('dl', required : false)
diff --git a/tracecmd/trace-stat.c b/tracecmd/trace-stat.c
index 9a6e22254b48..1d95d9934b47 100644
--- a/tracecmd/trace-stat.c
+++ b/tracecmd/trace-stat.c
@@ -633,6 +633,8 @@  static void report_buffers(struct buffer_instance *instance)
 	char *str;
 	char *cont;
 	char file[FILE_SIZE];
+	int pagesize;
+	int bufsize;
 	int cpu;
 
 	str = tracefs_instance_file_read(instance->tracefs, "buffer_size_kb", NULL);
@@ -678,6 +680,11 @@  static void report_buffers(struct buffer_instance *instance)
 	printf("\nBuffer total size in kilobytes:\n");
 	printf("   %s\n", str);
 
+	pagesize = getpagesize();
+	bufsize = tracefs_instance_get_subbuf_size(instance->tracefs);
+	if (bufsize > 0 && bufsize * 1024 != pagesize)
+		printf("\nSub-buffer size in kilobytes:\n   %d\n", bufsize);
+
  out:
 	free(str);
 }