From patchwork Wed Nov 22 23:25:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13465563 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 D1815C27C40 for ; Wed, 22 Nov 2023 23:25:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A866C6B05F1; Wed, 22 Nov 2023 18:25:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0AEF6B05F2; Wed, 22 Nov 2023 18:25:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8859C6B05F3; Wed, 22 Nov 2023 18:25:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6C71F6B05F1 for ; Wed, 22 Nov 2023 18:25:33 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5602BA14E2 for ; Wed, 22 Nov 2023 23:25:33 +0000 (UTC) X-FDA: 81487174146.17.0234F79 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) by imf06.hostedemail.com (Postfix) with ESMTP id AC71C180014 for ; Wed, 22 Nov 2023 23:25:31 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="o3CvX/g1"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.181 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=1700695531; 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=+xIe2DoE21qrt9LSNcAUwIwIwHsNrxaH9AQLMP04McM=; b=f1FLHNUn8Yb8frSzo1T6e2bedUw8RbHtBdgCpIahmy/A9akkstbfcRQQ68i/vXb9/v93yr gjeq8dgG2kwVEUhFhFFtIxDHw1t+6SsnlKUF7dGRXkl5YynV6Pv1EmLaczfUuOxbe6zG6D 5KpHD7VP4KNQiVrtbgMbhKCkJ09DFyM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="o3CvX/g1"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.181 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700695531; a=rsa-sha256; cv=none; b=LkbCn09+laLh0VnLSWVtrM88qnraPfgmIkH6L39njpkA9wMv/eucDPrXNH2ZAySU82xiqx dTMLgSZf1cbpkz26V+Noy1WS85qU23Wizevj12rZaxksR073qooBSr0EyRcCzvONgRn6lm 7l3XjBepV+0L89+8m5TJGboXWlL/5Ao= 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=1700695530; 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=+xIe2DoE21qrt9LSNcAUwIwIwHsNrxaH9AQLMP04McM=; b=o3CvX/g1Mo37OAG87L/6Vu3aVXW2glLs+ZCCGUrP4H0SA8cPtcuDyYy22kVuLNkWtpIA9Q /HbvDCodA7ny8mu2ew1QagbLzcTglJHQRpbARFoW4RvMBKCAQNlLos+/qEMrNpU12NLKky vaSlk3dtsvcNkFHaJ0XGnT1dL407Frk= From: Kent Overstreet To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Kent Overstreet Subject: [PATCH 6/7] bcachefs: shrinker.to_text() methods Date: Wed, 22 Nov 2023 18:25:11 -0500 Message-ID: <20231122232515.177833-7-kent.overstreet@linux.dev> In-Reply-To: <20231122232515.177833-1-kent.overstreet@linux.dev> References: <20231122232515.177833-1-kent.overstreet@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: AC71C180014 X-Stat-Signature: rjide6f7xz4xn538pbje6ciz4wweftnx X-HE-Tag: 1700695531-749832 X-HE-Meta: U2FsdGVkX1/l4+hqlGebh9zVmftH23YLjoDxR9PQrrp8Qt4FInyJmy56YdYCvVnC/Ps1eiHmPkm2WqHlHZfrQllto6q0mYSFozoQwTEDDdHxjDQ0kZxiYwlhlVFvuRyBdDYXQXWVJFamPH0UioaGN2FR6m4rvCJDTCCX60z/qNGZcdcI6xu0K6g23w13/sDII4LRlRxxL7YmFJRTrff9qzMzjM+1tlXOHsvGhL1MCWJc09CArVCNQG2auAQkn51nJ0+6wGPYnWlb6K/Dk9a7/7eHpqDK9OukVFgpO5Rs1jp79X7apOXyd613nTmccyTJ48zvV4O8Xa+vRPVsdeK9c6mPL/hJLQHBC1IyS4qiWkmeU4mTHF0N7EJd8dHyKQSaNN4VKD7cW3mPRmtcHmuzWGyvzjTqCGDsLhFJdCMRw3fG7kh6fG3d4QvFSK9wdxoVC66ncKmz13aVzd8T5mT1PAab9YDCpiCB6Oacyesjc+OFMj/ZnBO6oF40Z/38nfAt5T6PwfGPSk/DCij5SWSmXLyhMUwk1GXzi6MZuaP+kGQ62vrCgkUM0tYpGZTYZbz7do5V555NrgbLWNjJIU9V+/n691gH8iCwS+ui6Me42/9cNpsSZsJdk1FnCBGGAVjADoMKoivCsKuuPqq8d6MKS5FenDlaYh7vFPB+GqPHAOPfoouwmq/uhX4rmf/mkbCwDStQf7qJ0h51HOnovF1XWpa4HYxrDQYknqlVJDKiIC8fxFR48qf0HhaJzFZGTOTwFkHcvncek6qYaKFEa/ZILqBjgmbFsfWbB6HOk8sqbzAIThtfOD41LRhDYqbmyMUUC5G/cr5rUYCCmBD7MAvJ8U210R5MKLqof2Eh5yTti9XiOVVrN0/TCzpPEA5fJVOivJ6o58PxvnMDJ9kI6xAJVUjP6fUpDJidLfXQuq170XpsZUr7UJxqSYlz6rDsSMrzTFhz+EOqRrp7H5gXR8T QBjzawWy rOHjGjdv94R0yLeVT8G94lTx2gNBOpQlpAhVKY23uOkGPobQQOZcQecdCKfV7fPxc1aRSc/rWUm4cI8Ftk4wwXi1epFoaRHZDnR5nkTQaFjP2kP4JecfZ5631vKlB9D6WmnFA 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: This adds shrinker.to_text() methods for our shrinkers and hooks them up to our existing to_text() functions. Signed-off-by: Kent Overstreet --- fs/bcachefs/btree_cache.c | 13 +++++++++++++ fs/bcachefs/btree_key_cache.c | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 47e7770d0583..aab279dff944 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -13,6 +13,7 @@ #include #include +#include const char * const bch2_btree_node_flags[] = { #define x(f) #f, @@ -392,6 +393,17 @@ static unsigned long bch2_btree_cache_count(struct shrinker *shrink, return btree_cache_can_free(bc); } +static void bch2_btree_cache_shrinker_to_text(struct seq_buf *s, struct shrinker *shrink) +{ + struct bch_fs *c = shrink->private_data; + char *cbuf; + size_t buflen = seq_buf_get_buf(s, &cbuf); + struct printbuf out = PRINTBUF_EXTERN(cbuf, buflen); + + bch2_btree_cache_to_text(&out, c); + seq_buf_commit(s, out.pos); +} + void bch2_fs_btree_cache_exit(struct bch_fs *c) { struct btree_cache *bc = &c->btree_cache; @@ -478,6 +490,7 @@ int bch2_fs_btree_cache_init(struct bch_fs *c) bc->shrink = shrink; shrink->count_objects = bch2_btree_cache_count; shrink->scan_objects = bch2_btree_cache_scan; + shrink->to_text = bch2_btree_cache_shrinker_to_text; shrink->seeks = 4; shrink->private_data = c; shrinker_register(shrink); diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index 4402cf068c56..e14e9b4cd029 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -13,6 +13,7 @@ #include "trace.h" #include +#include static inline bool btree_uses_pcpu_readers(enum btree_id id) { @@ -1028,6 +1029,18 @@ void bch2_fs_btree_key_cache_init_early(struct btree_key_cache *c) INIT_LIST_HEAD(&c->freed_nonpcpu); } +static void bch2_btree_key_cache_shrinker_to_text(struct seq_buf *s, struct shrinker *shrink) +{ + struct bch_fs *c = shrink->private_data; + struct btree_key_cache *bc = &c->btree_key_cache; + char *cbuf; + size_t buflen = seq_buf_get_buf(s, &cbuf); + struct printbuf out = PRINTBUF_EXTERN(cbuf, buflen); + + bch2_btree_key_cache_to_text(&out, bc); + seq_buf_commit(s, out.pos); +} + int bch2_fs_btree_key_cache_init(struct btree_key_cache *bc) { struct bch_fs *c = container_of(bc, struct bch_fs, btree_key_cache); @@ -1051,6 +1064,7 @@ int bch2_fs_btree_key_cache_init(struct btree_key_cache *bc) shrink->seeks = 0; shrink->count_objects = bch2_btree_key_cache_count; shrink->scan_objects = bch2_btree_key_cache_scan; + shrink->to_text = bch2_btree_key_cache_shrinker_to_text; shrink->private_data = c; shrinker_register(shrink); return 0;