diff mbox series

trace-cmd record: Fix -m option

Message ID 20221115153502.5253871c@gandalf.local.home (mailing list archive)
State Accepted
Commit 83f5d28ee73784db38d02bdb64f089ea415430e9
Headers show
Series trace-cmd record: Fix -m option | expand

Commit Message

Steven Rostedt Nov. 15, 2022, 8:35 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The -m option limits the size of each per-cpu buffer to the value
specified in kbs (or actually pages). That is, if -m 1000 is specified,
then the size per cpu buffer should not be more that 1000 kbs. Since it is
implemented in halfs, it is usually between half and the full amount.

But since the buffer reads can use pipes, the increment of the page count
needs to take that into consideration. Currently, it just increments the
page count every time the count goes over the page size. But due to pipes,
the size increment can be multiple pages (65k in fact), and this distorts
the size.

Have the page count increment via the actually size read and not just by
one even if several pages were read at one go.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-recorder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c
index 20deb31c0897..f387091f5177 100644
--- a/lib/trace-cmd/trace-recorder.c
+++ b/lib/trace-cmd/trace-recorder.c
@@ -287,8 +287,8 @@  static inline void update_fd(struct tracecmd_recorder *recorder, int size)
 	recorder->count += size;
 
 	if (recorder->count >= recorder->page_size) {
+		recorder->pages += recorder->count / recorder->page_size;
 		recorder->count = 0;
-		recorder->pages++;
 	}
 
 	if (recorder->pages < recorder->max)