lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 27 Oct 2021 14:32:02 -0700
From:   Yang Shi <shy828301@...il.com>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     Hugh Dickins <hughd@...gle.com>, Hao Sun <sunhao.th@...il.com>,
        "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Song Liu <songliubraving@...com>,
        Andrea Righi <andrea.righi@...onical.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linux MM <linux-mm@...ck.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        stable <stable@...r.kernel.org>
Subject: Re: [PATCH] mm: khugepaged: skip huge page collapse for special files

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ