Re: [PATCH] dax: use switch statement over chained ifs

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

 



On Mon, Jan 16, 2023 at 06:11:00PM -0800, Amy Parker wrote:
> This patch uses a switch statement for pe_order, which improves
> readability and on some platforms may minorly improve performance. It
> also, to improve readability, recognizes that `PAGE_SHIFT - PAGE_SHIFT' is
> a constant, and uses 0 in its place instead.
> 
> Signed-off-by: Amy Parker <apark0006@xxxxxxxxxxxxxxxxxxxx>

Hi Amy,

Thanks for the patch!  Two problems.  First, your mailer seems to have
mangled the patch; in my tree these are tab indents, and the patch has
arrived with four-space indents, so it can't be applied.

The second problem is that this function should simply not exist.
I forget how we ended up with enum page_entry_size, but elsewhere
we simply pass 'order' around.  So what I'd really like to see is
a patch series that eliminates page_entry_size everywhere.

I can outline a way to do that in individual patches if that would be
helpful.

>  fs/dax.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/dax.c b/fs/dax.c
> index c48a3a93ab29..e8beed601384 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -32,13 +32,16 @@
> 
>  static inline unsigned int pe_order(enum page_entry_size pe_size)
>  {
> -    if (pe_size == PE_SIZE_PTE)
> -        return PAGE_SHIFT - PAGE_SHIFT;
> -    if (pe_size == PE_SIZE_PMD)
> +    switch (pe_size) {
> +    case PE_SIZE_PTE:
> +        return 0;
> +    case PE_SIZE_PMD:
>          return PMD_SHIFT - PAGE_SHIFT;
> -    if (pe_size == PE_SIZE_PUD)
> +    case PE_SIZE_PUD:
>          return PUD_SHIFT - PAGE_SHIFT;
> -    return ~0;
> +    default:
> +        return ~0;
> +    }
>  }
> 
>  /* We choose 4096 entries - same as per-zone page wait tables */
> -- 
> 2.39.0



[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