Re: [PATCH 1/2] pipe: change pipe_write() to never add a zero-sized buffer

Oleg Nesterov
2025-02-09T18:45:09Z

On 02/09, Linus Torvalds wrote:
>
> On Sun, 9 Feb 2025 at 10:02, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > Could you explain what do you think should I do if I keep this check?
> > make pipe_buf_assert_len() return void? or just replace it with
> > WARN_ON_ONCE(!buf->len) in its callers?
>
> Just replace it with WARN_ON_ONCE() in any place where you really
> think it's needed.

OK, will do.

> IOW, why warn for a case that isn't a problem, and you're only making
> it a problem by thinking it is?

Again, lets look eat_empty_buffer().

The comment says "maybe it's empty" but how/why can this happen ?

The changelog for d1a819a2ec2d3 ("splice: teach splice pipe reading
about empty pipe buffers") says "you can trigger it by doing a write
to a pipe that fails" but if someone looks at anon_pipe_write() after
1/2 this case is not possible.

And if eat_empty_buffer() flushes the buffer and updates pipe->tail,
why doesn't it wake the writers?

WARN_ON_ONCE() makes it clear that we do not expect !buf->len == 0,
and the kernel will complain if it does happen.

So unless you have a strong opinion, I'd prefer to keep it for now.

Oleg.