Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

alloc_tag: use release_pages() in the cleanup path

Patch series "Minor fixes for memory allocation profiling", v2.

Over the last couple months I gathered a few reports of minor issues in
memory allocation profiling which are addressed in this patchset.


This patch (of 2):

When bulk-freeing an array of pages use release_pages() instead of freeing
them page-by-page.

Link: https://lkml.kernel.org/r/20250915212756.3998938-1-surenb@google.com
Link: https://lkml.kernel.org/r/20250915212756.3998938-2-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Usama Arif <usamaarif642@gmail.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Usama Arif <usamaarif642@gmail.com>
Cc: David Wang <00107082@163.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Sourav Panda <souravpanda@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Suren Baghdasaryan and committed by
Andrew Morton
123bcf28 5919f128

+5 -5
+5 -5
lib/alloc_tag.c
··· 438 438 if (nr < more_pages || 439 439 vmap_pages_range(phys_end, phys_end + (nr << PAGE_SHIFT), PAGE_KERNEL, 440 440 next_page, PAGE_SHIFT) < 0) { 441 + release_pages_arg arg = { .pages = next_page }; 442 + 441 443 /* Clean up and error out */ 442 - for (int i = 0; i < nr; i++) 443 - __free_page(next_page[i]); 444 + release_pages(arg, nr); 444 445 return -ENOMEM; 445 446 } 446 447 ··· 683 682 684 683 static void __init free_mod_tags_mem(void) 685 684 { 686 - int i; 685 + release_pages_arg arg = { .pages = vm_module_tags->pages }; 687 686 688 687 module_tags.start_addr = 0; 689 - for (i = 0; i < vm_module_tags->nr_pages; i++) 690 - __free_page(vm_module_tags->pages[i]); 688 + release_pages(arg, vm_module_tags->nr_pages); 691 689 kfree(vm_module_tags->pages); 692 690 free_vm_area(vm_module_tags); 693 691 }