From: Miaohe Lin <linmiaohe@huawei.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: <akpm@linux-foundation.org>, <hannes@cmpxchg.org>,
<mhocko@kernel.org>, <roman.gushchin@linux.dev>,
<shakeelb@google.com>, <muchun.song@linux.dev>,
<linux-mm@kvack.org>, <cgroups@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/memcg: use get_page() for device private pages in mc_handle_swap_pte()
Date: Sun, 23 Jul 2023 09:16:28 +0800 [thread overview]
Message-ID: <3a86cef4-d1fd-8914-3b0a-2ae95ccff740@huawei.com> (raw)
In-Reply-To: <73b5d7c2-783d-3d75-2c1b-4b91a039df94@huawei.com>
On 2023/7/17 10:28, Miaohe Lin wrote:
> On 2023/7/15 11:56, Matthew Wilcox wrote:
>> On Sat, Jul 15, 2023 at 11:28:02AM +0800, Miaohe Lin wrote:
>>> When page table locked is held, the page can't be freed from under us.
>>
>> But the page isn't mapped into the page table ... there's a swap entry
>> in the page table, so I don't think your logic holds.
>>
>
> IIUC, device_private_entry will hold one page refcnt when it's set to page table.
Take remove_migration_pte() as example, it will hold extra one page refcnt when set device private entry:
remove_migration_pte()
...
folio_get(folio);
...
if (unlikely(is_device_private_page(new))) {
make_[writable|readable]_device_private_entry();
}
...
set_pte_at
> And there's similar code in do_swap_page():
>
> vm_fault_t do_swap_page(struct vm_fault *vmf)
> if (unlikely(non_swap_entry(entry))) {
> if (is_device_private_entry(entry))
> /*
> * Get a page reference while we know the page can't be
> * freed.
> */
> get_page(vmf->page);
> pte_unmap_unlock(vmf->pte, vmf->ptl);
> ret = vmf->page->pgmap->ops->migrate_to_ram(vmf);
> put_page(vmf->page);
> ...
>
> If my logic doesn't hold, do_swap_page() will need to fix the code. Or am I miss something?
Can I have your opinion?
Thanks.
prev parent reply other threads:[~2023-07-23 1:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-15 3:28 Miaohe Lin
2023-07-15 3:56 ` Matthew Wilcox
2023-07-17 2:28 ` Miaohe Lin
2023-07-23 1:16 ` Miaohe Lin [this message]
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=3a86cef4-d1fd-8914-3b0a-2ae95ccff740@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=willy@infradead.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
all inboxes | Powered by JetHome®