Re: [PATCH] mm: khugepaged: skip huge page collapse for special files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 27, 2021 at 1:50 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
>
> 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.

Yes, Song mentioned the same thing. Fixed by an incremental patch.

>
> >       /* 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
> >



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux