Re: [PATCH 10/11] alloc_fdtable(): change calling conventions.

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

 



On Mon, Aug 12, 2024 at 07:44:26AM GMT, Al Viro wrote:
> First of all, tell it how many slots do we want, not which slot
> is wanted.  It makes one caller (dup_fd()) more straightforward
> and doesn't harm another (expand_fdtable()).
> 
> Furthermore, make it return ERR_PTR() on failure rather than
> returning NULL.  Simplifies the callers.
> 
> Simplify the size calculation, while we are at it - note that we
> always have slots_wanted greater than BITS_PER_LONG.  What the
> rules boil down to is
> 	* use the smallest power of two large enough to give us
> that many slots
> 	* on 32bit skip 64 and 128 - the minimal capacity we want
> there is 256 slots (i.e. 1Kb fd array).
> 	* on 64bit don't skip anything, the minimal capacity is
> 128 - and we'll never be asked for 64 or less.  128 slots means
> 1Kb fd array, again.
> 	* on 128bit, if that ever happens, don't skip anything -
> we'll never be asked for 128 or less, so the fd array allocation
> will be at least 2Kb.
> 
> Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> ---

I'd copy the rules from the commit message into the function comment
(Maybe not the 128bits part).

Reviewed-by: Christian Brauner <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