From patchwork Sat Aug 24 19:10:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13776497 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 3ED30C5320E for ; Sat, 24 Aug 2024 19:10:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBE13800EF; Sat, 24 Aug 2024 15:10:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D3BA1800EE; Sat, 24 Aug 2024 15:10:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB66E800EF; Sat, 24 Aug 2024 15:10:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9481D800EE for ; Sat, 24 Aug 2024 15:10:37 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4B2C31A081C for ; Sat, 24 Aug 2024 19:10:37 +0000 (UTC) X-FDA: 82488080514.30.3BA0530 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) by imf03.hostedemail.com (Postfix) with ESMTP id 1758D20007 for ; Sat, 24 Aug 2024 19:10:34 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mCLuZi00; spf=pass (imf03.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.178 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724526593; a=rsa-sha256; cv=none; b=1HEnPPbBp7twTFsCpP8d65++Fy1Tg8Nwl7d8LD73e3sQZc6eufC22P8PZckm8F2la7eUrC FnfGVzAm0dU2vAr3DY0qVj36vASRW9K5fcmkiGbHUi79fBK3tP8jqrqwCEOTLxKtd3m11f ARX4iIpXqVyQb9y8RFiJ9N2gyZaJk3I= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mCLuZi00; spf=pass (imf03.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.178 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724526593; 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=zKBGRtsPyUvtp5wY3XaRsK5eF/sYhIfHRSgUQREqSSc=; b=r5BQMmT3iGCyrBgUzyaAWnh7DJnC7FckA14PPCKbNCbPbZkDKRmVfkTnRvEbWGSFE/X3hw H2q4qfJnCSGC6RbhNvbgyT1hzCfULy7c0vYHjCwylV1T+Rb2W5QzbjT+7Vknp7x3gDr9A7 ykIF8KoBD4rS3wkgM3ySbHOiGUpYCrk= 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=1724526633; 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=zKBGRtsPyUvtp5wY3XaRsK5eF/sYhIfHRSgUQREqSSc=; b=mCLuZi006yPmOyvt4ug0F4H1yPxKHuV9w05Ji8hemfGYpuf7LzRQHiP+mDAQOJd31WpCHF A33rHCZsgG1Pu04hRLc9VGB3RSXW3BcUNa5eYsPdzVsl04tag5XniOIN+/gE/SXw8dJrJ2 vqZXONnqFtGa2PzU4Y6k31vMpVt0cu8= From: Kent Overstreet To: david@fromorbit.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: Kent Overstreet Subject: [PATCH 06/10] bcachefs: shrinker.to_text() methods Date: Sat, 24 Aug 2024 15:10:13 -0400 Message-ID: <20240824191020.3170516-7-kent.overstreet@linux.dev> In-Reply-To: <20240824191020.3170516-1-kent.overstreet@linux.dev> References: <20240824191020.3170516-1-kent.overstreet@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 6xx911q9sfc7q61zx47m6fdmmz1uyb1n X-Rspamd-Queue-Id: 1758D20007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724526634-730566 X-HE-Meta: U2FsdGVkX1/dQmpTwQtJBSfnc4vClYqiSttaI+2Uw1NT73SubeFtgXt4vwYwnNvQw5OX9tapQh6kLi2kdwh+E4sRx3M7HLXEDm5gUIrPzauyFzRx2vo1imz9pirDHch9oAF6NVzjS0X2Xl/cLlmYQX5ZD7GE6cg8wlXqKJZelO8MAGayoCt2yZ4LRgIZcq3R3zHm4LrzpPMVPLDPHtBMLuZXIYy117WZl9ZY78gExuYD/oGVsxCEe2zX3+SRHeBj2tJcESF9N9Oanj7Nl2aQHuQBJKjqktYn141L+fGGxd90b8z9PZ9/idJD50slONb/uRC9+fpjIk4zNj8s2SO2tr3jarJsvO2AdRmpmzH3DWsUTfTAp7UkdicHQ+WL+moeCl0vbQuGPLt6QhCnsCYRn15dRhOovhN+GPsHaASEiwhmbQa37pNJ31wQUMSz1f0t9JYI9k+X0H70O0v4+zTpGplf/0MunsnAvln2T//BoZWQoGAd6t2JdqggBdeqpKZ9GguqgnFbbrrQA555T1cnwGkBftZUvWqgMrd0dkEOC4n+CHUSTH0mNg2S6ixFYLfu1WVQwplswlHtacaNLJh7d/h19j2T3LZkN9Rms3DdY+3/aM2FgN6EQWVhjGklIx8ScJKxo1QL4X7TsVWLPKKQ1CMXNVV3SETjc/NU989pYSMbY3r/yV8+u1pCqLUPWmC3B63wda1OGigLe7FlkkT1WWUR9+4Sw1qnSBs7GV/IQ5N0m84hLNvN2tqUU+1k//fLRCIvQhJUtNhldVzRydJXs3qlclCI6uGBmTZM4H5E7eAzML/J2YMNM6Q0CHjKnaZGmWTNUoUDvmojTGn9EzYtB6MczLmxqxgLjlsHO3e8wZiGVQkj4vaxh5HaeidPtlLuyXIQjckr0rF2orejlwZNOLXgPWwZVXfIFNlBJWlD+Ac890LLvEs0E9/7PnCcPQR2NvhIbAAD1pW5WShn1MW dgFxU7m3 3lfLBH9E6vXTbfjba4bUluoJoyCjIUl137UzfhyZoTBmXSU+i+63nMs/bmuuG7S7JwYiuLelLZA7HOmdAnnwScFTrrOTdElOegEy9FUhvEtqcx2lzlsTk/59v9JvwK/ZSB7FGJBCHC+zkdXjGbdNBeguhMYxNekwOV5VK 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 662f0f79b7af..9f096fdcaf9a 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -15,6 +15,7 @@ #include #include +#include #define BTREE_CACHE_NOT_FREED_INCREMENT(counter) \ do { \ @@ -487,6 +488,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->btree_cache); + seq_buf_commit(s, out.pos); +} + void bch2_fs_btree_cache_exit(struct bch_fs *c) { struct btree_cache *bc = &c->btree_cache; @@ -570,6 +582,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 2e49ca71194f..af84516fb607 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) { @@ -746,6 +747,18 @@ void bch2_fs_btree_key_cache_init_early(struct btree_key_cache *c) { } +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); @@ -770,6 +783,7 @@ int bch2_fs_btree_key_cache_init(struct btree_key_cache *bc) bc->shrink = shrink; 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->batch = 1 << 14; shrink->seeks = 0; shrink->private_data = c;