Skip to content

Commit c1d5f45

Browse files
Improve rate limiting for rare buffer warnings
Use pr_warn_ratelimited() to avoid global ratelimit interference from printk_ratelimit(), which is discouraged in the kernel due to shared state across unrelated callsites. Co-authored-by: Po-Ying Chiu <[email protected]>
1 parent 30aa86d commit c1d5f45

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: main.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ static DECLARE_WAIT_QUEUE_HEAD(rx_wait);
9696
static void produce_board(void)
9797
{
9898
unsigned int len = kfifo_in(&rx_fifo, draw_buffer, sizeof(draw_buffer));
99-
if (unlikely(len < sizeof(draw_buffer)) && printk_ratelimit())
100-
pr_warn("%s: %zu bytes dropped\n", __func__, sizeof(draw_buffer) - len);
99+
if (unlikely(len < sizeof(draw_buffer)))
100+
pr_warn_ratelimited("%s: %zu bytes dropped\n", __func__,
101+
sizeof(draw_buffer) - len);
101102

102103
pr_debug("kxo: %s: in %u/%u bytes\n", __func__, len, kfifo_len(&rx_fifo));
103104
}

0 commit comments

Comments
 (0)