From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC48F26B08F for ; Sun, 5 Jul 2026 21:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783285301; cv=none; b=bkBXSaPsWUbnRlxtL+KzKmes+pzpbXdnk3TH6YGZ6Pmn//gcFP9aZRDhZq2w1Gdqgis44lBGC71pWyoHbGk8m8fupKwiAgvb+jAFxRk+bcPrhPNd2gIf2TPQHS+WSOpJNdR3MSKz6abNd20KB66G7/4884vYtrM8cgCB005prLg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783285301; c=relaxed/simple; bh=oVdCvxnzuIsI6kmwejlIltqCJQ0O0y38ZffkAu0ziAk=; h=Date:To:From:Subject:Message-Id; b=FP6ihw6ixiFX1CLQMJoIv5O1828Qy+5QvaqTMkWNlIPiWpBXBMwvw9QYLANLFDiUwyqXivxT/fhTxyVNPZQTgNrk/FRq+cFc9sxc4fNrPZYeIKq1n5ecd7ruhhfPQR0SEQRzRipa7s9KvXEMBweorb5DWhjFJmt9u3642q+h1o0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=bx7qoirb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="bx7qoirb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F81D1F00A3A; Sun, 5 Jul 2026 21:01:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1783285299; bh=vX73QvhRII31KyHrpikvFNhXGrmfMWsaXf3noyDRPtk=; h=Date:To:From:Subject; b=bx7qoirbp/RP/PwGNgjhgQVzDsgei3WAu1l7822LfWiGJKM2wh2G7BG+4Np+nkapO u9dhiIO8Q+8jf2k6PXlX+30VUz14Vi1sxMrqaZgVj/gDhaH0Xdd3bGNZy5VUjNv+Lh TvS/R7PdiMJRmaPTykn67waxkhSdCSR3zACeb3ec= Date: Sun, 05 Jul 2026 14:01:38 -0700 To: mm-commits@vger.kernel.org,shakeel.butt@linux.dev,roman.gushchin@linux.dev,nphamcs@gmail.com,muchun.song@linux.dev,mhocko@kernel.org,hannes@cmpxchg.org,chengming.zhou@linux.dev,jiayuan.chen@shopee.com,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-memcg-reset-zswap-settings-in-css_reset.patch added to mm-new branch Message-Id: <20260705210139.4F81D1F00A3A@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm: memcg: reset zswap settings in css_reset has been added to the -mm mm-new branch. Its filename is mm-memcg-reset-zswap-settings-in-css_reset.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memcg-reset-zswap-settings-in-css_reset.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Jiayuan Chen Subject: mm: memcg: reset zswap settings in css_reset Date: Thu, 2 Jul 2026 10:48:25 +0800 mem_cgroup_css_reset() is called when the memory controller is disabled on a cgroup but the memcg cannot be destroyed because it is pinned by a subsystem dependency -- for example, the io controller declares .depends_on = 1 << memory_cgrp_id, so memory remains in the cgroup_ss_mask and the css is hidden rather than killed. The purpose of css_reset is to revert the memcg to its vanilla state so that no policies are applied and the css can be safely made visible again later. Currently, all page counters (memory.max, swap.max, kmem.max, tcpmem.max) and other limits (soft_limit, memory.high, swap.high) are reset to their defaults, but zswap_max and zswap_writeback are not. These fields are initialized in css_alloc (zswap_max = PAGE_COUNTER_MAX, zswap_writeback inherited from parent) but were missing from css_reset. As a result, stale zswap policies remain in effect after css_reset: the zswap charge path (obj_cgroup_may_zswap) continues to enforce the old zswap_max limit, and the writeback path continues to honor the old zswap_writeback setting, even though the memory controller has been "disabled" on this cgroup. Reset zswap_max to PAGE_COUNTER_MAX and zswap_writeback to true, matching their defaults in css_alloc. Test: echo "+memory +io" > /sys/fs/cgroup/cgroup.subtree_control mkdir /sys/fs/cgroup/test mkdir /sys/fs/cgroup/test/child echo "+memory +io" > /sys/fs/cgroup/test/cgroup.subtree_control echo 10000 > /sys/fs/cgroup/test/child/memory.zswap.max # child/memory.swap.max and child/memory.zswam.max disappear echo "-memory" > /sys/fs/cgroup/test/cgroup.subtree_control # re-enable memory control echo "+memory" > /sys/fs/cgroup/test/cgroup.subtree_control # before this patch cat /sys/fs/cgroup/test/child/memory.zswap.max 8192 # after this patch, same as memory.swap.max cat /sys/fs/cgroup/test/child/memory.zswap.max max Link: https://lore.kernel.org/20260702024827.353185-1-jiayuan.chen@linux.dev Signed-off-by: Jiayuan Chen Cc: Chengming Zhou Cc: Johannes Weiner Cc: Michal Hocko Cc: Muchun Song Cc: Nhat Pham Cc: Roman Gushchin Cc: Shakeel Butt Signed-off-by: Andrew Morton --- mm/memcontrol.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/mm/memcontrol.c~mm-memcg-reset-zswap-settings-in-css_reset +++ a/mm/memcontrol.c @@ -4362,6 +4362,10 @@ static void mem_cgroup_css_reset(struct page_counter_set_max(&memcg->memory, PAGE_COUNTER_MAX); page_counter_set_max(&memcg->swap, PAGE_COUNTER_MAX); +#ifdef CONFIG_ZSWAP + WRITE_ONCE(memcg->zswap_max, PAGE_COUNTER_MAX); + WRITE_ONCE(memcg->zswap_writeback, true); +#endif #ifdef CONFIG_MEMCG_V1 page_counter_set_max(&memcg->kmem, PAGE_COUNTER_MAX); page_counter_set_max(&memcg->tcpmem, PAGE_COUNTER_MAX); _ Patches currently in -mm which might be from jiayuan.chen@shopee.com are mm-damon-core-split-a-fraction-of-regions-when-nr_regions-exceeds-max-2.patch mm-damon-tests-core-kunit-test-split-above-max_nr_regions-2.patch memcg-bail-out-memoryhigh-when-memcg-is-dying.patch memcg-bail-out-memorymax-when-memcg-is-dying.patch memcg-bail-out-proactive-reclaim-when-memcg-is-dying.patch memcg-v1-bail-out-reclaim-when-memcg-is-dying.patch mm-memcg-reset-zswap-settings-in-css_reset.patch