Skip to content

Commit 5d04eda

Browse files
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 <yphbchou0911@gmail.com>
1 parent 3b85299 commit 5d04eda

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

simrupt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ static void process_data(void)
214214
WARN_ON_ONCE(!irqs_disabled());
215215

216216
pr_info("simrupt: [CPU#%d] produce data\n", smp_processor_id());
217-
fast_buf_put(update_simrupt_data());
217+
int ret = fast_buf_put(update_simrupt_data());
218+
if (unlikely(ret < 0) && printk_ratelimit())
219+
pr_warn("simrupt: fast_buf is full, dropping data\n");
218220

219221
pr_info("simrupt: [CPU#%d] scheduling tasklet\n", smp_processor_id());
220222
tasklet_schedule(&simrupt_tasklet);

0 commit comments

Comments
 (0)