Re: [PATCH v2 0/2] printk_ringbuffer: don't needlessly wrap data blocks around

Petr Mladek
2025-09-11T15:58:50Z

On Thu 2025-09-11 17:30:36, Petr Mladek wrote:
> On Fri 2025-09-05 17:41:50, Daniil Tatianin wrote:
> > This series fixes the issue where data blocks would wrap in cases where the last
> > data block perfectly fits the ring. This caused whatever was at the beginning of
> > the ring to get discarded in this case, and the data block would get put there
> > even though it could be put at the end of the data ring just fine without
> > discarding anything.
> >
> > Fixing this issue also allows to simplify the check in data_check_size,
> > previously it would ensure there's space for a trailing id, which we
> > don't need anymore.
> >
> > v0->v1:
> > - Fix severely broken code alignment
> >
> > v1->v2:
> > - Rename & invert get_next_lpos -> is_blk_wrapped
> > - Add a new commit for changing the logic in data_check_size
>
> The patchset looks good to me. But I wanted to do some tests
> and it failed. I did the following:
>
> 1. Applied this patchset on top of printk/linux.git, branch for-next,
> https://git.kernel.org/pub/scm/linux/kernel/git/printk/linux.git/log/?h=for-next
>
> I this branch because it contains a new KUnit test for the printk
> ring buffer.

I forgot the add the patch:

diff --git a/kernel/printk/printk_ringbuffer_kunit_test.c b/kernel/printk/printk_ringbuffer_kunit_test.c
index 2282348e869a..241f7ef49ac6 100644
--- a/kernel/printk/printk_ringbuffer_kunit_test.c
+++ b/kernel/printk/printk_ringbuffer_kunit_test.c
@@ -56,7 +56,7 @@ struct prbtest_rbdata {
char text[] __counted_by(size);
};

-#define MAX_RBDATA_TEXT_SIZE 0x80
+#define MAX_RBDATA_TEXT_SIZE (0x256 - sizeof(struct prbtest_rbdata))
#define MAX_PRB_RECORD_SIZE (sizeof(struct prbtest_rbdata) + MAX_RBDATA_TEXT_SIZE)

struct prbtest_data {
@@ -251,7 +251,7 @@ static inline void prbtest_prb_reinit(struct printk_ringbuffer *rb)
static void test_readerwriter(struct kunit *test)
{
/* Equivalent to CONFIG_LOG_BUF_SHIFT=13 */
- DEFINE_PRINTKRB(test_rb, 8, 5);
+ DEFINE_PRINTKRB(test_rb, 4, 4);

struct prbtest_thread_data *thread_data;
struct prbtest_data *test_data;
--
2.51.0

Best Regards,
Petr