From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 07FBA293B5F for ; Tue, 17 Mar 2026 23:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773788844; cv=none; b=rQP5PHXSxAhisKR5Ev2BUUr+UxJ17eIag7t/vvmDpet2d3mkpkaSxQeu9MFurfrFIYNZZuJeso2hxmRpIckkDItwUNwNPdjVfraOWTqDwPGh7Pjv26m1eVI0A/HpGPazHOrp+7NXmJT1UBiWpmx4ZwTj8WABlBG+O8NrK6FFg68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773788844; c=relaxed/simple; bh=FK+9YKQ/DIUq0kXP72niYHWDNfO5DIOWYPw/t2u7uU0=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=MaiRzMI9Ej6wD5OU9N4XNGB25MOIVjYZ1Hs0UZY87mMREiHMw3rIyte9GGoZmiUbmg+HmWyagAGqbH+bItc+HqlpFMD2SqyqioLnanXk5IWmYnoJUNIyEZbwAfm4Le2VEsIAKOYwP46RT/9smKQJ+vx8JWnDdUogS0xkvlhyH/A= 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=R97arZgQ; arc=none smtp.client-ip=74.125.82.202 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="R97arZgQ" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2bead0a9123so3287860eec.1 for ; Tue, 17 Mar 2026 16:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773788842; x=1774393642; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Lb4d72Dw6v8zTFjLSshGhZJgBDqi5O2Bbx7kiArqy98=; b=R97arZgQQwZCl2Lhn6y/oiy1W53Wsn4aEo24Jd+S4uU0KZh/HvTLJy0HE4Zu/wV6XS gtw3HoI96xdOGSKXEBGroASyvZM28b+K9I6pLADv97eprqXCLTjgEhf3nw3Df+GqR+yA uA9sQEX4FymB0I8Pd2QahatZSeQ8l2G7C2tMJEOKqV3R+lWaiBM6hR6qyMK4O6P2kpav LGfau3krwvdtfVlNF1F0SwoPnZd87EcMKKiF8FtrEE8WvBiTV8fFXQyfNsPncxnjmnL3 CaS6wAEONJwFV7SiMgsSRsC9kzoR9hIGP7pFtKRBN1M2LRusJw/s7B7pWqR/I0+Z/lcK 0M1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773788842; x=1774393642; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Lb4d72Dw6v8zTFjLSshGhZJgBDqi5O2Bbx7kiArqy98=; b=WIT0u6Q8XPI9VoQD3RZKjumYEEuYivAQi4GZvBGSbrjjz3AM/CDuOS6lcm+txnto2e 9XssNTC6qskw8I7ZjOspRzFCC92SE1+NgYsyhtibHzb1gEOByRoOdHb6lxeBBEFPas1U cCA6B1a3vZOAdOkNAO9s0Y2eF+Y7nyogDi34CBZIsRTycTdLLjd3mfsVhTbrhm8OTozx mYhjAd6hP93IWMHMyXmU1+PJ6wRd+3Cs5x9a9KNKAInRDz4EjRD02zkK35qqdixBk5h4 gndMG3m9Z7i9XgcFtV3/POyHq0UseM1yxxgJVK/ynQDQyHut0DBRJYiadTE7lGxV9Ah+ 2hFQ== X-Forwarded-Encrypted: i=1; AJvYcCUnLXk1STWngiv+wTJUzp1OvgSnFDpHHj+HENcXabkj/N3P4HT74wqU5mvkoMEAA+av6sfgdAbxhSAbgEA=@vger.kernel.org X-Gm-Message-State: AOJu0YwpXhIx7OifneNP8p5MKOMuxub49pGKqAFTxx7bqAVfB5aJ213n cwVJL2kHxw64Iah5Yg/m4nbn6ONlQrLsTnBsJ4pgaznt2RPH3KiooGP2ZbjnFvNFYxKlrfgcf2F H8+mpg59tMh8epA== X-Received: from dybb24.prod.google.com ([2002:a05:693c:6098:b0:2c0:ccba:438b]) (user=bingjiao job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:7316:b0:2be:3cd:62bc with SMTP id 5a478bee46e88-2c0e4f9f0f1mr601175eec.13.1773788841723; Tue, 17 Mar 2026 16:07:21 -0700 (PDT) Date: Tue, 17 Mar 2026 23:06:59 +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.851.ga537e3e6e9-goog Message-ID: <20260317230720.990329-1-bingjiao@google.com> Subject: [PATCH 0/3] mm/memcontrol: control demotion in memcg reclaim From: Bing Jiao To: linux-mm@kvack.org Cc: Bing Jiao , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , David Rientjes , Yosry Ahmed , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , David Hildenbrand , Qi Zheng , Lorenzo Stoakes , Axel Rasmussen , Yuanchu Xie , Wei Xu , Joshua Hahn Content-Type: text/plain; charset="UTF-8" In tiered-memory systems, NUMA demotion counts towards reclaim targets in shrink_folio_list(), but it does not reduce the total memory usage of a memcg. In memcg direct reclaim paths (charge-triggered or manual limit writes), this leads to "fake progress" where the reclaim loop concludes it has satisfied the memory request without actually reducing the cgroup's charge. This results in inefficient reclaim loops, CPU waste, moving all pages to far-tier nodes, and potentially premature OOM kills, and potentially premature OOM kills when the cgroup is under memory pressure but demotion is still possible. This series fixes this issue by disabling demotion in memcg-specific direct reclaim paths and provides user control for proactive reclaim. Patch 1: Fixes a state leak in try_charge_memcg() where reclaim_options were modified and carried over to retries improperly. Patch 2: Introduces MEMCG_RECLAIM_NO_DEMOTION and disables demotion in memcg direct reclaim paths. Patch 3: Adds a 'demote=' option to the proactive reclaim interface (memory.reclaim), allowing users to explicitly enable demotion if desired, while defaulting it to disabled for consistency. Bing Jiao (3): mm/memcontrol: fix reclaim_options leak in try_charge_memcg() mm/memcontrol: disable demotion in memcg direct reclaim mm/vmscan: add demote= option to proactive reclaim include/linux/swap.h | 1 + mm/memcontrol-v1.c | 10 ++++++++-- mm/memcontrol.c | 17 ++++++++++++----- mm/vmscan.c | 11 +++++++++++ 4 files changed, 32 insertions(+), 7 deletions(-) -- 2.53.0.851.ga537e3e6e9-goog