include/linux/pipe_fs_i.h | 1 + 1 file changed, 1 insertion(+)
Add htmldoc annotation for the newly introduced "head_tail" member
describing it to be a union of the pipe_inode_info's @head and @tail
members.
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Closes: https://lore.kernel.org/lkml/20250305204609.5e64768e@canb.auug.org.au/
Fixes: 3d252160b818 ("fs/pipe: Read pipe->{head,tail} atomically outside pipe->mutex")
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
---
include/linux/pipe_fs_i.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index 3cc4f8eab853..44b8c346ae2d 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -65,6 +65,7 @@ union pipe_index {
* @wr_wait: writer wait point in case of full pipe
* @head: The point of buffer production
* @tail: The point of buffer consumption
+ * @head_tail: unsigned long union of @head and @tail
* @note_loss: The next read() should insert a data-lost message
* @max_usage: The maximum number of slots that may be used in the ring
* @ring_size: total number of buffers (should be a power of 2)
base-commit: 48a5eed9ad584315c30ed35204510536235ce402
--
2.34.1
On Wed, 5 Mar 2025 at 01:24, K Prateek Nayak <kprateek.nayak@amd.com> wrote:
>
> Add htmldoc annotation for the newly introduced "head_tail" member
> describing it to be a union of the pipe_inode_info's @head and @tail
> members.
Applied.
I also committed the pipe_occupancy() fix for 32-bit, but did so
without testing - it was ObviouslyCorrect(tm), but considering that
everybody missed it in the original patch, "obvious" is all relative.
And it turns out my worry about pipe_discard_from() was unnecessary.
Yes, the code is buggy. But no, it doesn't matter. Why? There are no
callers of that function ;)
That said, I still hope people will take a look at the code and see if
there's anything else I missed.
Oh, and testing. Testing would be good.
Linus
Hello Linus,
On 3/5/2025 11:05 PM, Linus Torvalds wrote:
> On Wed, 5 Mar 2025 at 01:24, K Prateek Nayak <kprateek.nayak@amd.com> wrote:
>>
>> Add htmldoc annotation for the newly introduced "head_tail" member
>> describing it to be a union of the pipe_inode_info's @head and @tail
>> members.
>
> Applied.
Thank you.
>
> I also committed the pipe_occupancy() fix for 32-bit, but did so
> without testing - it was ObviouslyCorrect(tm), but considering that
> everybody missed it in the original patch, "obvious" is all relative.
>
> And it turns out my worry about pipe_discard_from() was unnecessary.
> Yes, the code is buggy. But no, it doesn't matter. Why? There are no
> callers of that function ;)
On the topic of pipe_discard_from(), Al had added that helper in commit
c3497fd009ef ("fix short copy handling in copy_mc_pipe_to_iter()") to
discard unused buffer for copy_mc_to_iter()
Its usage in copy_mc_pipe_to_iter() was later removed in commit
8fad7767edcf ("ITER_PIPE: allocate buffers as we go in copy-to-pipe
primitives) in favor of iov_iter_revert()
pipe_advance() started using it in from commit 2c855de93314 ("ITER_PIPE:
clean pipe_advance() up") however all of that was nuked in commit
3fc40265ae2b ("iov_iter: Kill ITER_PIPE")
generic_file_splice_read() started using it from commit 0d9649341363
("splice: stop abusing iov_iter_advance() to flush a pipe") but
generic_file_splice_read() was later removed in commit c6585011bc1d
("splice: Remove generic_file_splice_read()")
I don't see any in kernel user of this helper currently so can the
wrap-around issue be addressed and the helper be removed later?
>
> That said, I still hope people will take a look at the code and see if
> there's anything else I missed.
>
> Oh, and testing. Testing would be good.
>
> Linus
--
Thanks and Regards,
Prateek
On Wed, 5 Mar 2025 at 08:08, K Prateek Nayak <kprateek.nayak@amd.com> wrote:
>
> > And it turns out my worry about pipe_discard_from() was unnecessary.
> > Yes, the code is buggy. But no, it doesn't matter. Why? There are no
> > callers of that function ;)
>
]> I don't see any in kernel user of this helper currently so can the
> wrap-around issue be addressed and the helper be removed later?
Yes. That's what I did. I still would love to see
- more testing
- explicit limit checking in pipe_resize_ring()
and then I think we could make CONFIG_64BIT use the 16-bit
pipe_index_t too (because not doing so clearly was a mistake: it meant
that people didn't test the 32-bit case, so the wrap-around bugs
weren't as obvious).
Linus
Linus
© 2016 - 2026 Red Hat, Inc.