From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (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 104D31E5B7B for ; Tue, 17 Mar 2026 23:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773788844; cv=none; b=POQJEk+s6AF1MC/zy+ocTrQvN5gD4xUlk/68SGfX1P8lhAkrA7G4xY9HAdkTkJo0Tf1JbxvfaDTkISnlIRb2edOuaRfO+iO7E/197yAzlqwagOdfztk3j7KuLEGPjp1vB5v3SXJieaPLUtHr1f9sLaR3ix8u51LQdZLXeFkRZG8= 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.201 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-f201.google.com with SMTP id 5a478bee46e88-2bead0a9123so3287853eec.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=IgQHynpIDatXdnZLwkM2e5E8hHM+6SwOTe6VEJzl9KAlnDamesPFGA67K7CwHT0UgT 1NR0WK8k9X+q4adZZYeAsGqAZtMum/8ZtrZcYO8ydFWhL+j+SL3rKk2bCZ6lKfm1R7q2 1LbD7w57pT/akbLAqcjLz4lRPAeRx1aO3UI4Wn+9SQfTU2YvPpHb+Lo/EtrFr533Z6UZ c1HMQ4YGm4HFBJS45qeqg866dqq9IZf5d2CzwMX0k+KMKF6CDjbbuQo+xQQjgxw4lJLL gDvWpGlMCuXFUJGgRmJSGxkDGDv4aMWhFttixF4HPDw7mmz1wOwdn3hUToDhlvKSOlnY HKTg== X-Forwarded-Encrypted: i=1; AJvYcCWOg36ZvK1nY8jgPVMI+BCh6i8izOj3Qwt5MIpcv3wi/pSo37kgSlKe8UiMVKtBN3trVnOXrHa9@vger.kernel.org X-Gm-Message-State: AOJu0Yyvp/tkIX77Q4GD9IFj0aviMIcg5Cggy16kttIW8ZCuuCwhyJVJ KvqTQKMOL6IBOk1FN9xzEe9Zyai+/f6r4QwtQsluRQ/RglgPAtffbYCE5bm5agu5K+ZDzgvvZ0H NAH1v7FCuwXM0yg== 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: cgroups@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