[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YnFkZmvW2thpIn8o@google.com>
Date: Tue, 3 May 2022 10:20:38 -0700
From: Minchan Kim <minchan@...nel.org>
To: David Hildenbrand <david@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-mm <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>,
John Hubbard <jhubbard@...dia.com>,
John Dias <joaodias@...gle.com>
Subject: Re: [PATCH] mm: fix is_pinnable_page against on cma page
On Tue, May 03, 2022 at 06:02:33PM +0200, David Hildenbrand wrote:
> On 03.05.22 17:26, Minchan Kim wrote:
> > On Tue, May 03, 2022 at 03:15:24AM +0200, David Hildenbrand wrote:
> >>
> >>>>>> However, I assume we have the same issue right now already with
> >>>> ZONE_MOVABLE and MIGRATE_CMA when trying to pin a page residing on these
> >>>
> >>> ZONE_MOVALBE is also changed dynamically?
> >>>
> >>
> >> Sorry, with "same issue" I meant failing to pin if having to migrate and
> >> the page is temporarily unmovable.
> >>
> >>>> there are temporarily unmovable and we fail to migrate. But it would now
> >>>> apply even without ZONE_MOVABLE or MIGRATE_CMA. Hm...
> >>>
> >>> Didn't parse your last mention.
> >>
> >> On a system that neither uses ZONE_MOVABLE nor MIGRATE_CMA we might have
> >> to migrate now when pinning.
> >
> > I don't understand your point. My problem is pin_user_pages with
> > FOLL_LONGTERM. It shouldn't pin a page from ZONE_MOVABLE and cma area
> > without migrating page out of movable zone or CMA area.
> > That's why try_grab_folio checks whether target page stays in those
> > movable areas. However, to check CMA area, is_migrate_cma_page is
> > racy so the FOLL_LONGTERM flag semantic is broken right now.
> >
> > Do you see any problem of the fix?
>
> My point is that you might decide to migrate a page because you stumble
> over MIGRATE_ISOLATE, although there is no need to reject long-term
> pinning and to trigger page migration.
>
> Assume a system without ZONE_MOVABLE and without MIGRATE_CMA. Assume
> someone reserves gigantic pages (alloc_contig_range()) and you have
> concurrent long-term pinning on a page that is no MIGRATE_ISOLATE.
>
> GUP would see MIGRATE_ISOLATE and would reject pinning. The page has to
> be migrated, which can fail if the page is temporarily unmovable.
Why is the page temporarily unmovable? The GUP didn't increase the
refcount in the case. If it's not migrabtable, that's not a fault
from the GUP but someone is already holding the temporal refcount.
It's not the scope this patchset would try to solve it.
>
> See my point? We will try migrating in cases where we don't have to
Still not clear for me what you are concerning.
> migrate. I think what we would want to do is always reject pinning a CMA
> page, independent of the isolation status. but we don't have that
Always reject pinning a CMA page if it is *FOLL_LONGTERM*
> information available.
page && (MIGRATE_CMA | MIGRATE_ISOLATE) && gup_flags is not enough
for it?
>
> I raised in the past that we should look into preserving the migration
> type and turning MIGRATE_ISOLATE essentially into an additional flag.
>
>
> So I guess this patch is the right thing to do for now, but I wanted to
> spell out the implications.
I want but still don't understand what you want to write further
about the implication parts. If you make more clear, I am happy to
include it.
>
> >
> > A thing to get some attention is whether we need READ_ONCE or not
> > for the local variable mt.
> >
>
> Hmm good point. Staring at __get_pfnblock_flags_mask(), I don't think
> there is anything stopping the compiler from re-reading the value. But
> we don't care if we're reading MIGRATE_CMA or MIGRATE_ISOLATE, not
> something in between.
How about this?
CPU A CPU B
is_pinnable_page
..
.. set_pageblock_migratetype(MIGRATE_ISOLATE)
mt == MIGRATE_CMA
get_pageblock_miratetype(page)
returns MIGRATE_ISOLATE
mt == MIGRATE_ISOLATE set_pageblock_migratetype(MIGRATE_CMA)
get_pageblock_miratetype(page)
returns MIGRATE_CMA
So both conditions fails to detect it.
Powered by blists - more mailing lists