[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YXm7kHy8uTN1+RRc@casper.infradead.org>
Date: Wed, 27 Oct 2021 21:50:24 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Yang Shi <shy828301@...il.com>
Cc: hughd@...gle.com, sunhao.th@...il.com,
kirill.shutemov@...ux.intel.com, songliubraving@...com,
andrea.righi@...onical.com, akpm@...ux-foundation.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH] mm: khugepaged: skip huge page collapse for special files
On Wed, Oct 27, 2021 at 12:52:21PM -0700, Yang Shi wrote:
> +++ b/mm/khugepaged.c
> @@ -445,22 +445,25 @@ static bool hugepage_vma_check(struct vm_area_struct *vma,
> if (!transhuge_vma_enabled(vma, vm_flags))
> return false;
>
> - /* Enabled via shmem mount options or sysfs settings. */
> - if (shmem_file(vma->vm_file) && shmem_huge_enabled(vma)) {
> + if (vma->vm_file)
> return IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff,
> HPAGE_PMD_NR);
> - }
> +
> + /* Enabled via shmem mount options or sysfs settings. */
> + if (shmem_file(vma->vm_file))
> + return shmem_huge_enabled(vma);
This doesn't make sense to me. if vma->vm_file, we already returned,
so this is dead code.
> /* THP settings require madvise. */
> if (!(vm_flags & VM_HUGEPAGE) && !khugepaged_always())
> return false;
>
> - /* Read-only file mappings need to be aligned for THP to work. */
> + /* Only regular file is valid */
> if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && vma->vm_file &&
> - !inode_is_open_for_write(vma->vm_file->f_inode) &&
> (vm_flags & VM_EXEC)) {
> - return IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff,
> - HPAGE_PMD_NR);
> + struct inode *inode = vma->vm_file->f_inode;
> +
> + return !inode_is_open_for_write(inode) &&
> + S_ISREG(inode->i_mode);
> }
>
> if (!vma->anon_vma || vma->vm_ops)
> --
> 2.26.2
>
Powered by blists - more mailing lists