From patchwork Tue Apr 19 20:32:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 12819412 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 ADFCCC43217 for ; Tue, 19 Apr 2022 20:32:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44CEE6B0078; Tue, 19 Apr 2022 16:32:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 359F86B007B; Tue, 19 Apr 2022 16:32:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B0946B007D; Tue, 19 Apr 2022 16:32:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 071B46B0078 for ; Tue, 19 Apr 2022 16:32:18 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CCCA520BCA for ; Tue, 19 Apr 2022 20:32:17 +0000 (UTC) X-FDA: 79374775914.16.2F0F28B Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by imf09.hostedemail.com (Postfix) with ESMTP id 6862D140008 for ; Tue, 19 Apr 2022 20:32:16 +0000 (UTC) Received: by mail-qk1-f177.google.com with SMTP id d198so11291996qkc.12 for ; Tue, 19 Apr 2022 13:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OJODyF/ajH9xOJK+4CIgokrEBufAgT0uT/ipe+iH5NU=; b=QAsHvwzDiVLVrGcU+9jbXMpQHWpDKdMfj3bnaE6Fu/OB+mJ3UTI2COzzBz8F3B8PDY QR/HlbQYkvX1wLqTHtrj09BO5gbHxfopW1/9ErRgVdLGBXmwB2vh783JIEf1zL6y8m+1 gOyPOGYrhW7b1BfPzQGL9EWo3jr7z4k0QgYVP2/c2gSoJpNHts8tIk6Y+KfQW/pB83A9 g6G7mq+Ri4BnZ0etWfdnCF6WkxD2F/lCKxbTpcoRuig61gE97c4evJaj8ypBbSFuTLw/ kkfwBHq79jHa+vLZ4y9nTlceUZJ9SRnkNEyvY/hJNAx/aS7t2tOy0ZcRWyCVKI+ZBv16 9bzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OJODyF/ajH9xOJK+4CIgokrEBufAgT0uT/ipe+iH5NU=; b=yujDFoJ2gcC8PU54gP2V2b8yznQ2vluFs9YV+4mg9VAZDcBzLSqjYD5aQ5qFzaaCt6 AUI2gCAaNgtzrB+3QCL0qF1afijnJQkqnEvn7medThAwVC4VkgQ9SvqqxKpAYEckw5pm oFXMxYh0OPWE33nHOqHJcvLZmGzzydaIym2VzQ1nQwjSBSMKzpo+80M1cqf+3zdIb+/Q S9ib34KvkeIKnJ6ZEu0PCqYVuVcp49FU/pa7AzoiRhnLVt6jU52P+kSbiZGbbRdYBIT6 gEx5dgb5+PyfxAO4n/NjZW+fQnSSo68wNtevfUFcOVLVA2MWfTl0imQ1ze1lqhIqtILr hg5w== X-Gm-Message-State: AOAM5328lukt9pR7sDG+2813pSTWk6cQoC1ObhXlRBaPTCV6ykhQtDPq ZRGi3YHb7ysdLBh/5hbhqQ== X-Google-Smtp-Source: ABdhPJwglihygmVaHV5xfkCJRJUfFCN+9TSdbuDle94mmw3wMqPZlOg/eMDWhy7vp1WF0tcR+c+hZg== X-Received: by 2002:a05:620a:4711:b0:67e:6c24:2b2b with SMTP id bs17-20020a05620a471100b0067e6c242b2bmr10987093qkb.588.1650400336592; Tue, 19 Apr 2022 13:32:16 -0700 (PDT) Received: from moria.home.lan (c-73-219-103-14.hsd1.vt.comcast.net. [73.219.103.14]) by smtp.gmail.com with ESMTPSA id e9-20020ac84e49000000b002f1fcda1ac7sm611180qtw.82.2022.04.19.13.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 13:32:15 -0700 (PDT) From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: Kent Overstreet , roman.gushchin@linux.dev Subject: [PATCH 4/4] bcachefs: shrinker.to_text() methods Date: Tue, 19 Apr 2022 16:32:02 -0400 Message-Id: <20220419203202.2670193-5-kent.overstreet@gmail.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220419203202.2670193-1-kent.overstreet@gmail.com> References: <20220419203202.2670193-1-kent.overstreet@gmail.com> MIME-Version: 1.0 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QAsHvwzD; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.222.177 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 6862D140008 X-Stat-Signature: beditrybfhhoztzsjkumr9kyoz4m91nt X-HE-Tag: 1650400336-81843 X-Bogosity: Ham, tests=bogofilter, spamicity=0.352850, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Signed-off-by: Kent Overstreet --- fs/bcachefs/btree_cache.c | 18 +++++++++++++++--- fs/bcachefs/btree_key_cache.c | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 72f0587e4d..75ef3b5462 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -394,6 +394,14 @@ 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 printbuf *out, struct shrinker *shrink) +{ + struct bch_fs *c = container_of(shrink, struct bch_fs, + btree_cache.shrink); + + bch2_btree_cache_to_text(out, c); +} + void bch2_fs_btree_cache_exit(struct bch_fs *c) { struct btree_cache *bc = &c->btree_cache; @@ -477,6 +485,7 @@ int bch2_fs_btree_cache_init(struct bch_fs *c) bc->shrink.count_objects = bch2_btree_cache_count; bc->shrink.scan_objects = bch2_btree_cache_scan; + bc->shrink.to_text = bch2_btree_cache_shrinker_to_text; bc->shrink.seeks = 4; ret = register_shrinker(&bc->shrink); out: @@ -1147,7 +1156,10 @@ void bch2_btree_node_to_text(struct printbuf *out, struct bch_fs *c, void bch2_btree_cache_to_text(struct printbuf *out, struct bch_fs *c) { - pr_buf(out, "nr nodes:\t\t%u\n", c->btree_cache.used); - pr_buf(out, "nr dirty:\t\t%u\n", atomic_read(&c->btree_cache.dirty)); - pr_buf(out, "cannibalize lock:\t%p\n", c->btree_cache.alloc_lock); + pr_buf(out, "nr nodes: %u", c->btree_cache.used); + pr_newline(out); + pr_buf(out, "nr dirty: %u", atomic_read(&c->btree_cache.dirty)); + pr_newline(out); + pr_buf(out, "cannibalize lock: %p", c->btree_cache.alloc_lock); + pr_newline(out); } diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index a575189f35..32b5cb6042 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -711,6 +711,14 @@ void bch2_fs_btree_key_cache_init_early(struct btree_key_cache *c) INIT_LIST_HEAD(&c->freed); } +static void bch2_btree_key_cache_shrinker_to_text(struct printbuf *out, struct shrinker *shrink) +{ + struct btree_key_cache *bc = + container_of(shrink, struct btree_key_cache, shrink); + + bch2_btree_key_cache_to_text(out, bc); +} + int bch2_fs_btree_key_cache_init(struct btree_key_cache *c) { int ret; @@ -724,14 +732,18 @@ int bch2_fs_btree_key_cache_init(struct btree_key_cache *c) c->shrink.seeks = 1; c->shrink.count_objects = bch2_btree_key_cache_count; c->shrink.scan_objects = bch2_btree_key_cache_scan; + c->shrink.to_text = bch2_btree_key_cache_shrinker_to_text; return register_shrinker(&c->shrink); } void bch2_btree_key_cache_to_text(struct printbuf *out, struct btree_key_cache *c) { - pr_buf(out, "nr_freed:\t%zu\n", c->nr_freed); - pr_buf(out, "nr_keys:\t%lu\n", atomic_long_read(&c->nr_keys)); - pr_buf(out, "nr_dirty:\t%lu\n", atomic_long_read(&c->nr_dirty)); + pr_buf(out, "nr_freed: %zu", c->nr_freed); + pr_newline(out); + pr_buf(out, "nr_keys: %zu", atomic_long_read(&c->nr_keys)); + pr_newline(out); + pr_buf(out, "nr_dirty: %zu", atomic_long_read(&c->nr_dirty)); + pr_newline(out); } void bch2_btree_key_cache_exit(void)