From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379273; b=Evn6QKyurQlSNrwxOz17c7Oi/DYsLiPBfffaNsHPvnVxYEdHG8awH4GP782Qxrc3VI0C 0AsPimYrk4cJ5dxMbNtFkCkSs7J3ZHKDg7da5lm34w0UiwXz3DlsPD4qSOLgbIXAZQJi3 Bu4Jcv+i7eW374XY3CpwQWyXDH+kX9+GPVFamKZwYH2VRw7OY4QnRyZ6V0J5S6GsirXr1 dQtk8yElSMRcac0DGUwfR36hBmoqP/bXZS9aPoo+r4lrYZAinIvEOV2vPUSFfFNGLTwfo Jmk5XJW7RkP2uECAzlb+O3f0JaQGxHD7EfuEcYj8Kno3hGu5ByrS2AapQsaZmeaKzZA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379273; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=j3tfLY3eLLi0l1ZBXENigM6rWEeTnJVmy8WSMI4Z+c8=; b=VJAHkeKUbsEXX7K4L/O1XvK7V929rZm0u27zI9/V3T8ry2H864QJjMO1CBQGcSAdnqcr up/ajSSGqoyAEbQcrK26xQjoVwqMsQ295D1tY/Ys4tAbBo+smljOx/ztu8wQJtm+gVC5l wyV56Sc7bqcSb/ChqcPjTe2zknuXShP7knbpwVgqZzK/0doRndwDCS+RxcKkOmAJC0LlG bBAd54kiI0WY09MK6lqpQtmIlxzp1W79MgkAa8SclarK9BegrSoV/pLZI5BPnSVI+zhQK rwz+J2XW6bX+9k0eSLXO4Yr7Z+UrBy4+LUeOKcsOFSbc1LBtvI/aOgRK6x2HFs4h32Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=NxL44cuo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BE85606A330; Fri, 4 Dec 2026 10:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=NxL44cuo Received: by smtp.kernel.org (Postfix) with ESMTPSA id B172F1F000C2; Fri, 4 Dec 2026 10:14:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379273; bh=j3tfLY3eLLi0l1ZBXENigM6rWEeTnJVmy8WSMI4Z+c8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NxL44cuooRl94lpUOBojusvZqaaqJEkX6S2nDXlAcb4tBJx9XrAQPJ2cZOZUb/ktG KzVsHMuGrLOKcyvlWMgKQGmTnRceHpJs2NsLAnTDDmEjjGX9NF11bxEYSppX4M+jG1 6CxcJrIfWhNdWRfMg+dOHgbYjJhaJydtuKSiikKo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qiqi Liu , Andrew Morton , "Vlastimil Babka (SUSE)" , Brendan Jackman , Johannes Weiner , Michal Hocko , Suren Baghdasaryan , Zi Yan , Sasha Levin Subject: [PATCH 7.3 003/742] mm/page_alloc: apply per-task GFP context in bulk allocator Date: Fri, 4 Dec 2026 18:57:47 +0900 Message-ID: <20261204100635.130226064@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qiqi Liu [ Upstream commit 1372648980b8524a5747a2732e90b20d3db10c3c ] alloc_pages_bulk_noprof() does not call current_gfp_context(), so per-task scoped allocation constraints (PF_MEMALLOC_NOIO, PF_MEMALLOC_NOFS, PF_MEMALLOC_PIN) are not applied on the bulk fast path. By ignoring PF_MEMALLOC_NOIO and PF_MEMALLOC_NOFS, the allocation can theoretically result in a deadlock. Ignoring PF_MEMALLOC_PIN also has consequences: without clearing __GFP_MOVABLE, prepare_alloc_pages() selects MIGRATE_MOVABLE for the PCP list, and a task with PF_MEMALLOC_PIN set receives movable pages from the bulk allocator. Once pinned, these pages can no longer be migrated but remain in MOVABLE pageblocks, violating the mobility contract. This can increase fragmentation and interfere with compaction or contiguous-memory allocations, eventually surfacing as higher allocation latency or allocation failures under memory pressure. Found via review of the bulk allocation tracepoint hooks [1]. Link: https://sashiko.dev/#/patchset/20260907120949.418450-1-liuqiqi%40kylinos.cn Link: https://lore.kernel.org/all/20260907120949.418450-1-liuqiqi@kylinos.cn/ [1] Link: https://lore.kernel.org/20260915074928.327471-1-liuqiqi@kylinos.cn Fixes: 387ba26fb1cb ("mm/page_alloc: add a bulk page allocator") Signed-off-by: Qiqi Liu Signed-off-by: Andrew Morton Reviewed-by: Vlastimil Babka (SUSE) Cc: Brendan Jackman Cc: Johannes Weiner Cc: Michal Hocko Cc: Suren Baghdasaryan Cc: Zi Yan Stable-dep-of: bcfc8286f0cd ("mm/page_alloc: retry allocations that raced with a zonelist rebuild") Signed-off-by: Sasha Levin --- mm/page_alloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 55232081a32b2..86f4901c4c2f2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5262,6 +5262,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid, /* May set ALLOC_NOFRAGMENT, fragmentation will return 1 page. */ gfp &= gfp_allowed_mask; + gfp = current_gfp_context(gfp); if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &gfp, &alloc_flags)) goto out; -- 2.53.0