From patchwork Thu Apr 21 23:48:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 12822569 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 41695C433EF for ; Thu, 21 Apr 2022 23:48:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22F476B007B; Thu, 21 Apr 2022 19:48:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E10C6B007D; Thu, 21 Apr 2022 19:48:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 009016B007E; Thu, 21 Apr 2022 19:48:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id E4EE96B007B for ; Thu, 21 Apr 2022 19:48:50 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id B8CFC120132 for ; Thu, 21 Apr 2022 23:48:50 +0000 (UTC) X-FDA: 79382528820.16.C67F7E8 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by imf21.hostedemail.com (Postfix) with ESMTP id C94FC1C0024 for ; Thu, 21 Apr 2022 23:48:48 +0000 (UTC) Received: by mail-qk1-f169.google.com with SMTP id e128so4760910qkd.7 for ; Thu, 21 Apr 2022 16:48:50 -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=iMIgPJ5erku/7c7HhXsIctg1kxrza0LuvC2QEIAcGT7wBu0OauFCACWenk2xffUDR8 XvSO6KpoUrlwK8MsoRjIvhQGG3zVynFJa5Gw7Fnwvxb3RBVaVSIlGsbNQsUo5Ggj+g2m F3zt7/xN30ltoNSguXjheaeHJTLuicb+L99c5ETzfEAHShhj8+y7XTpzRhK1h/NwV1jP 1RdSjlkCUTKXhQ+pScjWL/hQfIrvKW6R9iBUMiwKnX/QQ4H696tdz7Sf3PD2st3851z7 hwHwA2cDiSaz5zzTGDVOXyaBFkRTNpPOx/O+/F4tLvIWQswTUThlV4CaqLNTB+5KykNb ovFQ== 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=nddjw3lCYw4CJd1F53YJq3vCVJh0H/fs05BjuSlEUT+IWjpr8HBqFyKoA4T6Pi7RKF 4Q7eUc/JOBCeEQm3H6Tm4cd3lWjOq19mruYxDK0iXt4GJ1CIhmR2E8m3JQiv/Qw/Nroe yktid9/ukaxuvNGj/D1hMVjpD9TyPo77c/EFTNi96bjoJxy8m468hqWT25eYSAGhQOn1 8/2byAKa3KMm2vDZbwDp7HCRXz+eGlarIa5BTRElEesyuur2YZM+/lOqr5/9/E6ADLRY F5cJutrBUhe1Kw+T6c9b7avTYDdmZvEtMuAvvCfTy/wfSJZ5IO5RI2COD2FesEEk55Br sqHg== X-Gm-Message-State: AOAM530i+ernEPS7yPq1mBDoPymbl1FKQhRUGmH54d+7PX9v+Yw4dnq3 FCWWju26Jtjq+Q0Z8GvdGDZ4aVPr0VKi X-Google-Smtp-Source: ABdhPJxI32XeTa41Ms2HZb8peaWuFEExEtNfe16DFYhZQ/thdpSwM/dy7gUZcuantPPXtVlOJX7YeA== X-Received: by 2002:a05:620a:4488:b0:69e:bf0f:42be with SMTP id x8-20020a05620a448800b0069ebf0f42bemr1112891qkp.663.1650584929641; Thu, 21 Apr 2022 16:48:49 -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 a1-20020a05622a02c100b002f342ccc1c5sm287372qtx.72.2022.04.21.16.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 16:48:49 -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: Thu, 21 Apr 2022 19:48:28 -0400 Message-Id: <20220421234837.3629927-5-kent.overstreet@gmail.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220421234837.3629927-1-kent.overstreet@gmail.com> References: <20220421234837.3629927-1-kent.overstreet@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C94FC1C0024 X-Stat-Signature: x4ps47tqxh3jznyk8k8radg1gwki7heg Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iMIgPJ5e; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.222.169 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com X-HE-Tag: 1650584928-805271 X-Bogosity: Ham, tests=bogofilter, spamicity=0.013318, 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)