From nobody Sun Feb 8 12:36:46 2026 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.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 7C77436920C for ; Tue, 13 Jan 2026 08:15:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768292143; cv=none; b=e8rgGxBdZhM1ezqS7adRa5wO5tRRp9wSCOD1uB6hYlHhn0OMsG6Xrze6kvhwuX54xeNa9uoly1nrThSGLtoy5fS4+l1LEX4VN1rRMlQlLsAg6uJxnRYSSgXeU+W432VN0oP/nAF5T3GeoxWsf4tHYGnzbVGXz6sWKzE60nee9Nw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768292143; c=relaxed/simple; bh=fp4REK6J/MVZYC22Z2TU+pzeMJxeOKqpDFyn0zcX3KM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T5HtNEBqQTZqIFoYa6fYs/mLc2hwLtxR9bc+xssSacCHKPNMz2xxUzLeCyTXGsyfr4T+NJfZBh1bMLc2J7wYOdHPA+pmBxOKE9MMd0S+WUCzH6xijVnB4n7nlH7sZ3WcpJFjs/v7537eIbFf3SLZUACnH8KiNvqzyAO6bh8wF3Q= 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=FKM+7dq5; arc=none smtp.client-ip=209.85.215.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="FKM+7dq5" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-c06cb8004e8so2728949a12.0 for ; Tue, 13 Jan 2026 00:15:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768292142; x=1768896942; 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=fn+2HMuW53bWkoRvrsYzvFUGyuuVFRazgaZ3DqLSbig=; b=FKM+7dq5LtVXfWMnkPk9bhrTl9tndOTOTmCsf1pGWsegz+cVsePAPstJpj2U7rbNkC A0bny0Dg6t8vZCl+zkU2vs/wK2JuRbXvpSbOecz1ghIZH1P+OrZg9Lsy3IQeEvv+ba9h F0yjEefvqEQ4nCJMSDoClfwDodNKufWBN6eKN8i8L431T5Mg6/hF8adzQipBIG56ypwu 9PrA/zQlIRvHM+fQz4tZHw//PabB3rzLCXxksS+/KXeKlgb/FZkj0odP1ZDsdAtrM/1Z CWLprO6cM4G5RYjnuyjspp0lDXSqq3087KWrii3pxaRx55RiPOerWxHKllKVlUktauwc U+wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768292142; x=1768896942; 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=fn+2HMuW53bWkoRvrsYzvFUGyuuVFRazgaZ3DqLSbig=; b=EH16ao7yWt45992VjWILUFzN+mlG+aiPp/45zh7fr3Vu9On91mUz4csQ0SStYZRPWK IgfXwpLBhWKjZO9BXR+53beSG6+JWA7mWwEuQUr7/6tSdmxFds+Cdj4ut+CIcne5oEhS Tz4LabVWPE+ckobDjFuliCKQQT5SIWljHJ1xdwj4is34RWzRRrPki5HiTZkSUQfEps+V K+4Ei5Lgq80tLSaIV6JbyYlUG9/kMEbTQryPG+DKXzXnmZEbn7aOexvSMxIO+0QI48ky UAYaa6Fdqs4EikmzuU5BQ2RiardEqv50sTzLiAoXhpssGTl3gO3yGUTOW4zySy1Ppg5O MLGg== X-Forwarded-Encrypted: i=1; AJvYcCWOmvPHsl077J94dq5WVShuibx3+62bM/aXx8Q5MuAHIYY8PhcQnezaBn3gzY8U7a/TczbHwuoA0YOi/9c=@vger.kernel.org X-Gm-Message-State: AOJu0YwVUB44ovezhV3UgCVhQh9mC9bxGhDx2126TM+IxWhQFyWw2rLZ 2daNb2tvZVzc3td8K1oJkcEMp8WSpHwqqjlvpkR69OwPtNRpbre78/gV X-Gm-Gg: AY/fxX6RX+SBSHWB8JJwXrR/r9awalx9CkghuR/O+PTtFVNmzSal/1nixMWFZQKOnl9 gCXXvXt1E3PqXl7eqhm7NHhML4EzybP3VXdr3Ee/IW4nqh8NSwhH0bMQ5DafpRU4NJMuK4toSTr B1X0O/jco/axSTwOFeukPWw3o1ytvCmAnQsIiOkN7sjxYs9BkNP94niPwBSBsjTOYMMLnKvy9zt 2qAKUPhMOl4HLkyEAeP0HlOStmTg3GcAWEvxfb/SFChSAOYYvE1vQ1/aYfBi3r40SoHZ0KsV41f u6n+eycNZQoGn9lqGqmpNPRmyg0svFMIon2Fy1fNbQzilgseUjREjQTAB9ll8CHw9oiFFWEj6oQ 4rzvkzO1qpibnaObvi/eq5uuvwwgdBthfyintKvpW0t+YyxZGDzdsKWMXDgY6UT/cZVk6kaOodw YdTY8GUqT33aW5ZaiqaZHuQ7HWEQ== X-Google-Smtp-Source: AGHT+IED9gfPtbQO5QOad8Z+7M8wVwtLncJwWLcyW2QnowsMI6f260Caic2klkdpN/rarjVFLNQLMQ== X-Received: by 2002:a17:90b:3852:b0:343:b610:901c with SMTP id 98e67ed59e1d1-34f68cb9036mr19913726a91.26.1768292141715; Tue, 13 Jan 2026 00:15:41 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:180a:3788:c683:2f64]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-350ff05492dsm657199a91.3.2026.01.13.00.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 00:15:41 -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, ziy@nvidia.com, matthew.brost@intel.com, joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net, ying.huang@linux.alibaba.com, apopple@nvidia.com, bingjiao@google.com, jonathan.cameron@huawei.com, pratyush.brahma@oss.qualcomm.com Subject: [PATCH v4 3/3] mm/vmscan: don't demote if there is not enough free memory in the lower memory tier Date: Tue, 13 Jan 2026 17:14:53 +0900 Message-ID: <20260113081453.8293-4-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260113081453.8293-1-akinobu.mita@gmail.com> References: <20260113081453.8293-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 --- v4: - add a code comment in can_demote() 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 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index f35afc5093dc..f980c533c778 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -358,7 +358,22 @@ 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; + + /* Check if there is enough free memory in the demotion target */ + 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