From nobody Mon Feb 9 15:06:43 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 DA66C4611EA for ; Thu, 8 Jan 2026 10:16:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767867403; cv=none; b=gHrdqJXst9goEOisphEVCE7miMdrC/TitUbjkiJtm6ajfM/NWoAEvnxcCVVFjNrRT/MrGU0ceXTNid8aWQnXnVmwCY3W2DMyYAqS+47wpLv2p+j2iUiq6S/aUnPwWjOJT8ASNWChyjM/rIJSkJsw/RfpJVjTBaCYndGGXGF2B0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767867403; c=relaxed/simple; bh=YYf+X5c8xRQHOIoiVkNKohN/SGgRXpW0mOrRpxFNnJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EmNYPH+XFooQMyulmabfjjLwDUKHQkSefMCJ4klfiX62EXWSUGTs0FMmcexXhCOLBf+VsTpRGI77vzmTvHxKfBuX+p/3qABHdyliCpZtYzP0bYvR4KUa2KaE88glQABCogVS2BTCr0rVT39Ojkda82cacu6uxK4vD5uqjepKFDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=imB/Yzn4; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="imB/Yzn4" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2a0c09bb78cso14848385ad.0 for ; Thu, 08 Jan 2026 02:16:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767867395; x=1768472195; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=suTkrZ1EkPHRVVH34Oml2yxp+xWgDllJvbX0nsQJyK8=; b=imB/Yzn4EKaWXIG92ZpWJAM9kF5qZdKuXBpAwy6BK3qh2Rous2EtDXKRrTC/IzoHKY vOqp6o03EjQxR6Ok5uAKmczFoUS1q3um+IDJqGGc8IqFxmt0bSVVVW1yv3CfKcjjgyOo n24SEEdW809TaZXgtHJXBtkCrk4EDIQ1MjcoQBLh/Cdq/fGS1STsLAKdB5zZw/YpwzcE Wm145S9pghGumtDNirh1GjNbblFxm8pYIrrxK61KFvieBNmdYOjrYqC7BPPoaCfrNWEP BfMCxzqb2eXjnD0J6+jSb5tywRC+C5cNF1YDbSZtoBb3wfg7knvJ6u9GWGYAaaXZiZAY VDJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767867395; x=1768472195; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=suTkrZ1EkPHRVVH34Oml2yxp+xWgDllJvbX0nsQJyK8=; b=GTh96JR3Mha9LZpc2KgyoOu6Bdy4LjOo0GevoEVVXMKqUaiscppq+Q2qAVGSDnftcA f+/IhWkkWkzCasi0hYVfo1vMHE0tNgJYRT8sk/tg3pCDZ3ngX64oSghdK4A6/Yr7V0bJ nbQidc+4LdL1lW9823yEouUd7ODOhLmsU0+kTOQmj9EVXPQw+cdytlgapFCYsSAR9TrF yoVAOMWMZUPxffzMrexK87UeOsTR5WYHV++drcTe97zp8wS6tCthIDGvSsOuNZIrHTi2 uIIjqX3SKy898O5Z8mJ8z6Rw6TKXx/drPP14NpxhXCpDaZHyqKnJDvqJJDZH2xXtXOEZ dQ/A== X-Forwarded-Encrypted: i=1; AJvYcCU4Tm+nV8/FuPMGQnPrWn1rjujN7YJC3QzNRMPWAWETz9w4WL4b++qOCrJzd0xq1iesZ5Jm4wpV1j4X6uQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9yWvVKgXdKJJzBfaj15RSvGdQQ6GCDGELSG+HNf/CHLv4uf0z 7Cxv2YqpMQBBgXrdJ/MMBQZ3O7EiXK+TOpd8l2ZmVhmSrCFMimsDtBPH X-Gm-Gg: AY/fxX7eM3o7G1VmAH8w53vjMIU9PQu2JC7+w6kU3nAkq4Mi+EYKBdUu6pvWE8VI4Js awDguCj0D6FkgGkh4Q2V3q9ZMnKqmi7zqTvFgRRBM0aWTYbyNGhc4dmdxmdsI3yEivC+aFY3aj+ krSxFc1IlWt4PU2oz67oHfQ9QvehRx8s0v9wD198sxQq9cXNlQ2VK+Eqy8C5/3PFiFQwTt6XuIt ntjftvfCNzdHYmnpKPqlRwBgv9yvMYG1jYASZbaDIDWfLd+yScE75wCZU68EGG5/cdbYGOa/i5Z oLqcKWvvrykI4b12zlc9QGv1IKkz2xm8e29NY3cFvkG15AMTlQlTnMKFJayDb6trjJ0FFhoTISq n+dXlpDyjbtbkVdyD3cyQHj7L9CAWYd4KNPWabMmmYUbsXtpstwn3A/T7mWWnjsEI4y3pX4YA6K WW3BAAXTtG0oQ9GyQMnJdMMFYe X-Google-Smtp-Source: AGHT+IEjPBmAvzyeXCoA9/7yT7vSwivlYjHbfpR026nkIclI0cizfQblaziO9HyuHaaz+q4kQ2IDPw== X-Received: by 2002:a17:903:11d0:b0:29f:1b1f:784 with SMTP id d9443c01a7336-2a3e39828f1mr90701885ad.4.1767867395489; Thu, 08 Jan 2026 02:16:35 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:8352:dfa:3b18:eb4e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a3e3c49299sm73785245ad.42.2026.01.08.02.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 02:16:35 -0800 (PST) From: Akinobu Mita To: akinobu.mita@gmail.com Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, hannes@cmpxchg.org, david@kernel.org, mhocko@kernel.org, zhengqi.arch@bytedance.com, shakeel.butt@linux.dev, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, bingjiao@google.com Subject: [PATCH v3 3/3] mm/vmscan: don't demote if there is not enough free memory in the lower memory tier Date: Thu, 8 Jan 2026 19:15:35 +0900 Message-ID: <20260108101535.50696-4-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260108101535.50696-1-akinobu.mita@gmail.com> References: <20260108101535.50696-1-akinobu.mita@gmail.com> 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 Content-Type: text/plain; charset="utf-8" On systems with multiple memory-tiers consisting of DRAM and CXL memory, the OOM killer is not invoked properly. Here's the command to reproduce: $ sudo swapoff -a $ stress-ng --oomable -v --memrate 20 --memrate-bytes 10G \ --memrate-rd-mbs 1 --memrate-wr-mbs 1 The memory usage is the number of workers specified with the --memrate option multiplied by the buffer size specified with the --memrate-bytes option, so please adjust it so that it exceeds the total size of the installed DRAM and CXL memory. If swap is disabled, you can usually expect the OOM killer to terminate the stress-ng process when memory usage approaches the installed memory size. However, if multiple memory-tiers exist (multiple /sys/devices/virtual/memory_tiering/memory_tier directories exist) and /sys/kernel/mm/numa/demotion_enabled is true, the OOM killer will not be invoked and the system will become inoperable, regardless of whether MGLRU is enabled or not. This issue can be reproduced using NUMA emulation even on systems with only DRAM. You can create two-fake memory-tiers by booting a single-node system with "numa=3Dfake=3D2 numa_emulation.adistance=3D576,704" kernel parameters. The reason for this issue is that memory allocations do not directly trigger the oom-killer, assuming that if the target node has an underlying memory tier, it can always be reclaimed by demotion. So this change avoids this issue by not attempting to demote if the underlying node has less free memory than the minimum watermark, and the oom-killer will be triggered directly from memory allocations. Signed-off-by: Akinobu Mita --- v3: - rebase to linux-next (next-20260108), where demotion target has changed from node id to node mask. v2: - describe reproducibility with !mglru in the commit log - removed unnecessary consideration for scan control when checking demotion= _nid watermarks mm/vmscan.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index a34cf784e131..9a4b12ef6b53 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -358,7 +358,21 @@ static bool can_demote(int nid, struct scan_control *s= c, =20 /* Filter out nodes that are not in cgroup's mems_allowed. */ mem_cgroup_node_filter_allowed(memcg, &allowed_mask); - return !nodes_empty(allowed_mask); + if (nodes_empty(allowed_mask)) + return false; + + for_each_node_mask(nid, allowed_mask) { + int z; + struct zone *zone; + struct pglist_data *pgdat =3D NODE_DATA(nid); + + for_each_managed_zone_pgdat(zone, pgdat, z, MAX_NR_ZONES - 1) { + if (zone_watermark_ok(zone, 0, min_wmark_pages(zone), + ZONE_MOVABLE, 0)) + return true; + } + } + return false; } =20 static inline bool can_reclaim_anon_pages(struct mem_cgroup *memcg, --=20 2.43.0