From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDECDC3DA4A for ; Wed, 14 Aug 2024 23:42:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64E526B0088; Wed, 14 Aug 2024 19:42:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FE176B0089; Wed, 14 Aug 2024 19:42:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49E706B008A; Wed, 14 Aug 2024 19:42:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2CF5D6B0088 for ; Wed, 14 Aug 2024 19:42:42 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9841B412B5 for ; Wed, 14 Aug 2024 23:42:41 +0000 (UTC) X-FDA: 82452478122.08.E2DD995 Received: from out-175.mta1.migadu.com (out-175.mta1.migadu.com [95.215.58.175]) by imf02.hostedemail.com (Postfix) with ESMTP id BB5788001B for ; Wed, 14 Aug 2024 23:42:39 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=UUWPIp72; spf=pass (imf02.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.175 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723678888; h=from:from:sender: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:dkim-signature; bh=powCy6WP/JGwsZWWQApUZ1BP4yfZE6Dxn7LVxtqo9Gg=; b=SXTOBwc3FqOsjo4qCSlKqZutOKn2wN2Y1zkEK1qT/X734fDjjJgQNA8nqWdhRxPK6ckn1w nmiGJVemeM9D+/m0wBEKTpu4TiE5ze5DKynLlEsFUFshGZCrU3KpqffHIBB9HDHlRwJBsw tUch6SD+8K2AsaOzmaQHWBDahamOzMU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723678888; a=rsa-sha256; cv=none; b=Kr5sLDNiZHgic4D0O66gOtfL8YSDAb+jWuPEtBTtQr8TUqPhja46JLaJuPGESHxkNzxKKf 6TDxxzqji8qwO+G7Pok0O5oaA0P1rimC2ia7eyVr4WO3fQVV3BCpTuzkGvmN/Bn1wc4Wj9 vzRLRWGhwgCLnzvkoMwCk8hj0aUPW8g= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=UUWPIp72; spf=pass (imf02.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.175 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Wed, 14 Aug 2024 16:42:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1723678957; 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=powCy6WP/JGwsZWWQApUZ1BP4yfZE6Dxn7LVxtqo9Gg=; b=UUWPIp72abgqNrtwuevubD420Lr2wsihLdU+wC1Q3kouZEfNgYs9JCg4l3JTBFkKu5abjp jAyjwR0qFEs6JIQtCvGugDwsfnXOKtQdIheb1IGRieo4GMblOQVlx/5XfNdajZiKrHd0VW /24nBr5bCdyz6ZSYvASgEp9SGjUB01c= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Nhat Pham Cc: Jesper Dangaard Brouer , Yosry Ahmed , Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Yu Zhao , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Meta kernel team , cgroups@vger.kernel.org Subject: Re: [PATCH v2] memcg: use ratelimited stats flush in the reclaim Message-ID: <5psrsuvzabh2gwj7lmf6p2swgw4d4svi2zqr4p6bmmfjodspcw@fexbskbtchs7> References: <20240813215358.2259750-1-shakeel.butt@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: BB5788001B X-Stat-Signature: q6mbrr1xxqa63y718se6dbrukdpx8mra X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1723678959-976376 X-HE-Meta: U2FsdGVkX1/tlQIp3qi8IXFkkNXEZ1QwreSr7f7PiVPHc3g5XhIAItdko1BlQy6PG/r0T1vN9kFy2fB44u5/S4Y1soSZaSecMySng2sucokuTvqZdJUQnEiOtiFyDe8QxyQqNPJVLwMd26gTsfQz+9t046cKmC4i+OAyDOqRvMa8YMi3N+RwhxtbsR6xrXHWp/hnimD7w34jaoEaY/91RganBTx5U83nYIxmehHWHBi+x1Z5ObcmSWPJ1LzhXbdDi10qk0nPj6Fjm6rna6ZAp6DVfAYVfYMzV4udl5Df8mPMwXtMc5painIfWGgS5SuP7dU8VJRYj7cDW8LeSLIWoP5oOTdhdG8K4ySZfc31yTz4We+Lhv/s4bXok07z2gypJSERXG8EWdBQs1H2qqAFIL4vT1NDlc+z9Igw+QLKpNJq5qD3YOUJMAClT4zm6zLuv8+MyHN5kf3qT+mhmiW40hKb6b+Xs3xaEoBsWH8f0S1WBoFP0TwupL0KctBflWgFLyMolYqLnRq9pan9gkqNVHXQfB/9T76FV1qavSDDHrZgDMDuidZB4/9Nols0EJX2WUE/XaIiVx+OVehMh6sajZ6tjE8zj3ZGd0tvbGPX9O2vK3wx9AefxWJvAD6WDA8gi8D4MQcddc/qdFPhCs+dsTaBMHav+MQZ7LgeVUbjmK7JVk2iQPdOXL0Y+yfttmgCz2pGeleBjh+FpmkJzSQufHBGf6e8B2MTJvxkCd6YYhMtbpqY2FxeBZDd7+j+7vScdCJGP3bxbQomK/wn0puDfRZt1y/5RdWgzeChcaBH2XoVGuH5g0R4ISqKjU4QYQzFyu8FIsDU5b7MGwqfSRpXvpfXUVWZSmO9sunl8nOzww9CPr1vDi9ySgD+70wKvzrzV3qH0QlxscUmVozVMtcrkJVcTpHqHPSmafGFvlwhxfSDNY4f/fKX/BbKqbeKEqumwNERY8hgB6OOyjH4rV5 jncwYE88 6dBPDOWnww11wRSmjft9OUeYnGKryTG8kxBF31jtLXqRp1ZPE6gWRSYLdv5bNT+QLgXhugpZ8iV2p4TC8J7ytU8D1PJn68bRdCJsygDNa8Z1w74JDWeuqovsZ3BvkL3z00xS/IKMhvL2Wyfw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Aug 14, 2024 at 04:03:13PM GMT, Nhat Pham wrote: > On Wed, Aug 14, 2024 at 9:32 AM Shakeel Butt wrote: > > > > > > Ccing Nhat > > > > On Wed, Aug 14, 2024 at 02:57:38PM GMT, Jesper Dangaard Brouer wrote: > > > I suspect the next whac-a-mole will be the rstat flush for the slab code > > > that kswapd also activates via shrink_slab, that via > > > shrinker->count_objects() invoke count_shadow_nodes(). > > > > > > > Actually count_shadow_nodes() is already using ratelimited version. > > However zswap_shrinker_count() is still using the sync version. Nhat is > > modifying this code at the moment and we can ask if we really need most > > accurate values for MEMCG_ZSWAP_B and MEMCG_ZSWAPPED for the zswap > > writeback heuristic. > > You are referring to this, correct: > > mem_cgroup_flush_stats(memcg); > nr_backing = memcg_page_state(memcg, MEMCG_ZSWAP_B) >> PAGE_SHIFT; > nr_stored = memcg_page_state(memcg, MEMCG_ZSWAPPED); > > It's already a bit less-than-accurate - as you pointed out in another > discussion, it takes into account the objects and sizes of the entire > subtree, rather than just the ones charged to the current (memcg, > node) combo. Feel free to optimize this away! > > In fact, I should probably replace this with another (atomic?) counter > in zswap_lruvec_state struct, which tracks the post-compression size. > That way, we'll have a better estimate of the compression factor - > total post-compression size / (length of LRU * page size), and > perhaps avoid the whole stat flushing path altogether... > That sounds like much better solution than relying on rstat for accurate stats.