From patchwork Sat Aug 24 18:04:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13776466 Received: from out-175.mta0.migadu.com (out-175.mta0.migadu.com [91.218.175.175]) (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 008D57DA61 for ; Sat, 24 Aug 2024 18:05:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724522717; cv=none; b=MkpLoObcYaayAluuFvbHj/Zr60FvzRGJfJzY3ZHe2+SAKD4ZX0IMN4gtXN8Fa0iX2t79UjH/AxThWuewPjmfsDPraGaKBMJzah3e7jQqWCYhF+O/BxeQErIeiMds8LlRnClMZ9XS6EUOLx0jlGeKk/p2OZ117dyv/f29lHxmbVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724522717; c=relaxed/simple; bh=yx2TTPkWQYx/+NBdt0PltJw5AhCZpih5oQlFHWE9ZOQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IniXNMDFVYdyXrH4sZfN7eSmuZGnIDKQwGsSeERT9HLTMLYLDlh0JHe92ypmSd82sW2veAtTf9kFYAypfgIFfa9R4BSu4HraY/fLiII4GbEJGgnBhrMEXGxIBFDR+ShfX+HI18Fv1YJEbP4gCR8YNMWd4bmOGrR3ExX6PLM8v48= 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=jHT0hnV0; arc=none smtp.client-ip=91.218.175.175 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="jHT0hnV0" 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=1724522714; 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=jHT0hnV05iv296p3WrQnyV/nbjPukwVJE4DnQqUOpalgUVp344jeS19T8AaczEAFomWJM/ Q/JMvlw1B8IFHtWtSWdsRwEpkejQh0e04qd7eVG6eoKT7aDbD/AqMUcIIb4SgnYAZXrT/u pAW9/ji9lDAxlqSVZJOOrHVx+JF8/MI= From: Kent Overstreet To: david@fromorbit.com, linux-fsdevel@vger.kernel.org, linux-mm@vger.kernel.org Cc: Kent Overstreet , Alexander Viro , Christian Brauner Subject: [PATCH 10/10] fs: super_cache_to_text() Date: Sat, 24 Aug 2024 14:04:52 -0400 Message-ID: <20240824180454.3160385-11-kent.overstreet@linux.dev> In-Reply-To: <20240824180454.3160385-1-kent.overstreet@linux.dev> References: <20240824180454.3160385-1-kent.overstreet@linux.dev> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT 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;