You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The comment in the produce_data function mentions "skip oldest element if kfifo buffer is full".
staticvoidproduce_data(unsigned charval)
{
/* Implement a kind of circular FIFO here (skip oldest element if kfifo * buffer is full). */unsigned intlen=kfifo_in(&rx_fifo, &val, sizeof(val));
if (unlikely(len<sizeof(val)) &&printk_ratelimit())
pr_warn("%s: %zu bytes dropped\n", __func__, sizeof(val) -len);
pr_debug("simrupt: %s: in %u/%u bytes\n", __func__, len,
kfifo_len(&rx_fifo));
}
But in fact, it seems that when the buffer is full, it will choose not to insert new data, because the implementation of kfifo_in will first confirm whether the size to be put is greater than the remaining size. If it is, the remaining size will be the main one.
Refine the subject of this issue to make it more informative. In addition, you should provide some code snippets to emphasize the case you are concerned about.
pao0626
changed the title
About simrupt.c code comments
The function annotation description in the simrupt.c file seems to be wrong.
Jun 27, 2024
The comment in the produce_data function mentions "skip oldest element if kfifo buffer is full".
But in fact, it seems that when the buffer is full, it will choose not to insert new data, because the implementation of kfifo_in will first confirm whether the size to be put is greater than the remaining size. If it is, the remaining size will be the main one.
[ref: https://elixir.bootlin.com/linux/latest/source/lib/kfifo.c#L113]
The text was updated successfully, but these errors were encountered: