From 5d04edade25105032beced45f3f65b78850b1c49 Mon Sep 17 00:00:00 2001 From: Po-Ying Chiu Date: Fri, 28 Mar 2025 23:41:52 +0800 Subject: [PATCH] Improve warning message for fast buffer overflow In the original code, when the fast buffer overflows, the return value from fast_buf_put() was silently ignored. This makes it difficult to detect whether any data was lost due to the buffer being full. To improve the observability, we capture the return value in a local variable and issue a warning when an overflow occurs. Co-authored-by: EricccTaiwan --- simrupt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/simrupt.c b/simrupt.c index 677830f..696bc20 100644 --- a/simrupt.c +++ b/simrupt.c @@ -214,7 +214,9 @@ static void process_data(void) WARN_ON_ONCE(!irqs_disabled()); pr_info("simrupt: [CPU#%d] produce data\n", smp_processor_id()); - fast_buf_put(update_simrupt_data()); + int ret = fast_buf_put(update_simrupt_data()); + if (unlikely(ret < 0) && printk_ratelimit()) + pr_warn("simrupt: fast_buf is full, dropping data\n"); pr_info("simrupt: [CPU#%d] scheduling tasklet\n", smp_processor_id()); tasklet_schedule(&simrupt_tasklet);