Skip to content

Commit 162f6c6

Browse files
VMoolaakpm00
authored andcommitted
mm/page_alloc: add kernel-docs for free_pages()
Patch series "Cleanup free_pages() misuse", v3. free_pages() is supposed to be called when we only have a virtual address. __free_pages() is supposed to be called when we have a page. There are a number of callers that use page_address() to get a page's virtual address then call free_pages() on it when they should just call __free_pages() directly. Add kernel-docs for free_pages() to help callers better understand which function they should be calling, and replace the obvious cases of misuse. This patch (of 7): Add kernel-docs to free_pages(). This will help callers understand when to use it instead of __free_pages(). Link: https://lkml.kernel.org/r/20250903185921.1785167-1-vishal.moola@gmail.com Link: https://lkml.kernel.org/r/20250903185921.1785167-2-vishal.moola@gmail.com Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Acked-by: SeongJae Park <sj@kernel.org> Acked-by: David Hildenbrand <david@redhat.com> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Andy Lutomirski <luto@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Justin Sanders <justin@coraid.com> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com> Cc: Will Deacon <will@kernel.org> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 94326d3 commit 162f6c6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mm/page_alloc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5275,6 +5275,15 @@ void free_pages_nolock(struct page *page, unsigned int order)
52755275
___free_pages(page, order, FPI_TRYLOCK);
52765276
}
52775277

5278+
/**
5279+
* free_pages - Free pages allocated with __get_free_pages().
5280+
* @addr: The virtual address tied to a page returned from __get_free_pages().
5281+
* @order: The order of the allocation.
5282+
*
5283+
* This function behaves the same as __free_pages(). Use this function
5284+
* to free pages when you only have a valid virtual address. If you have
5285+
* the page, call __free_pages() instead.
5286+
*/
52785287
void free_pages(unsigned long addr, unsigned int order)
52795288
{
52805289
if (addr != 0) {

0 commit comments

Comments
 (0)