Re: [RFC PATCH 10/11] shmem: add large folio support to the write path

From: Matthew Wilcox
Date: Sun Oct 29 2023 - 19:37:44 EST


On Sat, Oct 28, 2023 at 09:15:50PM +0000, Daniel Gomez wrote:
> +++ b/mm/shmem.c
> @@ -1621,6 +1621,9 @@ static struct folio *shmem_alloc_folio(gfp_t gfp, struct shmem_inode_info *info,
> pgoff_t ilx;
> struct page *page;
>
> + if ((order != 0) && !(gfp & VM_HUGEPAGE))
> + gfp |= __GFP_COMP;

This is silly. Just set it unconditionally.

> +static inline unsigned int
> +shmem_mapping_size_order(struct address_space *mapping, pgoff_t index,
> + size_t size, struct shmem_sb_info *sbinfo)
> +{
> + unsigned int order = ilog2(size);
> +
> + if ((order <= PAGE_SHIFT) ||
> + (!mapping_large_folio_support(mapping) || !sbinfo->noswap))
> + return 0;
> +
> + order -= PAGE_SHIFT;

You know we have get_order(), right?