From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (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 DDCF53BBFBD for ; Mon, 6 Jul 2026 06:30:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783319408; cv=none; b=PneimQGIfMdwX4P35OgCH8frcak8iAv7E5GXTl03r/zjKnt4mty+RWtKk+M1RDJ4mkxKfXafAnAvHaMXlEF82dIWn63c2bx/1ZP5jtiBHDZ4AfIFzit5VeKy40YfKA4mcGYY9REOXxo0OyFGR3IMSWevyYNpy32yfJUVDY/Zoyg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783319408; c=relaxed/simple; bh=Ylxt5w21YIIbpNtItpVBprDhb2T1dKI9eJzRxGfJ0cA=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=lN7Q17OL0e8ogtT5DLhyVYzYy5mLfd7lqmLGOeSUfJMN46wn21AmWubmcgXfwvbIDXAUWUcGMyk7kb3aqfI81xVGTAUkTJkTsjGgRsoWeybqzBQqUyjzU5RsgNelzJXJj+po9gAIoYnwt9aZ/n3JEMo/sUDfe5wOZGafJI9niZ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=qO+jFkbx; arc=none smtp.client-ip=95.215.58.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="qO+jFkbx" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783319389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3XQkYBnHZWsJpiyDF1oAd+8WYbBHmcQTchDtP++ibmA=; b=qO+jFkbxMfLVNFyOyT2C9xJgciesprCRI0aNzSsDeA8+DQP2vHUY0p5odBTMJos6gjXI9V HrDYMBdGGGXpwhGk1avVIz1/LnmEqiz9JlOg58JJpRgMtu7X/y9H8b/4BcPnJuh2HU4AAi RaL1ZpF2wvW5pAmsGODfbpAWQzFSVG0= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH v2] mm: memcg: reset zswap settings in css_reset X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260702024827.353185-1-jiayuan.chen@linux.dev> Date: Mon, 6 Jul 2026 14:28:54 +0800 Cc: linux-mm@kvack.org, Jiayuan Chen , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Andrew Morton , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <152D4FB6-5540-476E-84AE-AF463929F2B2@linux.dev> References: <20260702024827.353185-1-jiayuan.chen@linux.dev> To: Jiayuan Chen X-Migadu-Flow: FLOW_OUT > On Jul 2, 2026, at 10:48, Jiayuan Chen wrote: > > From: Jiayuan Chen > > 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 > > Cc: Jiayuan Chen > Signed-off-by: Jiayuan Chen Reviewed-by: Muchun Song Thanks.