[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250922131948.GX1391379@nvidia.com>
Date: Mon, 22 Sep 2025 10:19:48 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Mike Rapoport <rppt@...nel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Alexander Graf <graf@...zon.com>, Baoquan He <bhe@...hat.com>,
Changyuan Lyu <changyuanl@...gle.com>, Chris Li <chrisl@...nel.org>,
Pasha Tatashin <pasha.tatashin@...een.com>,
Pratyush Yadav <pratyush@...nel.org>, kexec@...ts.infradead.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 3/4] kho: add support for preserving vmalloc
allocations
On Sun, Sep 21, 2025 at 08:44:57AM +0300, Mike Rapoport wrote:
> +/* KHO internal flags for vmalloc preservations */
> +#define KHO_VMALLOC_ALLOC 0x0001
> +#define KHO_VMALLOC_HUGE_VMAP 0x0002
Maybe something for a followup, but we should really move all these
"ABI" structs and constants into clear ABI header files,
include/linux/kho/abi/XX.h?
Having them sprinkled about makes it harder to notice when people
propose to change them and that makes it harder to enforce ABI rules.
> +static struct kho_vmalloc_chunk *new_vmalloc_chunk(struct kho_vmalloc_chunk *cur)
> +{
> + struct kho_vmalloc_chunk *chunk;
> + int err;
> +
> + chunk = (struct kho_vmalloc_chunk *)get_zeroed_page(GFP_KERNEL);
> + if (!chunk)
> + return NULL;
> +
> + err = kho_preserve_pages(virt_to_page(chunk), 1);
> + if (err)
> + goto err_free;
> + if (cur)
> + KHOSER_STORE_PTR(cur->hdr.next, chunk);
> + return chunk;
> +
> +err_free:
> + free_page((unsigned long)chunk);
> + return NULL;
> +}
> +
> +static void kho_vmalloc_unpreserve_chunk(struct kho_vmalloc_chunk *chunk)
> +{
> + struct kho_mem_track *track = &kho_out.ser.track;
> + unsigned long pfn = PHYS_PFN(virt_to_phys(chunk));
> +
> + __kho_unpreserve(track, pfn, pfn + 1);
> +
> + for (int i = 0; chunk->phys[i]; i++) {
> + pfn = PHYS_PFN(chunk->phys[i]);
> + __kho_unpreserve(track, pfn, pfn + 1);
> + }
> +}
> +
> +static void kho_vmalloc_free_chunks(struct kho_vmalloc *kho_vmalloc)
> +{
> + struct kho_vmalloc_chunk *chunk = KHOSER_LOAD_PTR(kho_vmalloc->first);
> +
> + while (chunk) {
> + struct kho_vmalloc_chunk *tmp = chunk;
> +
> + kho_vmalloc_unpreserve_chunk(chunk);
> +
> + chunk = KHOSER_LOAD_PTR(chunk->hdr.next);
> + kfree(tmp);
Shouldn't this be free_page()?
Otherwise looks OK
Reviewed-by: Jason Gunthorpe <jgg@...dia.com>
Jason
Powered by blists - more mailing lists