From patchwork Sat Aug 24 19:10:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13776501 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 21EE1C52D6F for ; Sat, 24 Aug 2024 19:10:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5EB8C800F4; Sat, 24 Aug 2024 15:10:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 573E1800F0; Sat, 24 Aug 2024 15:10:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41684800F4; Sat, 24 Aug 2024 15:10:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1D814800F0 for ; Sat, 24 Aug 2024 15:10:41 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D45F016087D for ; Sat, 24 Aug 2024 19:10:40 +0000 (UTC) X-FDA: 82488080640.10.2329013 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) by imf14.hostedemail.com (Postfix) with ESMTP id 2A49D100010 for ; Sat, 24 Aug 2024 19:10:38 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=uLTTvEzA; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf14.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.188 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724526571; a=rsa-sha256; cv=none; b=ludukc0A3C5749M+skW84aQvlW1iBjQ/EOLO3eMEU3z5GPx/rIHnh+KztJ5/rZpUFZOQFP BRkIp7OdA1cMzo3JiJyqW5uLYv5gF476/2CWzudr0L9ZZmO5JmpNBQsoV/u7REKc4VuPpn gJMUe9Hrkhm5YIIje0zw6E+NhhJl4Aw= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=uLTTvEzA; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf14.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.188 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724526571; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4/6BjvYC74gmac1jn75OzS49TGeIbW4Qt8X6sz89g0E=; b=2PjZ/Zqup1BQyFN1Yg1Vjp+BjKawUVUG0qSi62Ek9FOpIfLeMJaqLWrbMCq35dyCLjzmIB SiLc6x5DEkLHJ8qny81y68o1GPq/y7+kbOJWTy3xxly6Uu6TrDJuemVi9jpHnLvtkHhB6/ id+O7SnzOZssIir7D+pY6SYwiRkTrFc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724526637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4/6BjvYC74gmac1jn75OzS49TGeIbW4Qt8X6sz89g0E=; b=uLTTvEzAmARYGg6WMItjxULIrOooAHWcR1U1Iq5IWriDIXInrJPfTm7cifzOilxCeEAm2U 5IZXCh2j9e45pp9trnFvC3jeTQXWCfhgFsuZf/WIY7+metYuj+pGV7w7VUPQA5h7y/Yo5r z4rS4OOztEOz0kMF8FXMpgTNMw7IC4w= From: Kent Overstreet To: david@fromorbit.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: Kent Overstreet , Alexander Viro , Christian Brauner Subject: [PATCH 10/10] fs: super_cache_to_text() Date: Sat, 24 Aug 2024 15:10:17 -0400 Message-ID: <20240824191020.3170516-11-kent.overstreet@linux.dev> In-Reply-To: <20240824191020.3170516-1-kent.overstreet@linux.dev> References: <20240824191020.3170516-1-kent.overstreet@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2A49D100010 X-Stat-Signature: thzodrddxyt3a3n5rbb79gdxghmkhmhq X-Rspam-User: X-HE-Tag: 1724526638-882515 X-HE-Meta: U2FsdGVkX1/qBzs8Lc0o7NijFJ01SbNGf98ndmIa4+5JrVYivux+StIa8RBxrFReGxfnTS6pd6l0FWaF/6V+jSql2H/k/bfKcopEB4yBGsq4OCcusC++sHH0wyyZGHr4oTQjkvcBdcf54vVJFTGFZvvC5BGfBEXL552As47jyDqX6f8/JUfGrdG+Hd88wUc+j5RAM4tqbFTE/q9jtRO1UGl1j0VFZZdqNsh9ohKfswf7cPN/zXU2KSi1GQ6Uox02oJMXygqE9RKbuAggrr1JCXnzO9WsiniiK1OcaRgRkSBRNcHXsLO+FVYhjpfx887gfgU/JCF1H8gWUSNKmAEnfuBbZGyJTRtXv8O3vvDYqAgN9Gy2BlI1YcRJkV61BaZKAQuzawWZtoFi8h7aHFQDKfK+hFPHqeLZWYAQUblC8gKj+RWZxPDOoSJywaEJQWl+m8uxf38UZC1ksq/RnnJnHsfhfwLqgn6iRZtF1WCI6byoEKPuh6/hdxcShaPuNtxVA6Dbz9Fvlu6Vz5m5dArkFaACgdHFvJZ6Kpk+9/br9UANFpejloCaeC6s5jFc9l+Bpy2YWUhBq6f4x0aISq/B+O0HeOIUp0VGALBy+UGwmh51P7MjBnfsYLGdLXY/RNOCYzNNVaTdAINEnlEbrmDQV4SOfMUswsk79G4bX9rLG4CYb1mWoFQ0V/70T3fENERlQBamqvV7DGSUb7jDlfO5yDZlClGQcpIWqb4K8ydFvAEhnXQqR2HCBvbzwMOdt4wTZTUQAiidX09Dh0PrPFbWrDB0QzogWin4+GwKj+HW581ygpPH7UFakisiWL1sIB/e/e3HuP+n2Abq2PeeT8esJrFvuCs/uPvvJT7lmcA08DWzby8Y4Hw4Gu5MlJCPJqLaZ8DSY6UtjOqUc6LcrAFB/wV86uXzaJdp9JRvq7bP6HtgXkUllbdflXT/FhJBiZ80Eih76PBFjmT+vuMN4St LV4lueky D7DjAmOfyvC9lv2/V1/T9HZYBswBSFlpmTbcnW8s8f8omd0bkDr95MYqDSb4KTHGyaRHbNzN/CmBvbwrXLI9wz6SIcMq0FeZkK9qfU0rEP+Tm7JfBhmjwY0FDkRqDy8zKyo+qfCqYSKEe7RADaC3DxGoD1+vU/iy2cJINpsd9NKrLWHqoUUBzDXqFvTjQGnmkrve0BbGous6UtlcbCzctjKH9lvTQ68y0MEFpW/WYGX1k565Xh8+HgrZrTx7lJmQqH66EQ0XmahPiHA6cudMBMAXF7DZ2qR6/PnqGXEcVsOcgb6pWhdPJgA04jeFQp/dVj9lgCmWDAmu8E6XPXScWJu8iZA== 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: Implement shrinker.to_text() for the superblock shrinker: print out nr of dentries and inodes, total and shrinkable. Cc: Alexander Viro Cc: Christian Brauner Cc: Dave Chinner Signed-off-by: Kent Overstreet --- fs/super.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/super.c b/fs/super.c index 5b0fea6ff1cd..d3e43127e311 100644 --- a/fs/super.c +++ b/fs/super.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "internal.h" @@ -270,6 +271,16 @@ static unsigned long super_cache_count(struct shrinker *shrink, return total_objects; } +static void super_cache_to_text(struct seq_buf *out, struct shrinker *shrink) +{ + struct super_block *sb = shrink->private_data; + + seq_buf_printf(out, "inodes: total %zu shrinkable %lu\n", + per_cpu_sum(sb->s_inodes_nr), list_lru_count(&sb->s_inode_lru)); + seq_buf_printf(out, "dentries: toal %zu shrinkbale %lu\n", + per_cpu_sum(sb->s_dentry_nr), list_lru_count(&sb->s_dentry_lru)); +} + static void destroy_super_work(struct work_struct *work) { struct super_block *s = container_of(work, struct super_block, @@ -394,6 +405,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_shrink->scan_objects = super_cache_scan; s->s_shrink->count_objects = super_cache_count; + s->s_shrink->to_text = super_cache_to_text; s->s_shrink->batch = 1024; s->s_shrink->private_data = s;