Commit 45d99ea
ring-buffer: Fix bytes info in per_cpu buffer stats
The 'bytes' info in file 'per_cpu/cpu<X>/stats' means the number of
bytes in cpu buffer that have not been consumed. However, currently
after consuming data by reading file 'trace_pipe', the 'bytes' info
was not changed as expected.
# cat per_cpu/cpu0/stats
entries: 0
overrun: 0
commit overrun: 0
bytes: 568 <--- 'bytes' is problematical !!!
oldest event ts: 8651.371479
now ts: 8653.912224
dropped events: 0
read events: 8
The root cause is incorrect stat on cpu_buffer->read_bytes. To fix it:
1. When stat 'read_bytes', account consumed event in rb_advance_reader();
2. When stat 'entries_bytes', exclude the discarded padding event which
is smaller than minimum size because it is invisible to reader. Then
use rb_page_commit() instead of BUF_PAGE_SIZE at where accounting for
page-based read/remove/overrun.
Also correct the comments of ring_buffer_bytes_cpu() in this patch.
Link: https://lore.kernel.org/linux-trace-kernel/20230921125425.1708423-1-zhengyejian1@huawei.com
Cc: stable@vger.kernel.org
Fixes: c64e148 ("trace: Add ring buffer stats to measure rate of events")
Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>1 parent ce9ecca commit 45d99ea
1 file changed
+15
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
357 | 362 | | |
358 | 363 | | |
359 | 364 | | |
| |||
2003 | 2008 | | |
2004 | 2009 | | |
2005 | 2010 | | |
2006 | | - | |
| 2011 | + | |
2007 | 2012 | | |
2008 | 2013 | | |
2009 | 2014 | | |
| |||
2367 | 2372 | | |
2368 | 2373 | | |
2369 | 2374 | | |
2370 | | - | |
2371 | | - | |
2372 | | - | |
2373 | | - | |
2374 | | - | |
2375 | 2375 | | |
2376 | 2376 | | |
2377 | 2377 | | |
| |||
2517 | 2517 | | |
2518 | 2518 | | |
2519 | 2519 | | |
2520 | | - | |
| 2520 | + | |
2521 | 2521 | | |
2522 | 2522 | | |
2523 | 2523 | | |
| |||
2660 | 2660 | | |
2661 | 2661 | | |
2662 | 2662 | | |
2663 | | - | |
2664 | | - | |
2665 | | - | |
2666 | 2663 | | |
2667 | 2664 | | |
2668 | 2665 | | |
| |||
2676 | 2673 | | |
2677 | 2674 | | |
2678 | 2675 | | |
2679 | | - | |
| 2676 | + | |
| 2677 | + | |
2680 | 2678 | | |
2681 | 2679 | | |
2682 | 2680 | | |
| |||
2701 | 2699 | | |
2702 | 2700 | | |
2703 | 2701 | | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
2704 | 2705 | | |
2705 | 2706 | | |
2706 | 2707 | | |
| |||
4215 | 4216 | | |
4216 | 4217 | | |
4217 | 4218 | | |
4218 | | - | |
| 4219 | + | |
4219 | 4220 | | |
4220 | 4221 | | |
4221 | 4222 | | |
| |||
4723 | 4724 | | |
4724 | 4725 | | |
4725 | 4726 | | |
| 4727 | + | |
4726 | 4728 | | |
4727 | 4729 | | |
4728 | 4730 | | |
| |||
5816 | 5818 | | |
5817 | 5819 | | |
5818 | 5820 | | |
5819 | | - | |
| 5821 | + | |
5820 | 5822 | | |
5821 | 5823 | | |
5822 | 5824 | | |
| |||
0 commit comments