From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (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 86565334C36 for ; Tue, 27 Jan 2026 22:00:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769551208; cv=none; b=aN1ClEiIjFaQ0/I0+8iBNEznWPZL2NBx4OyupJSyVa2tqywcsdgC43Yg46rl2ijDRDIKYcwn2ZxjqaAnSLr5HEFo1XBX/Gnc7Uv4ZDg29p0BSkNh2c26+dJehkH/Xic1hYZKlFfnak6QpEe57be+I8VWigtx9VQT2wOAzUGB9dA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769551208; c=relaxed/simple; bh=Y88iVvSNkV74nN1mJKvTtB14ao7wckVJ0F+cwVhyggE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jzYB+w9xcLZEWjx7tEjmPWFgwD1CPsL3MrmtqhCzVgBrzNY2wK4PcjRPco0RJqvWXLDTxhUpMKgIQmu/3hs+RFxCSk+XqwaPb5ZHQoiOZu9RfrkN690qx+UJ+YIrnepCUc/RPzANEE76TO6+fefIllK7qYmv7GSTGK5epYeJs/0= 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=caTegEuD; arc=none smtp.client-ip=209.85.128.174 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="caTegEuD" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-7947072d0f6so19182697b3.1 for ; Tue, 27 Jan 2026 14:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769551205; x=1770156005; 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=IjM130EplqqQ/xeoUk9+p55WLFrsTBothNzba4XDkwI=; b=caTegEuDoulqGXdzlUaTBhlAJfesqi1cnRvN7TDROD0eEiueqXnpGByHdh6hvY+Ree b4pN3/XZdF7EJ81kvz21FVWLo4lUgTbvjSa6VHVyavN03AkgIW7sywCN6fbcAFtOO4kb 1tUBiHa7p9VbsLLS9rekPpAAl+Mr7nnFwbbAYtsU5iNB4BmZmika60fLnS8ObCousF+6 gmPSgZKk6ale6dHImcbCiQpYkXff+nVTsAtAdZqUXhi5tT59LdTZVSHDcoVp2OB4UD/a gJm0QHBMIc1V5t1dkhzkrPKiY5CGz6KYbjHBbWEO2He7pxe1kEg1HOdHdfgO1l2fzWZK RTlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769551205; x=1770156005; 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=IjM130EplqqQ/xeoUk9+p55WLFrsTBothNzba4XDkwI=; b=EC5Fq7u5NmaXWvKM+eicrXp77l0iBrdudVm+oxUmGdT1XdOIG/nLQO1MDfD4wQirRn LxlpMgwtww+5HP8MOgIvgqQvVLOSMhX6jaZSzn63JDsRmnGaDDyGJOpbpoUXkk6SdESk beN1z/pmFXY7OQEJhe6KH0IT48P/pu7faulcMmjUiwbPGGedPzE40Ny/JRac45a9jOH4 BXL2QS9xK7Yceut5kBDG9j7JCV7I6xEA2ShThsoDVEFDkH/m2QN8IkhucqAuUzcoQwkn ytvq+wYpWLZq/MgFPaBZh1H/RtSY/xY+4MIGDn/Rh+kekQqbiZDyyuIUq/BZ7X47MRSq SdFA== X-Forwarded-Encrypted: i=1; AJvYcCVNoj5WPoXLsm7jwl68gf4Ti1QmB+0Tv+XIg3AtMutdT4/jmHZ/M3WdygFRkDbAYQt5ObCpzrInX97kf0A=@vger.kernel.org X-Gm-Message-State: AOJu0YyfyVC2iRxww2rnRhvbKIl75W4somUZHKUvQA3RS0+vHOJE6jHE bu60c6LNgK8Fq/NSvnBv7WvYFU7//p5O6w33kUOEFTYTjkvt4BHOKjen X-Gm-Gg: AZuq6aI5Ch75ePSDkt7k19RUhCgMOWhbgpx9y/u+AY7sKaq1D6J8UHZjVFLCQr9X4ww 3Nyc4eGBB3vEdqQJA4ANHkap2rMIOvJqYWmEyhsam4y8mNxfeipJQukb4DaBQehLc5dorK3AV8W Edm73uuzgiLDfOYnwKMaI+y8v1mZTHUC9WgSj1zPBn8tX4zD/Z9ubs1qLcVoxT2Zv0XMbXt5Jp7 +a1gFFsYxrJr/kwx+PkUvBNCW81bigfDuobKv4yuI89YC6SsTMJ8XQXHoBS9Jd2eaEI9UQw54YX TRJBYGsmQBHDaq2V+UsQBnREbzFLPHS8Y/XyhgVTMwN7snKOPgmYPSZ2gWiOQxHTsNCNW483mfO slVmx9VDKvnXFNK/r7OQQOTbFo8Tc3FveoOHEhlz82+1pTAEWOS2bJ1aiGgPPeKiS18VXRBgNo6 f9U41+z0s+qBq+pLbRWB/V X-Received: by 2002:a05:690c:6982:b0:793:a94d:4fd2 with SMTP id 00721157ae682-7947ab1d0b8mr25216387b3.6.1769551205384; Tue, 27 Jan 2026 14:00:05 -0800 (PST) Received: from localhost ([2a03:2880:25ff:11::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-794828ab4c6sm3043037b3.34.2026.01.27.14.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jan 2026 14:00:04 -0800 (PST) From: Joshua Hahn To: Akinobu Mita Cc: Michal Hocko , 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, 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, 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: Re: [PATCH v4 3/3] mm/vmscan: don't demote if there is not enough free memory in the lower memory tier Date: Tue, 27 Jan 2026 17:00:02 -0500 Message-ID: <20260127220003.3993576-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit > > > Therefore, it appears that the behavior of get_swappiness() is important > > > in this issue. > > > > This is quite mysterious. > > > > Especially because get_swappiness() is an MGLRU exclusive function, I find > > it quite strange that the issue you mention above occurs regardless of whether > > MGLRU is enabled or disabled. With MGLRU disabled, did you see the same hangs > > as before? Were these hangs similarly fixed by modifying the callsite in > > get_swappiness? > > Good point. > When MGLRU is disabled, changing only the behavior of can_demote() > called by get_swappiness() did not solve the problem. > > Instead, the problem was avoided by changing only the behavior of > can_demote() called by can_reclaim_anon_page(), without changing the > behavior of can_demote() called from other places. > > > On a separate note, I feel a bit uncomfortable for making this the default > > setting, regardless of whether there is swap space or not. Just as it is > > easy to create a degenerate scenario where all memory is unreclaimable > > and the system starts going into (wasteful) reclaim on the lower tiers, > > it is equally easy to create a scenario where all memory is very easily > > reclaimable (say, clean pagecache) and we OOM without making any attempt to > > free up memory on the lower tiers. > > > > Reality is likely somewhere in between. And from my perspective, as long as > > we have some amount of easily reclaimable memory, I don't think immediately > > OOMing will be helpful for the system (and even if none of the memory is > > easily reclaimable, we should still try doing something before killing). > > > > > > > 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. > > > > This patch enforces that the opposite of this assumption is true; that even > > if a target node has an underlying memory tier, it can never be reclaimed by > > demotion. > > > > Certainly for systems with swap and some compression methods (z{ram, swap}), > > this new enforcement could be harmful to the system. What do you think? > > Thank you for the detailed explanation. > > I understand the concern regarding the current patch, which only > checks the free memory of the demotion target node. > I will explore a solution. Hello Akinobu, I hope you had a great weekend! I noticed something that I thought was worth flagging. It seems like the primary addition of this patch, which is to check for zone_watermark_ok across the zones, is already a part of should_reclaim_retry(): /* * Keep reclaiming pages while there is a chance this will lead * somewhere. If none of the target zones can satisfy our allocation * request even if all reclaimable pages are considered then we are * screwed and have to go OOM. */ for_each_zone_zonelist_nodemask(zone, z, ac->zonelist, ac->highest_zoneidx, ac->nodemask) { [...snip...] /* * Would the allocation succeed if we reclaimed all * reclaimable pages? */ wmark = __zone_watermark_ok(zone, order, min_wmark, ac->highest_zoneidx, alloc_flags, available); if (wmark) { ret = true; break; } } ... which is called in __alloc_pages_slowpath. I wonder why we don't already hit this. It seems to do the same thing your patch is doing? What do you think? I hope you have a great day! Joshua