From nobody Thu Apr 16 06:46:45 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D1BE430BA6 for ; Mon, 2 Mar 2026 07:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772435035; cv=none; b=duHZZ6tmq+dTuS5i/8/4H5u0T+Zv6kJUQz8kyNVGTfqLsYqKUNK/NtVZwOXpGDv1FebXqonC8l1feEAxt6rMn/0GX1z0sBULglP7aKplIsYP+fShCoIa7nIu4eqs+cIujQ0Q//A2zP7IpjKjLa41QRkazUjYWXPsma+/tH/ldJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772435035; c=relaxed/simple; bh=K/S9aHPvAmHAhFrctXT9uZ3XaMDztKnDKbJRufpmpRw=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=RE0FlLL/j3OIM9RN6FeI5K2t6g4nA0h4act6+F/WbAE3MJI+WT/KH6xsKae0K56oXlBdNPV+PlhOtqAXOfgUocg3GNyN8l2cygKjPEL0UrZtqcIfqR21hl/ysGGD4fp6A5XXZKFcohowHExVBTw79Itu2bXi/LQXB3dzriv+Wqo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--bingjiao.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jc++c8kU; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--bingjiao.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jc++c8kU" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-1279caef718so1328406c88.1 for ; Sun, 01 Mar 2026 23:03:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772435033; x=1773039833; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=b68BgO2svrQ9zkYU7SLhBTPAbCEH/OdSzC0ZL6Lj1bw=; b=jc++c8kURcBqXbHnSg0YpmaLZVw/rMjZuK8vshtfP+TaL9G4XlBoHDrMbI1NrfNf/E WzCcuq39vQpZoh5Apm+XXT33eHPYwZjBg1RvTJeYjUc8mE/gHiNQV3rGSiLsvpLJx1kg UhHO6P7H2weoj2qoqlE9zTJbqS/UKgRXRtEulHsPTZ3X0Kg2K9xdGWv4BUa0ojz4yl6K MM9ht5bTYQdb96oQgeaWk2DLLQn8G1AIsw9ekDTaXT/VtE8iIylRmEUw4+msPBAzcL+s 8IivGye+3tBhBYOqRPISjkCSTYLGeIuQVKsW8PrKs7RGqUlIl1Y0qLwmV+OeaXWW9rzq OfoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772435033; x=1773039833; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=b68BgO2svrQ9zkYU7SLhBTPAbCEH/OdSzC0ZL6Lj1bw=; b=SaNMeZNWW/YvgnVHMxrZM5L36qYhU3+LAQx8bkFkoC9GbRmrrRSXPugfRbfVmDkJQE uJeubZi3Pn3lVxjjrD7IFpDrmz7pVUAxOb+98PD9xbOGIw5E/i9fc3dp2nNVGZQR4qlz xAijxTco7mG5dW590MDv6I+51guyJ9DCS4qwtyr9R6cTfXZhyyZAkhqcIoTv6QUVwQNP RDYJER4JjlO48EsSIysmHcSZ/8lyh54BNngUgZ9850nYzYXN0/lw+EjMS1uLvBEEL6CF 8nPzXK1LvzOWJyFZz5SgSF+AI8TD2M7fuqb6loXpPsX9p7+ACpO6drB3jL8+YGMMqhkg ffZw== X-Forwarded-Encrypted: i=1; AJvYcCWJ8lk//z3FbiDghG++WzyV38kN5lkMO0EO+SXQblWPH35AQBytwLPs9/xPbCZwgJMfHD1FX6VInyjB0tY=@vger.kernel.org X-Gm-Message-State: AOJu0YyZBG0CDgGJi0WgbBiecRqPaSaTiE/IGk5h09K7FJir9+M064BN IMWM9CDKdNwoXZFyqW4DM9xkNjm9lTbndlQiB0RVVmBVBnyUDIDnYnLB5QEB8QqKU5jrThk5LQw 0jrdyJ3EDHq7k4w== X-Received: from dlk29.prod.google.com ([2002:a05:7022:11d:b0:127:78f8:34b0]) (user=bingjiao job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:4384:b0:124:9acd:3a38 with SMTP id a92af1059eb24-1278fc4dedcmr3132169c88.35.1772435032931; Sun, 01 Mar 2026 23:03:52 -0800 (PST) Date: Mon, 2 Mar 2026 07:03:26 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260302070351.3465439-1-bingjiao@google.com> Subject: [PATCH] mm/vmscan: restore allowed mask in alloc_demote_folio() From: Bing Jiao To: linux-mm@kvack.org Cc: Bing Jiao , Andrew Morton , Johannes Weiner , David Hildenbrand , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Axel Rasmussen , Yuanchu Xie , Wei Xu , linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In alloc_demote_folio(), mtc->nmask is set to NULL for the first allocation. If that succeeds, it returns without restoring mtc->nmask to allowed_mask. For subsequent allocations from the migrate_pages() batch, mtc->nmask will be NULL. If the target node then becomes full, the fallback allocation will use nmask =3D NULL, allocating from any node allowed by the task cpuset, which for kswapd is all nodes. To address this issue, restore the mtc->nmask to its original allowed nodemask after the first allocation. Signed-off-by: Bing Jiao --- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index cbffc0a27824..b42abd17aee7 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -985,11 +985,11 @@ static struct folio *alloc_demote_folio(struct folio = *src, mtc->nmask =3D NULL; mtc->gfp_mask |=3D __GFP_THISNODE; dst =3D alloc_migration_target(src, (unsigned long)mtc); + mtc->nmask =3D allowed_mask; if (dst) return dst; mtc->gfp_mask &=3D ~__GFP_THISNODE; - mtc->nmask =3D allowed_mask; return alloc_migration_target(src, (unsigned long)mtc); } -- 2.53.0.473.g4a7958ca14-goog