[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9be14739-82cc-42fb-bb38-a868231cdda6@redhat.com>
Date: Tue, 14 Jan 2025 15:51:09 +0100
From: David Hildenbrand <david@...hat.com>
To: Alistair Popple <apopple@...dia.com>, akpm@...ux-foundation.org,
dan.j.williams@...el.com, linux-mm@...ck.org
Cc: alison.schofield@...el.com, lina@...hilina.net, zhang.lyra@...il.com,
gerald.schaefer@...ux.ibm.com, vishal.l.verma@...el.com,
dave.jiang@...el.com, logang@...tatee.com, bhelgaas@...gle.com,
jack@...e.cz, jgg@...pe.ca, catalin.marinas@....com, will@...nel.org,
mpe@...erman.id.au, npiggin@...il.com, dave.hansen@...ux.intel.com,
ira.weiny@...el.com, willy@...radead.org, djwong@...nel.org, tytso@....edu,
linmiaohe@...wei.com, peterx@...hat.com, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linuxppc-dev@...ts.ozlabs.org, nvdimm@...ts.linux.dev,
linux-cxl@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-ext4@...r.kernel.org, linux-xfs@...r.kernel.org, jhubbard@...dia.com,
hch@....de, david@...morbit.com, chenhuacai@...nel.org, kernel@...0n.name,
loongarch@...ts.linux.dev
Subject: Re: [PATCH v6 10/26] mm/mm_init: Move p2pdma page refcount
initialisation to p2pdma
On 10.01.25 07:00, Alistair Popple wrote:
> Currently ZONE_DEVICE page reference counts are initialised by core
> memory management code in __init_zone_device_page() as part of the
> memremap() call which driver modules make to obtain ZONE_DEVICE
> pages. This initialises page refcounts to 1 before returning them to
> the driver.
>
> This was presumably done because it drivers had a reference of sorts
> on the page. It also ensured the page could always be mapped with
> vm_insert_page() for example and would never get freed (ie. have a
> zero refcount), freeing drivers of manipulating page reference counts.
>
> However it complicates figuring out whether or not a page is free from
> the mm perspective because it is no longer possible to just look at
> the refcount. Instead the page type must be known and if GUP is used a
> secondary pgmap reference is also sometimes needed.
>
> To simplify this it is desirable to remove the page reference count
> for the driver, so core mm can just use the refcount without having to
> account for page type or do other types of tracking. This is possible
> because drivers can always assume the page is valid as core kernel
> will never offline or remove the struct page.
>
> This means it is now up to drivers to initialise the page refcount as
> required. P2PDMA uses vm_insert_page() to map the page, and that
> requires a non-zero reference count when initialising the page so set
> that when the page is first mapped.
>
> Signed-off-by: Alistair Popple <apopple@...dia.com>
> Reviewed-by: Dan Williams <dan.j.williams@...el.com>
>
LGTM
Acked-by: David Hildenbrand <david@...hat.com>
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists