From nobody Tue Apr 7 23:43:00 2026 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B54F33D669A; Wed, 11 Mar 2026 11:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773227051; cv=none; b=ukfosW+rthN8f9UDXTL2CsEV75lxh0bK6qkg7bpW6ikD4YW05Uxw0s4uU8jLj6p4UHCgDhZNJ99b6FfZxw4w5nHoyX8wdToLhbtFgQDR/Sn1wL3AKMjZQy92SZw13eoCYVDPtpkw59Fwzn7syJvC7yVJkzLSFyZCzaM42JVnTrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773227051; c=relaxed/simple; bh=dUS30z5mwiHKFQ3rO9Ro70hyG3QRgNKWXiRNvl5lVB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UvLoTTnysTcHnzPBmMOFsva+AdumGcMsYNReOIxZX2X7J3pJNA6HdgS0ISoVp8wdN2+iKUveox0nt9AUlZX2TEeEtz3+4mns3MVkpoAYrNOqu6HuXQtcnO3Dr8VtYVkkBkRMdwyqnBqpZ7aS/k7S4jkoejWGGVGuaclP7EfexJQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr; spf=pass smtp.mailfrom=ghiti.fr; arc=none smtp.client-ip=217.70.183.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id 9A2D24329A; Wed, 11 Mar 2026 11:03:58 +0000 (UTC) From: Alexandre Ghiti To: akpm@linux-foundation.org Cc: alexghiti@kernel.org, kernel-team@meta.com, akinobu.mita@gmail.com, david@kernel.org, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, hannes@cmpxchg.org, zhengqi.arch@bytedance.com, shakeel.butt@linux.dev, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, gourry@gourry.net, apopple@nvidia.com, byungchul@sk.com, joshua.hahnjy@gmail.com, matthew.brost@intel.com, rakie.kim@sk.com, ying.huang@linux.alibaba.com, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alexandre Ghiti , stable@vger.kernel.org Subject: [PATCH 4/4] mm: Fix demotion gfp by preserving initial gfp reclaim policy Date: Wed, 11 Mar 2026 12:02:43 +0100 Message-ID: <20260311110314.237315-5-alex@ghiti.fr> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260311110314.237315-1-alex@ghiti.fr> References: <20260311110314.237315-1-alex@ghiti.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: alex@ghiti.fr X-GND-Score: 0 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeefjeefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecunecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehlvgigrghnughrvgcuifhhihhtihcuoegrlhgvgiesghhhihhtihdrfhhrqeenucggtffrrghtthgvrhhnpeeludffffethfejfefhfeeukeevffehjedtieelgfekjedtueegfeduhfeifefgudenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppedviedvtdemuddtugemtgdtledvmeegtddtmeemheemfegriegvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdeivddtmedutdgumegttdelvdemgedttdemmeehmeefrgeivgdphhgvlhhopegrlhgvgihghhhithhiqdhfvgguohhrrgdqrffhgefokeeivdfrrdhthhgvfhgrtggvsghoohhkrdgtohhmpdhmrghilhhfrhhomheprghlvgigsehghhhithhirdhfrhdpqhhiugepleetvdffvdegfedvleetpdhmohguvgepshhmthhpohhuthdpnhgspghrtghpthhtohepvdelpdhrtghpthhtoheprghkphhmsehlihhnuhigqdhfohhunhgurghtihhonhdrohhrghdprhgtphhtthhopegrlhgvgihghhhithhisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehkvghrnhgvlhdqthgvrghmsehmvghtrgdrtghom hdprhgtphhtthhopegrkhhinhhosghumhhithgrsehgmhgrihhlrdgtohhmpdhrtghpthhtohepuggrvhhiugeskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhorhgvnhiiohdrshhtohgrkhgvshesohhrrggtlhgvrdgtohhm X-GND-State: clean Content-Type: text/plain; charset="utf-8" When the src folio is a hugetlb page, htlb_modify_alloc_mask() will unconditionally enable reclaim. But we have to preserve initial gfp flags which, in the case of demotion, prevent direct reclaim. Reported-by: Gregory Price Closes: https://lore.kernel.org/linux-mm/aXkfBF5bdnTZ7t7e@gourry-fedora-PF4= VCD3F/ Fixes: 19fc7bed252c ("mm/migrate: introduce a standard migration target all= ocation function") Cc: stable@vger.kernel.org Signed-off-by: Alexandre Ghiti --- mm/migrate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index ee533a4d38db..d44a34d37007 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2169,13 +2169,13 @@ int migrate_pages(struct list_head *from, new_folio= _t get_new_folio, struct folio *alloc_migration_target(struct folio *src, unsigned long priv= ate) { struct migration_target_control *mtc; - gfp_t gfp_mask; + gfp_t gfp_mask, gfp_entry; unsigned int order =3D 0; int nid; enum zone_type zidx; =20 mtc =3D (struct migration_target_control *)private; - gfp_mask =3D mtc->gfp_mask; + gfp_mask =3D gfp_entry =3D mtc->gfp_mask; nid =3D mtc->nid; if (nid =3D=3D NUMA_NO_NODE) nid =3D folio_nid(src); @@ -2184,6 +2184,8 @@ struct folio *alloc_migration_target(struct folio *sr= c, unsigned long private) struct hstate *h =3D folio_hstate(src); =20 gfp_mask =3D htlb_modify_alloc_mask(h, gfp_mask); + gfp_mask =3D (gfp_mask & ~__GFP_RECLAIM) | (gfp_entry & __GFP_RECLAIM); + return alloc_hugetlb_folio_nodemask(h, nid, mtc->nmask, gfp_mask, htlb_allow_alloc_fallback(mtc->reason)); --=20 2.53.0