]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
ring-buffer: Include dropped pages in counting dirty patches
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Fri, 21 Oct 2022 16:30:13 +0000 (12:30 -0400)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Dec 2022 12:59:32 +0000 (13:59 +0100)
commit83ff2932b8ffa6d1cc788aab7033f187725e852a
tree075508096ad9f6e19c86acdb94b8bdc6fbae7aed
parent8a2dd3d31adc7b21b010c9e4e4e1c0ea2177fc59
ring-buffer: Include dropped pages in counting dirty patches

[ Upstream commit 31029a8b2c7e656a0289194ef16415050ae4c4ac ]

The function ring_buffer_nr_dirty_pages() was created to find out how many
pages are filled in the ring buffer. There's two running counters. One is
incremented whenever a new page is touched (pages_touched) and the other
is whenever a page is read (pages_read). The dirty count is the number
touched minus the number read. This is used to determine if a blocked task
should be woken up if the percentage of the ring buffer it is waiting for
is hit.

The problem is that it does not take into account dropped pages (when the
new writes overwrite pages that were not read). And then the dirty pages
will always be greater than the percentage.

This makes the "buffer_percent" file inaccurate, as the number of dirty
pages end up always being larger than the percentage, event when it's not
and this causes user space to be woken up more than it wants to be.

Add a new counter to keep track of lost pages, and include that in the
accounting of dirty pages so that it is actually accurate.

Link: https://lkml.kernel.org/r/20221021123013.55fb6055@gandalf.local.home
Fixes: 2c2b0a78b3739 ("ring-buffer: Add percentage of ring buffer full to wake up reader")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 73cf0ff9a39369708c0d99d02ab378212d9c594d)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
kernel/trace/ring_buffer.c