xen/grant-table: stop setting PG_private on pages for grant mapping

gnttab_alloc_pages() stores xen_page_foreign in page->private. On 32-bit, a
pointer to an allocated xen_page_foreign is stored; on 64-bit,
xen_page_forCcgn is stored inline. Checking page->private != NULL is enough
to tell whether a xen_page_foreign needs to be freed on 32-bit and
page->private is zeroed unconditionally on 64-bit.

It prepares for a future commit that remove PG_private.

No functional change intended.

Link: https://lore.kernel.org/20260920-remove-pg_private-v5-3-bb68b6a21869@nvidia.com
Signed-off-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Assisted-by: LLM
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
This commit is contained in:
Zi Yan 2026-09-20 22:27:59 -04:00 committed by Andrew Morton
parent a0319334a9
commit 6eecb67b69

View File

@ -863,10 +863,10 @@ EXPORT_SYMBOL_GPL(gnttab_free_auto_xlat_frames);
int gnttab_pages_set_private(int nr_pages, struct page **pages)
{
#if BITS_PER_LONG < 64
int i;
for (i = 0; i < nr_pages; i++) {
#if BITS_PER_LONG < 64
struct xen_page_foreign *foreign;
foreign = kzalloc_obj(*foreign);
@ -874,9 +874,9 @@ int gnttab_pages_set_private(int nr_pages, struct page **pages)
return -ENOMEM;
set_page_private(pages[i], (unsigned long)foreign);
#endif
SetPagePrivate(pages[i]);
}
#endif
/* Data is stored in page->private on 64-bit */
return 0;
}
@ -1031,12 +1031,11 @@ void gnttab_pages_clear_private(int nr_pages, struct page **pages)
int i;
for (i = 0; i < nr_pages; i++) {
if (PagePrivate(pages[i])) {
#if BITS_PER_LONG < 64
if (page_private(pages[i]))
kfree((void *)page_private(pages[i]));
#endif
ClearPagePrivate(pages[i]);
}
set_page_private(pages[i], 0);
}
}
EXPORT_SYMBOL_GPL(gnttab_pages_clear_private);