Re: [PATCH] mm: khugepaged: fix call hpage_collapse_scan_file() for anonymous vma

From: Matthew Wilcox
Date: Thu Jan 09 2025 - 08:44:30 EST


On Thu, Jan 09, 2025 at 03:00:59PM +0800, Liu Shixin wrote:
> Add vma_is_anonymous() check to make such vma be processed by
> hpage_collapse_scan_pmd().

Wouldn't it be better to replace the vm_file check with
vma_is_anonymous()? ie:

> - if (IS_ENABLED(CONFIG_SHMEM) && vma->vm_file) {
> + if (IS_ENABLED(CONFIG_SHMEM) && vma->vm_file &&
> + !vma_is_anonymous(vma)) {

+ if (IS_ENABLED(CONFIG_SHMEM) &&
+ !vma_is_anonymous(vma)) {