Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp259222rdd; Wed, 22 Nov 2023 15:25:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/HC4XSIAKMhMZ/pOrHGfOwAvKG1TOCmkKzS23w9JrEIRbd2U5CffZ7QFg7If9sYTs1JvL X-Received: by 2002:a17:902:e5c2:b0:1cc:43af:f568 with SMTP id u2-20020a170902e5c200b001cc43aff568mr3777521plf.6.1700695548327; Wed, 22 Nov 2023 15:25:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700695548; cv=none; d=google.com; s=arc-20160816; b=F6ISNk+VmdkGAZvW59VjwUCiosshlzRw1Sqg6oB43kuYtBhAhA/meq8gumLqriPFil Bt2u0hxIaWwaL605yFvaLvS+beWEzDyTSyZfYrC29vT7VwePkn0L85xarmYyA59zyB9Z Mi28IBc8VDBDfBfVH0XJnspRhZj1LRlkwsOwQufHmv4WQwHPNW7Arb557sW/ok5NBHmr kaE0QbF32F211/la1ALoFlYOmDpI+JY5qnkSLNW1JqbovY5bAnwRWe0JBpjjFyrRKjqD Ze04Zwxe5X5/6p5Yne2t//ob1ror4W8yYpQmkAzVj86mLU/UPGkv157vPd7Wnc4PzuVH FRxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+xIe2DoE21qrt9LSNcAUwIwIwHsNrxaH9AQLMP04McM=; fh=E4i1WlDjTcv4PaggG9LiH5M0StK1kb2o4G2+VCXOoG0=; b=OQxMwZceMy4nz2bgIF97BA5un62XYcADh0wOn43E7NZq6A1qm9exn1XWXZLaCrgfY5 GyfhdfZ9UV8+/G4tbFvYSKhmFFeaJ4w7/SGftdz2V9jUFg3Ehwlw/FCW2Bwmn/ktyVR7 BlxXdGsiO7XDDjz3RJVWiVqj44au164AFE0NntZHAx0HY3fUDiVuSU0sigdMiBx4T7K5 Vr18bLv7ADi4a+w5j5MwCKQ7VzY+6KkuoyOrMzeX2fCNIW9CHQobif+naBWeDPahABod l+p54z7qS98I8FieKZ2oeqIkKX+XiltCQgb3c8MYaQBQArg4hJkzttNBVz+KyPeXqAPo 2V4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="o3CvX/g1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id k11-20020a170902c40b00b001cf64a69c81si429155plk.466.2023.11.22.15.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 15:25:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="o3CvX/g1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7B3F08280D4F; Wed, 22 Nov 2023 15:25:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235194AbjKVXZn (ORCPT + 99 others); Wed, 22 Nov 2023 18:25:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344564AbjKVXZg (ORCPT ); Wed, 22 Nov 2023 18:25:36 -0500 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D21251AB for ; Wed, 22 Nov 2023 15:25:31 -0800 (PST) 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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 15:25:45 -0800 (PST) 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; -- 2.42.0