[PATCH v2 2/2] printk_ringbuffer: allow one data block to occupy the entire data ring

Daniil Tatianin posted 2 patches 4 days, 15 hours ago
[PATCH v2 2/2] printk_ringbuffer: allow one data block to occupy the entire data ring
Posted by Daniil Tatianin 4 days, 15 hours ago
We no longer require a trailing id at the end of the data ring, so
there is no reason to check that one fits.

Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
 kernel/printk/printk_ringbuffer.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/kernel/printk/printk_ringbuffer.c b/kernel/printk/printk_ringbuffer.c
index 99989a9ce4b4..cbbd356b085b 100644
--- a/kernel/printk/printk_ringbuffer.c
+++ b/kernel/printk/printk_ringbuffer.c
@@ -397,21 +397,14 @@ static unsigned int to_blk_size(unsigned int size)
  */
 static bool data_check_size(struct prb_data_ring *data_ring, unsigned int size)
 {
-	struct prb_data_block *db = NULL;
-
 	if (size == 0)
 		return true;
 
 	/*
 	 * Ensure the alignment padded size could possibly fit in the data
-	 * array. The largest possible data block must still leave room for
-	 * at least the ID of the next block.
+	 * array.
 	 */
-	size = to_blk_size(size);
-	if (size > DATA_SIZE(data_ring) - sizeof(db->id))
-		return false;
-
-	return true;
+	return (to_blk_size(size) <= DATA_SIZE(data_ring));
 }
 
 /* Query the state of a descriptor. */
-- 
2.43.0
Re: [PATCH v2 2/2] printk_ringbuffer: allow one data block to occupy the entire data ring
Posted by John Ogness 4 days, 14 hours ago
On 2025-09-05, Daniil Tatianin <d-tatianin@yandex-team.ru> wrote:
> We no longer require a trailing id at the end of the data ring, so
> there is no reason to check that one fits.
>
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>

Reviewed-by: John Ogness <john.ogness@linutronix.de>
Tested-by: John Ogness <john.ogness@linutronix.de>