Re: [PATCH 14/44] ITER_PIPE: helper for getting pipe buffer by index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 22, 2022 at 05:15:22AM +0100, Al Viro wrote:
> pipe_buffer instances of a pipe are organized as a ring buffer,
> with power-of-2 size.  Indices are kept *not* reduced modulo ring
> size, so the buffer refered to by index N is
> 	pipe->bufs[N & (pipe->ring_size - 1)].
> 
> Ring size can change over the lifetime of a pipe, but not while
> the pipe is locked.  So for any iov_iter primitives it's a constant.
> Original conversion of pipes to this layout went overboard trying
> to microoptimize that - calculating pipe->ring_size - 1, storing
> it in a local variable and using through the function.  In some
> cases it might be warranted, but most of the times it only
> obfuscates what's going on in there.
> 
> Introduce a helper (pipe_buf(pipe, N)) that would encapsulate
> that and use it in the obvious cases.  More will follow...
> 
> Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> ---

Looks good to me,
Reviewed-by: Christian Brauner (Microsoft) <brauner@xxxxxxxxxx>



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux