Re: [PATCH v17 7/7] mm: Don't split THP page when syscall is called

From: Minchan Kim
Date: Sun Nov 30 2014 - 19:11:49 EST


On Thu, Nov 27, 2014 at 04:49:21PM +0100, Michal Hocko wrote:
> On Mon 20-10-14 19:12:04, Minchan Kim wrote:
> > We don't need to split THP page when MADV_FREE syscall is
> > called. It could be done when VM decide really frees it so
> > we could avoid unnecessary THP split.
> >
> > Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx>
> > Acked-by: Rik van Riel <riel@xxxxxxxxxx>
> > Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
> > Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>
>
> Other than a minor comment below
> Reviewed-by: Michal Hocko <mhocko@xxxxxxx>

Thanks!

>
> > ---
> > include/linux/huge_mm.h | 4 ++++
> > mm/huge_memory.c | 35 +++++++++++++++++++++++++++++++++++
> > mm/madvise.c | 21 ++++++++++++++++++++-
> > mm/rmap.c | 8 ++++++--
> > mm/vmscan.c | 28 ++++++++++++++++++----------
> > 5 files changed, 83 insertions(+), 13 deletions(-)
> >
> [...]
> > diff --git a/mm/madvise.c b/mm/madvise.c
> > index a21584235bb6..84badee5f46d 100644
> > --- a/mm/madvise.c
> > +++ b/mm/madvise.c
> > @@ -271,8 +271,26 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
> > spinlock_t *ptl;
> > pte_t *pte, ptent;
> > struct page *page;
> > + unsigned long next;
> > +
> > + next = pmd_addr_end(addr, end);
> > + if (pmd_trans_huge(*pmd)) {
> > + if (next - addr != HPAGE_PMD_SIZE) {
> > +#ifdef CONFIG_DEBUG_VM
> > + if (!rwsem_is_locked(&mm->mmap_sem)) {
> > + pr_err("%s: mmap_sem is unlocked! addr=0x%lx end=0x%lx vma->vm_start=0x%lx vma->vm_end=0x%lx\n",
> > + __func__, addr, end,
> > + vma->vm_start,
> > + vma->vm_end);
> > + BUG();
> > + }
> > +#endif
>
> Why is this code here? madvise_free_pte_range is called only from the
> madvise path and we are holding mmap_sem and relying on that for regular
> pages as well.

Make sense.