Re: [PATCH] printk: Fix skipped entries after index iterator restart

From: Andy Shevchenko

Date: Mon Nov 16 2026 - 04:15:17 EST


On Mon, Nov 16, 2026 at 10:56:10AM +0200, Avi Weiss wrote:
> seq_read_iter() can advance the iterator before the next record
> fits in the read buffer. When iteration resumes, pi_start() calls
> pi_next() at the saved position and advances past the pending printk
> index entry. As a result, index reads can silently omit formats.
>
> Return the entry corresponding to the saved position without
> advancing the iterator.

...

> - return pi_next(s, NULL, pos);
> + return pi_get_entry(s->file->f_inode->i_private, *pos - 1);

Side note (because it seems used more in the same form), we have file_inode()
helper and this should idiomatically look as

return pi_get_entry(file_inode(s->file)->i_private, *pos - 1);

But I haven't checked if the file_inode() is recommended or deprecated API.

--
With Best Regards,
Andy Shevchenko