Commit 2985dae1 authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by Linus Torvalds
Browse files

mm/page_alloc: Fix try_alloc_pages



Fix an obvious bug. try_alloc_pages() should set_page_refcounted.

[ Not so obvious: it was probably correct at the time it was written but
  was at some point then rebased on top of v6.14-rc1.

  And at that point there was a semantic conflict with commit
  efabfe14 ("mm/page_alloc: move set_page_refcounted() to callers
  of get_page_from_freelist()") and became buggy.
							- Linus ]

Fixes: 97769a53 ("mm, bpf: Introduce try_alloc_pages() for opportunistic page allocation")
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Reviewed-by: default avatarShakeel Butt <shakeel.butt@linux.dev>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Acked-by: default avatarVlastimil BAbka <vbabka@suse.cz>
Reviewed-by: default avatarHarry Yoo <harry.yoo@oracle.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5de0afb4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -7385,6 +7385,9 @@ struct page *try_alloc_pages_noprof(int nid, unsigned int order)

	/* Unlike regular alloc_pages() there is no __alloc_pages_slowpath(). */

	if (page)
		set_page_refcounted(page);

	if (memcg_kmem_online() && page &&
	    unlikely(__memcg_kmem_charge_page(page, alloc_gfp, order) != 0)) {
		free_pages_nolock(page, order);