Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp259264rdd; Wed, 22 Nov 2023 15:25:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqLdItLEAjFXFvICnwwNcxkSHGiBZYAOHPmuCt8jlt9hb+xk188ixrY/bZTp3ab6g58vj5 X-Received: by 2002:a17:90b:1646:b0:285:e7d:88ef with SMTP id il6-20020a17090b164600b002850e7d88efmr4288692pjb.23.1700695553323; Wed, 22 Nov 2023 15:25:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700695553; cv=none; d=google.com; s=arc-20160816; b=zY6B9LH6oGhkDn3bDXGVpYyitRT42RRgxMHvDcF3zzph17Y5IzQFEUEVjPhLiQg9F1 ROGQ2ZUR/x06KUr+h7HhXAR0pg6Q8dFBJdZ+6gjMgCO6+WSJXvFzPtfL+Z+KTy9b/Zi3 6LNFp13N1NRusCheMfFAxoQptH9hFa85wYc3PPvKYQ6I1G0Fc5sacR4SSrh74oeQBE/M 5MsK+XH+/9rFyczFkinGS7NitP8Vhn65ElxUzraBPdOVEm0j+XfTyrmwHre2luRyqQNF cepvQ8x0oLKNt75Jmeo0/DNjv61vduVKGZoPr77Lw0KSIgjTjQWJFCD5Cp5gJHGbNL+s qjKQ== 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=hhFyhh1rGVdN8KU7zA1YO/xWC9r61TLiUr+vYD/9YWg=; fh=E4i1WlDjTcv4PaggG9LiH5M0StK1kb2o4G2+VCXOoG0=; b=mlGvur/dw0QrPCFFJV9fMDtARE+CuYYr7cRDBCgETE/eOUBl0NpJaGTtWVX6+9WKlM TG9Ap8+79ZzmoZywYZasbdDgC7/oGi0pYCz9+Gqq6Nr+LV46KdK5pD4X1jFq6E29MAdQ tyIXzNyHDyRVdmgHVpMaj0TR8CZBRU6XRI9eJiZiBs3RjkFfOeRYc9AxraF5USewgM1F b7Bnd17dXMqrAxN7fv++lf3NuWNFdYJ+qoE0bdnK6Yk7Aej9msp85QkwGDhcF5WoO0qs 0/FQhOuHFUaw+lUmGQEsaou2CaoKkQUoO+blheuU5GcMvBRucCSxNBGKDMjTPYtnmUV3 Sw5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=BHd1Y+nn; 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 s63-20020a17090a69c500b0028515f9b7d1si93479pjj.168.2023.11.22.15.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 15:25:53 -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=BHd1Y+nn; 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 226138280D64; Wed, 22 Nov 2023 15:25:48 -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 S1344564AbjKVXZp (ORCPT + 99 others); Wed, 22 Nov 2023 18:25:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344558AbjKVXZf (ORCPT ); Wed, 22 Nov 2023 18:25:35 -0500 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6286419D 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=1700695529; 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=hhFyhh1rGVdN8KU7zA1YO/xWC9r61TLiUr+vYD/9YWg=; b=BHd1Y+nn87jfgs0JPV5W9mQnj/jbSljivlaWBWB01hjhj/kWczcqBvz5Z6L0HpvjZCtsmd /dVQdVskpae/TXe1lhJkyqwhQBEja9RxyeQj/qFWuwDRlz1zUC1oNymeFeLzQPPjOqHaw5 +p/p0qYljzIyMnmljGtQZZIcQd8+3JE= From: Kent Overstreet To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Kent Overstreet Subject: [PATCH 5/7] mm: shrinker: Add shrinker_to_text() to debugfs interface Date: Wed, 22 Nov 2023 18:25:10 -0500 Message-ID: <20231122232515.177833-6-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,RCVD_IN_DNSWL_BLOCKED, 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:48 -0800 (PST) Previously, we added shrinker_to_text() and hooked it up to the OOM report - now, the same report is available via debugfs. Signed-off-by: Kent Overstreet --- include/linux/shrinker.h | 1 + mm/shrinker_debug.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h index 497a7e8e348c..b8e57afabbcc 100644 --- a/include/linux/shrinker.h +++ b/include/linux/shrinker.h @@ -143,6 +143,7 @@ __printf(2, 3) struct shrinker *shrinker_alloc(unsigned int flags, const char *fmt, ...); void shrinker_register(struct shrinker *shrinker); void shrinker_free(struct shrinker *shrinker); +void shrinker_to_text(struct seq_buf *, struct shrinker *); void shrinkers_to_text(struct seq_buf *); static inline bool shrinker_try_get(struct shrinker *shrinker) diff --git a/mm/shrinker_debug.c b/mm/shrinker_debug.c index 12ea5486a3e9..39342aa9f4ca 100644 --- a/mm/shrinker_debug.c +++ b/mm/shrinker_debug.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -159,6 +160,21 @@ static const struct file_operations shrinker_debugfs_scan_fops = { .write = shrinker_debugfs_scan_write, }; +static int shrinker_debugfs_report_show(struct seq_file *m, void *v) +{ + struct shrinker *shrinker = m->private; + char *bufp; + size_t buflen = seq_get_buf(m, &bufp); + struct seq_buf out; + + seq_buf_init(&out, bufp, buflen); + shrinker_to_text(&out, shrinker); + seq_commit(m, seq_buf_used(&out)); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(shrinker_debugfs_report); + int shrinker_debugfs_add(struct shrinker *shrinker) { struct dentry *entry; @@ -190,6 +206,8 @@ int shrinker_debugfs_add(struct shrinker *shrinker) &shrinker_debugfs_count_fops); debugfs_create_file("scan", 0220, entry, shrinker, &shrinker_debugfs_scan_fops); + debugfs_create_file("report", 0440, entry, shrinker, + &shrinker_debugfs_report_fops); return 0; } -- 2.42.0