ACPI: NVS: replace __get_free_page() with kmalloc()

suspend_nvs_alloc() allocates shadow pages for saving and restoring
ACPI Non-Volatile Storage regions across suspend/resume.

These buffers can be allocated with kmalloc() as there's nothing special
about them to go directly to the page allocator.

kmalloc() provides a better API that does not require ugly casts and
kfree() does not need to know the size of the freed object.

Performance difference between kmalloc() and __get_free_pages() is not
measurable as both allocators take an object/page from a per-CPU list for
fast path allocations.

For the slow path the performance is anyway determined by the amount of
reclaim involved rather than by what allocator is used.

Replace use of __get_free_page() with kmalloc() and free_page() with
kfree().

Link: https://lore.kernel.org/all/[email protected]
Signed-off-by: Mike Rapoport (Microsoft) <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Rafael J. Wysocki <[email protected]>
This commit is contained in:
Mike Rapoport (Microsoft) authored and Rafael J. Wysocki committed 2026-07-21 14:23:24 +02:00
1 parent 1590cf0329
commit dbd3f82512
1 file changed
+2 -2
+2 -2
View File
@@ -133,7 +133,7 @@ void suspend_nvs_free(void)
list_for_each_entry(entry, &nvs_list, node)
if (entry->data) {
free_page((unsigned long)entry->data);
kfree(entry->data);
entry->data = NULL;
if (entry->kaddr) {
if (entry->unmap) {
@@ -156,7 +156,7 @@ int suspend_nvs_alloc(void)
struct nvs_page *entry;
list_for_each_entry(entry, &nvs_list, node) {
entry->data = (void *)__get_free_page(GFP_KERNEL);
entry->data = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!entry->data) {
suspend_nvs_free();
return -ENOMEM;