[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yi1bakVfs/l6CNE0@casper.infradead.org>
Date: Sun, 13 Mar 2022 02:48:10 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: Max Kellermann <max.kellermann@...il.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/4] pipe_fs_i.h: add pipe_buf_init()
On Sun, Mar 13, 2022 at 02:37:43AM +0000, Al Viro wrote:
> On Fri, Feb 25, 2022 at 07:54:31PM +0100, Max Kellermann wrote:
>
> > /* Insert it into the buffer array */
> > buf = &pipe->bufs[head & mask];
> > - buf->page = page;
> > - buf->ops = &anon_pipe_buf_ops;
> > - buf->offset = 0;
> > - buf->len = 0;
> > - if (is_packetized(filp))
> > - buf->flags = PIPE_BUF_FLAG_PACKET;
> > - else
> > - buf->flags = PIPE_BUF_FLAG_CAN_MERGE;
> > + pipe_buf_init(buf, page, 0, 0,
> > + &anon_pipe_buf_ops,
> > + is_packetized(filp) ? PIPE_BUF_FLAG_PACKET : PIPE_BUF_FLAG_CAN_MERGE);
>
> *cringe*
> FWIW, packetized case is very rare, so how about turning that into
> pipe_buf_init(buf, page, 0, 0,
> &anon_pipe_buf_ops,
> PIPE_BUF_FLAG_CAN_MERGE);
> if (unlikely(is_packetized(filp)))
> buf->flags = PIPE_BUF_FLAG_PACKET;
> Your pipe_buf_init() is inlined, so it shouldn't be worse from the optimizer
> POV - it should be able to start with calculating that value and then storing
> that, etc.
That's not equivalent. I think the better option here is to always
initialise flags to 0 (and not have a parameter for it):
pipe_buf_init(buf, page, 0, 0, &anon_pipe_buf_ops);
if (is_packetized(filp))
buf->flags = PIPE_BUF_FLAG_PACKET;
else
buf->flags = PIPE_BUF_FLAG_CAN_MERGE;
Powered by blists - more mailing lists