[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZLIY+ZwrLvpapGE6@casper.infradead.org>
Date: Sat, 15 Jul 2023 04:56:41 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Miaohe Lin <linmiaohe@...wei.com>
Cc: akpm@...ux-foundation.org, hannes@...xchg.org, mhocko@...nel.org,
roman.gushchin@...ux.dev, shakeelb@...gle.com,
muchun.song@...ux.dev, linux-mm@...ck.org, cgroups@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/memcg: use get_page() for device private pages in
mc_handle_swap_pte()
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.
> So use get_page() to get the extra page reference to simplify the code.
> No functional change intended.
>
> Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
> ---
> mm/memcontrol.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 93e3cc581b51..4ca382efb1ca 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -5670,8 +5670,9 @@ static struct page *mc_handle_swap_pte(struct vm_area_struct *vma,
> */
> if (is_device_private_entry(ent)) {
> page = pfn_swap_entry_to_page(ent);
> - if (!get_page_unless_zero(page))
> - return NULL;
> + /* Get a page reference while we know the page can't be freed. */
> + get_page(page);
> +
> return page;
> }
>
> --
> 2.33.0
>
>
Powered by blists - more mailing lists