[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8693c37b-f709-4c63-eac6-418c32b80e7e@huawei.com>
Date: Wed, 14 Dec 2022 09:10:06 +0800
From: Kefeng Wang <wangkefeng.wang@...wei.com>
To: Matthew Wilcox <willy@...radead.org>
CC: David Hildenbrand <david@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Oscar Salvador <osalvador@...e.de>,
SeongJae Park <sj@...nel.org>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>, <damon@...ts.linux.dev>,
<vishal.moola@...il.com>
Subject: Re: [PATCH -next 1/8] mm: memory_hotplug: add pfn_to_online_folio()
On 2022/12/13 22:47, Matthew Wilcox wrote:
> On Tue, Dec 13, 2022 at 08:13:31PM +0800, Kefeng Wang wrote:
>> On 2022/12/13 19:40, David Hildenbrand wrote:
>>> On 13.12.22 10:27, Kefeng Wang wrote:
>>>> Introduce a wrapper function pfn_to_online_folio(), which calls
>>>> pfn_to_online_page() and returns the folio of the page found,
>>>> or null if no page.
>>>>
>>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
>>>> ---
>>>> include/linux/memory_hotplug.h | 7 +++++++
>>>> 1 file changed, 7 insertions(+)
>>>>
>>>> diff --git a/include/linux/memory_hotplug.h
>>>> b/include/linux/memory_hotplug.h
>>>> index 9fcbf5706595..e841e4fb52a7 100644
>>>> --- a/include/linux/memory_hotplug.h
>>>> +++ b/include/linux/memory_hotplug.h
>>>> @@ -265,6 +265,13 @@ static inline void
>>>> pgdat_kswapd_unlock(pg_data_t *pgdat) {}
>>>> static inline void pgdat_kswapd_lock_init(pg_data_t *pgdat) {}
>>>> #endif /* ! CONFIG_MEMORY_HOTPLUG */
>>>> +static inline struct folio *pfn_to_online_folio(unsigned long pfn)
>>>> +{
>>>> + struct page *page = pfn_to_online_page(pfn);
>>>> +
>>>> + return page ? page_folio(page) : NULL;
>>>> +}
>>> Who guarantees that page_folio() is safe and stable at that point?
>>>
>>> IIRC, that's very tricky. We could have the page concurrently getting
>>> freed and the folio dissolved.
>> So the caller should consider this, lock or get the folio in the caller?
> The caller only has a pfn; it doesn't have the folio at the time of
> the call. David is right, this function cannot safely exist.
Thanks fro all the advises from David/Matthew/SeongJae, will rethink
this converting.
>
Powered by blists - more mailing lists