linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace-cmd record: Fix -m option
@ 2022-11-15 20:35 Steven Rostedt
  0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2022-11-15 20:35 UTC (permalink / raw)
  To: Linux Trace Devel

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 --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)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-15 20:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15 20:35 [PATCH] trace-cmd record: Fix -m option Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).