linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	John Hubbard <jhubbard@nvidia.com>,
	John Dias <joaodias@google.com>
Subject: Re: [PATCH] mm: fix is_pinnable_page against on cma page
Date: Tue, 3 May 2022 19:27:06 +0200	[thread overview]
Message-ID: <f271ca5e-c573-1c48-35a7-b59e9f2e122e@redhat.com> (raw)
In-Reply-To: <YnFkZmvW2thpIn8o@google.com>

>> 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.

You can have other references on the page that turn it temporarily
unmovable, for example, via FOLL_GET, short-term FOLL_PIN.

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

Yes.

> 
>> 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.

What I am essentially saying is that when rejecting to long-term
FOLL_PIN something that is MIGRATE_ISOLATE now, we might now end up
having to migrate pages that are actually fine to get pinned, because
they are not actual CMA pages. And any such migration might fail when
pages are temporarily unmovable.


> 
>>
>>>
>>> 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.

I think you're right. That's nasty.

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2022-05-03 17:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02 17:35 [PATCH] mm: fix is_pinnable_page against on cma page Minchan Kim
2022-05-02 18:02 ` David Hildenbrand
2022-05-02 18:22   ` Minchan Kim
2022-05-03  1:15     ` David Hildenbrand
2022-05-03 15:26       ` Minchan Kim
2022-05-03 16:02         ` David Hildenbrand
2022-05-03 17:20           ` Minchan Kim
2022-05-03 17:27             ` David Hildenbrand [this message]
2022-05-03 18:08               ` Minchan Kim
2022-05-03 18:12                 ` Minchan Kim
2022-05-04 22:48           ` Minchan Kim
2022-05-05  6:48             ` Minchan Kim
2022-05-05 17:00               ` Mike Kravetz
2022-05-05 17:25                 ` Peter Xu
2022-05-08  0:31                   ` David Hildenbrand
2022-05-05 17:27                 ` Minchan Kim
2022-05-08  0:28               ` David Hildenbrand
2022-05-02 19:15 ` kernel test robot
2022-05-02 21:10 ` kernel test robot
2022-05-03  8:48 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f271ca5e-c573-1c48-35a7-b59e9f2e122e@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=jhubbard@nvidia.com \
    --cc=joaodias@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).