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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A6AFC88E77 for ; Wed, 16 Sep 2026 01:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-ID:Date:To:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=d+Y+eiPW1nE6VIhJC8yX27rrjw8WGgTeZfgGyELcrpU=; b=dv6C4qD2GrZr6GdWnagm7V5ouV NYkZmugE1lrmqik3z4VeROMFJAf5hW3WcB5XtkJR65PWlO8QHw5yDK9T+g/zi1BvFHrMzwoyo5xpB JC3+55ReXyVMguNyy0sXB8nj6NrG0VTpGVfQsdEl2J4lWQ+r6AtPQHUwfuhb+alP8UvM=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1x6eri-0002B3-Dx; Wed, 16 Sep 2026 01:55:11 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1x6erf-0002Ab-6C for linux-f2fs-devel@lists.sourceforge.net; Wed, 16 Sep 2026 01:55:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=x1lzUFtT+DGkPXPWDZ4RkZRHXDa5/yt2RwppxsIF6Qs=; b=VHuexfGX8Jup83gWikL/5u3/km DfCKP0TdQpR2kGgppmLB0xu+SMVRGy3ezpe/i/xbSub1rjkgxjpEIlgdRozf/fJxMJiM6kqsHhdyq EX+4yG+PuJBmHs4HORQ6yazqoj/Vgtx8U/qRsmeQD5lcm9eXn/0+/HZNWotPvuKCdKRc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=x1lzUFtT+DGkPXPWDZ4RkZRHXDa5/yt2RwppxsIF6Qs=; b=L9M9n12sw5ozZIJ8IiiAFqqDI0 XHFBdL6u1LpbZ24S/XNVCro4XCsc2BPaPJC8ZFsNBMVh6ZCIdGDn3TGWjNaNh2lv8WrxhZHuMAG0s DFPBpceSytTp3HTkgbJAAwn24SVlkROIdOQHnDOX/1zB38sOfrKubWeIGP6Kp+EyU75c=; Received: from tor.source.kernel.org ([172.105.4.254]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1x6erb-00011r-UZ for linux-f2fs-devel@lists.sourceforge.net; Wed, 16 Sep 2026 01:55:08 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 6308D60231 for ; Wed, 16 Sep 2026 01:55:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F9D21F008A0; Wed, 16 Sep 2026 01:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789523702; bh=x1lzUFtT+DGkPXPWDZ4RkZRHXDa5/yt2RwppxsIF6Qs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f5oJJB6/H7RWDkWJdlnnvdvKgGtOyB+anzk0C/VA7zGhLCMJ0DkY0F5Bf1UDn2B8Q 0kdtzoG2DT3lhQfcFf5ZMcW1b+G5mofva5C7rHe56LG0onYxm4QT+jjYehd062XMpP FbOiKRwFhNIbDP9qEVIHnfQPLN8SmT6VxB/k/KKVzEd5pFn6S6WtmgOFuOhzaeUsY6 f2RwR8LJRCn+uDtl0vomNsq7ZPMxaslBGjTPdGRRtAU79hTWnkGCEHq+TLm9hG7Dbt OGcy3TC055HxF0bHq9cLBsYWSemPxKiQx5D1kFLpzdWc/K4K7VHfMMgvM7zXL9Qap4 cDWM7kLHAGQ4w== To: jaegeuk@kernel.org Date: Wed, 16 Sep 2026 09:54:40 +0800 Message-ID: <20260916015440.2232938-13-chao@kernel.org> X-Mailer: git-send-email 2.55.0.1032.g73a4cd73de-goog In-Reply-To: <20260916015440.2232938-1-chao@kernel.org> References: <20260916015440.2232938-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1x6erb-00011r-UZ Subject: [f2fs-dev] [PATCH v8 12/12] f2fs: cache: show per-cache usage in debugfs X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Chao Yu via Linux-f2fs-devel Reply-To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Chao Yu This patch exposes per-cache memory usage (entry struct memory vs. cached block buffer memory) for meta, node, and compress caches under the memory section in debugfs: - meta entry: xxx KB, meta cache: xxx KB - node entry: xxx KB, node cache: xxx KB - compress entry: xxx KB, compress cache: xxx KB Signed-off-by: Chao Yu --- fs/f2fs/cache.h | 1 + fs/f2fs/debug.c | 49 ++++++++++++++++++++++++++++++++++++++++--------- fs/f2fs/f2fs.h | 2 ++ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/cache.h b/fs/f2fs/cache.h index a8c24f5282fa..d7983ee70337 100644 --- a/fs/f2fs/cache.h +++ b/fs/f2fs/cache.h @@ -38,6 +38,7 @@ enum f2fs_cache_type { F2FS_META_CACHE, F2FS_NODE_CACHE, F2FS_COMPRESS_CACHE, + NR_CACHE_TYPES, }; /* Main cache control structure (per sb_info) */ diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index 4ed5c271dba3..8c0cffde2457 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c @@ -380,17 +380,36 @@ static void update_mem_info(struct f2fs_sb_info *sbi) si->cache_mem += si->ext_mem[i]; } - si->page_mem = 0; - si->page_mem += (unsigned long long)META_CACHE(sbi)->num_entries << PAGE_SHIFT; - si->cache_mem += META_CACHE(sbi)->num_entries * sizeof(struct f2fs_cached_block); - si->page_mem += (unsigned long long)NODE_CACHE(sbi)->num_entries << PAGE_SHIFT; - si->cache_mem += NODE_CACHE(sbi)->num_entries * sizeof(struct f2fs_cached_block); + si->cache_entry_mem[F2FS_META_CACHE] = + (unsigned long long)META_CACHE(sbi)->num_entries * + sizeof(struct f2fs_cached_block); + si->cache_data_mem[F2FS_META_CACHE] = + (unsigned long long)META_CACHE(sbi)->num_entries * sbi->blocksize; + + si->cache_entry_mem[F2FS_NODE_CACHE] = + (unsigned long long)NODE_CACHE(sbi)->num_entries * + sizeof(struct f2fs_cached_block); + si->cache_data_mem[F2FS_NODE_CACHE] = + (unsigned long long)NODE_CACHE(sbi)->num_entries * sbi->blocksize; + + si->cache_mem += si->cache_entry_mem[F2FS_META_CACHE] + + si->cache_entry_mem[F2FS_NODE_CACHE]; + si->page_mem = si->cache_data_mem[F2FS_META_CACHE] + + si->cache_data_mem[F2FS_NODE_CACHE]; #ifdef CONFIG_F2FS_FS_COMPRESSION if (test_opt(sbi, COMPRESS_CACHE)) { - unsigned long npages = COMPRESS_CACHE(sbi)->num_entries; - - si->page_mem += (unsigned long long)npages << PAGE_SHIFT; - si->cache_mem += npages * sizeof(struct f2fs_cached_block); + si->cache_entry_mem[F2FS_COMPRESS_CACHE] = + (unsigned long long)COMPRESS_CACHE(sbi)->num_entries * + sizeof(struct f2fs_cached_block); + si->cache_data_mem[F2FS_COMPRESS_CACHE] = + (unsigned long long)COMPRESS_CACHE(sbi)->num_entries * + sbi->blocksize; + + si->cache_mem += si->cache_entry_mem[F2FS_COMPRESS_CACHE]; + si->page_mem += si->cache_data_mem[F2FS_COMPRESS_CACHE]; + } else { + si->cache_entry_mem[F2FS_COMPRESS_CACHE] = 0; + si->cache_data_mem[F2FS_COMPRESS_CACHE] = 0; } #endif } @@ -749,6 +768,18 @@ static int stat_show(struct seq_file *s, void *v) si->ext_mem[EX_READ] >> 10); seq_printf(s, " - block age extent cache: %llu KB\n", si->ext_mem[EX_BLOCK_AGE] >> 10); + seq_printf(s, " - meta entry: %llu KB, meta cache: %llu KB\n", + si->cache_entry_mem[F2FS_META_CACHE] >> 10, + si->cache_data_mem[F2FS_META_CACHE] >> 10); + seq_printf(s, " - node entry: %llu KB, node cache: %llu KB\n", + si->cache_entry_mem[F2FS_NODE_CACHE] >> 10, + si->cache_data_mem[F2FS_NODE_CACHE] >> 10); +#ifdef CONFIG_F2FS_FS_COMPRESSION + if (test_opt(sbi, COMPRESS_CACHE)) + seq_printf(s, " - compress entry: %llu KB, compress cache: %llu KB\n", + si->cache_entry_mem[F2FS_COMPRESS_CACHE] >> 10, + si->cache_data_mem[F2FS_COMPRESS_CACHE] >> 10); +#endif seq_printf(s, " - paged : %llu KB\n", si->page_mem >> 10); } diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 69690b061236..34878d99a2f0 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4525,6 +4525,8 @@ struct f2fs_stat_info { unsigned int block_count[2]; unsigned int inplace_count; unsigned long long base_mem, cache_mem, page_mem; + unsigned long long cache_entry_mem[NR_CACHE_TYPES]; + unsigned long long cache_data_mem[NR_CACHE_TYPES]; struct f2fs_dev_stats *dev_stats; }; -- 2.49.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel