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

From: Liu Shixin
Date: Thu Jan 09 2025 - 21:30:10 EST




On 2025/1/9 21:40, Matthew Wilcox wrote:
> 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)) {
>
>
> .
>
Thanks, replace is better.

Yang Shi suggest me to set vm_file to NULL when mmap /dev/zero as private.
It seems only /dev/zero is special which has vm_file but no vm_ops.
This way may solve more hidden similar problems, so I prefer it now.