linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Kefeng Wang <wangkefeng.wang@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>,
	David Hildenbrand <david@redhat.com>,
	Barry Song <baohua@kernel.org>,
	Ryan Roberts <ryan.roberts@arm.com>,
	Matthew Wilcox <willy@infradead.org>,
	linux-mm@kvack.org
Subject: Re: [PATCH 3/3] mm: shmem: remove __shmem_huge_global_enabled()
Date: Sat, 12 Oct 2024 11:38:20 +0800	[thread overview]
Message-ID: <43154696-1ef2-4a30-b168-6b9f4db20aef@linux.alibaba.com> (raw)
In-Reply-To: <20241010061024.1846220-4-wangkefeng.wang@huawei.com>



On 2024/10/10 14:10, Kefeng Wang wrote:
> Remove __shmem_huge_global_enabled() since only one caller,
> and remove repeated check of VM_NOHUGEPAGE/MMF_DISABLE_THP
> as they are checked in shmem_allowable_huge_orders(), also
> remove unnecessary vma parameter.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

LGTM. Thanks.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>

> ---
>   mm/shmem.c | 33 ++++++++++-----------------------
>   1 file changed, 10 insertions(+), 23 deletions(-)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 34a31e7e527c..36ac51d55867 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -548,17 +548,15 @@ static bool shmem_confirm_swap(struct address_space *mapping,
>   
>   static int shmem_huge __read_mostly = SHMEM_HUGE_NEVER;
>   
> -static bool __shmem_huge_global_enabled(struct inode *inode, pgoff_t index,
> -					loff_t write_end, bool shmem_huge_force,
> -					struct vm_area_struct *vma,
> -					unsigned long vm_flags)
> +static bool shmem_huge_global_enabled(struct inode *inode, pgoff_t index,
> +				      loff_t write_end, bool shmem_huge_force,
> +				      unsigned long vm_flags)
>   {
> -	struct mm_struct *mm = vma ? vma->vm_mm : NULL;
>   	loff_t i_size;
>   
> -	if (!S_ISREG(inode->i_mode))
> +	if (HPAGE_PMD_ORDER > MAX_PAGECACHE_ORDER)
>   		return false;
> -	if (mm && ((vm_flags & VM_NOHUGEPAGE) || test_bit(MMF_DISABLE_THP, &mm->flags)))
> +	if (!S_ISREG(inode->i_mode))
>   		return false;
>   	if (shmem_huge == SHMEM_HUGE_DENY)
>   		return false;
> @@ -576,7 +574,7 @@ static bool __shmem_huge_global_enabled(struct inode *inode, pgoff_t index,
>   			return true;
>   		fallthrough;
>   	case SHMEM_HUGE_ADVISE:
> -		if (mm && (vm_flags & VM_HUGEPAGE))
> +		if (vm_flags & VM_HUGEPAGE)
>   			return true;
>   		fallthrough;
>   	default:
> @@ -584,17 +582,6 @@ static bool __shmem_huge_global_enabled(struct inode *inode, pgoff_t index,
>   	}
>   }
>   
> -static bool shmem_huge_global_enabled(struct inode *inode, pgoff_t index,
> -		   loff_t write_end, bool shmem_huge_force,
> -		   struct vm_area_struct *vma, unsigned long vm_flags)
> -{
> -	if (HPAGE_PMD_ORDER > MAX_PAGECACHE_ORDER)
> -		return false;
> -
> -	return __shmem_huge_global_enabled(inode, index, write_end,
> -					   shmem_huge_force, vma, vm_flags);
> -}
> -
>   #if defined(CONFIG_SYSFS)
>   static int shmem_parse_huge(const char *str)
>   {
> @@ -772,8 +759,8 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
>   }
>   
>   static bool shmem_huge_global_enabled(struct inode *inode, pgoff_t index,
> -		loff_t write_end, bool shmem_huge_force,
> -		struct vm_area_struct *vma, unsigned long vm_flags)
> +				      loff_t write_end, bool shmem_huge_force,
> +				      unsigned long vm_flags)
>   {
>   	return false;
>   }
> @@ -1170,7 +1157,7 @@ static int shmem_getattr(struct mnt_idmap *idmap,
>   	generic_fillattr(idmap, request_mask, inode, stat);
>   	inode_unlock_shared(inode);
>   
> -	if (shmem_huge_global_enabled(inode, 0, 0, false, NULL, 0))
> +	if (shmem_huge_global_enabled(inode, 0, 0, false, 0))
>   		stat->blksize = HPAGE_PMD_SIZE;
>   
>   	if (request_mask & STATX_BTIME) {
> @@ -1687,7 +1674,7 @@ unsigned long shmem_allowable_huge_orders(struct inode *inode,
>   		return 0;
>   
>   	global_huge = shmem_huge_global_enabled(inode, index, write_end,
> -					shmem_huge_force, vma, vm_flags);
> +						shmem_huge_force, vm_flags);
>   	if (!vma || !vma_is_anon_shmem(vma)) {
>   		/*
>   		 * For tmpfs, we now only support PMD sized THP if huge page


      reply	other threads:[~2024-10-12  3:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10  6:10 [PATCH 0/3] mm: cleanup thp and shmem allowable order check Kefeng Wang
2024-10-10  6:10 ` [PATCH 1/3] mm: huge_memory: move file_thp_enabled() into huge_memory.c Kefeng Wang
2024-10-10 12:56   ` David Hildenbrand
2024-10-12  3:27   ` Baolin Wang
2024-10-10  6:10 ` [PATCH 2/3] mm: huge_memory: add thp_vma_disabled() Kefeng Wang
2024-10-10 12:58   ` David Hildenbrand
2024-10-10 14:41   ` David Hildenbrand
2024-10-10 14:53     ` David Hildenbrand
2024-10-11  0:40       ` Kefeng Wang
2024-10-11 10:00         ` David Hildenbrand
2024-10-10  6:10 ` [PATCH 3/3] mm: shmem: remove __shmem_huge_global_enabled() Kefeng Wang
2024-10-12  3:38   ` Baolin Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43154696-1ef2-4a30-b168-6b9f4db20aef@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=david@redhat.com \
    --cc=hughd@google.com \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox