[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+CK2bDtmeyMgd7gkdbb+0hfm5rSow-Lc+FOrZM3tUZAOR+FRw@mail.gmail.com>
Date: Fri, 4 Dec 2020 12:43:29 -0500
From: Pavel Tatashin <pasha.tatashin@...een.com>
To: Joonsoo Kim <js1304@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>, linux-mm <linux-mm@...ck.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Vlastimil Babka <vbabka@...e.cz>,
Michal Hocko <mhocko@...e.com>,
David Hildenbrand <david@...hat.com>,
Oscar Salvador <osalvador@...e.de>,
Dan Williams <dan.j.williams@...el.com>,
Sasha Levin <sashal@...nel.org>,
Tyler Hicks <tyhicks@...ux.microsoft.com>,
mike.kravetz@...cle.com, Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>, Jason Gunthorpe <jgg@...pe.ca>,
Peter Zijlstra <peterz@...radead.org>,
Mel Gorman <mgorman@...e.de>,
Matthew Wilcox <willy@...radead.org>,
David Rientjes <rientjes@...gle.com>,
John Hubbard <jhubbard@...dia.com>
Subject: Re: [PATCH 6/6] mm/gup: migrate pinned pages out of movable zone
On Thu, Dec 3, 2020 at 11:14 PM Joonsoo Kim <js1304@...il.com> wrote:
>
> On Wed, Dec 02, 2020 at 12:23:30AM -0500, Pavel Tatashin wrote:
> > We do not allocate pin pages in ZONE_MOVABLE, but if pages were already
> > allocated before pinning they need to migrated to a different zone.
> > Currently, we migrate movable CMA pages only. Generalize the function
> > that migrates CMA pages to migrate all movable pages.
> >
> > Signed-off-by: Pavel Tatashin <pasha.tatashin@...een.com>
> > ---
> > include/linux/migrate.h | 1 +
> > include/trace/events/migrate.h | 3 +-
> > mm/gup.c | 56 +++++++++++++---------------------
> > 3 files changed, 24 insertions(+), 36 deletions(-)
> >
> > diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> > index 0f8d1583fa8e..00bab23d1ee5 100644
> > --- a/include/linux/migrate.h
> > +++ b/include/linux/migrate.h
> > @@ -27,6 +27,7 @@ enum migrate_reason {
> > MR_MEMPOLICY_MBIND,
> > MR_NUMA_MISPLACED,
> > MR_CONTIG_RANGE,
> > + MR_LONGTERM_PIN,
> > MR_TYPES
> > };
> >
> > diff --git a/include/trace/events/migrate.h b/include/trace/events/migrate.h
> > index 4d434398d64d..363b54ce104c 100644
> > --- a/include/trace/events/migrate.h
> > +++ b/include/trace/events/migrate.h
> > @@ -20,7 +20,8 @@
> > EM( MR_SYSCALL, "syscall_or_cpuset") \
> > EM( MR_MEMPOLICY_MBIND, "mempolicy_mbind") \
> > EM( MR_NUMA_MISPLACED, "numa_misplaced") \
> > - EMe(MR_CONTIG_RANGE, "contig_range")
> > + EM( MR_CONTIG_RANGE, "contig_range") \
> > + EMe(MR_LONGTERM_PIN, "longterm_pin")
> >
> > /*
> > * First define the enums in the above macros to be exported to userspace
> > diff --git a/mm/gup.c b/mm/gup.c
> > index 724d8a65e1df..1d511f65f8a7 100644
> > --- a/mm/gup.c
> > +++ b/mm/gup.c
> > @@ -1593,19 +1593,18 @@ static bool check_dax_vmas(struct vm_area_struct **vmas, long nr_pages)
> > }
> > #endif
> >
> > -#ifdef CONFIG_CMA
> > -static long check_and_migrate_cma_pages(struct mm_struct *mm,
> > - unsigned long start,
> > - unsigned long nr_pages,
> > - struct page **pages,
> > - struct vm_area_struct **vmas,
> > - unsigned int gup_flags)
> > +static long check_and_migrate_movable_pages(struct mm_struct *mm,
> > + unsigned long start,
> > + unsigned long nr_pages,
> > + struct page **pages,
> > + struct vm_area_struct **vmas,
> > + unsigned int gup_flags)
> > {
> > unsigned long i;
> > unsigned long step;
> > bool drain_allow = true;
> > bool migrate_allow = true;
> > - LIST_HEAD(cma_page_list);
> > + LIST_HEAD(page_list);
> > long ret = nr_pages;
> > struct migration_target_control mtc = {
> > .nid = NUMA_NO_NODE,
> > @@ -1623,13 +1622,12 @@ static long check_and_migrate_cma_pages(struct mm_struct *mm,
> > */
> > step = compound_nr(head) - (pages[i] - head);
> > /*
> > - * If we get a page from the CMA zone, since we are going to
> > - * be pinning these entries, we might as well move them out
> > - * of the CMA zone if possible.
> > + * If we get a movable page, since we are going to be pinning
> > + * these entries, try to move them out if possible.
> > */
> > - if (is_migrate_cma_page(head)) {
> > + if (is_migrate_movable(get_pageblock_migratetype(head))) {
>
> is_migrate_movable() isn't a check for the ZONE. It's a check for the
> MIGRATE_TYPE. MIGRATE_TYPE doesn't require hard guarantee for
> migration, and, most of memory, including ZONE_NORMAL, is
> MIGRATE_MOVABLE. With this code, long term gup would always fails due
> to not enough memory. I think that correct change would be
> "is_migrate_cma_page(hear) && zone == ZONE_MOVABLE".
Good point. The above should be OR not AND.
zone_idx(page_zone(head)) == ZONE_MOVABLE || is_migrate_cma_page(hear)
Pasha
Powered by blists - more mailing lists