From patchwork Wed Nov 22 23:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13465562 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 6CC75C61D9C for ; Wed, 22 Nov 2023 23:25:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 275206B05F0; Wed, 22 Nov 2023 18:25:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F7156B05F1; Wed, 22 Nov 2023 18:25:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EECE56B05F2; Wed, 22 Nov 2023 18:25:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D7CA86B05F0 for ; Wed, 22 Nov 2023 18:25:32 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A6D2B12095E for ; Wed, 22 Nov 2023 23:25:32 +0000 (UTC) X-FDA: 81487174104.23.77950BF Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) by imf13.hostedemail.com (Postfix) with ESMTP id 0937B2000F for ; Wed, 22 Nov 2023 23:25:30 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=BHd1Y+nn; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf13.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.174 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700695531; 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=hhFyhh1rGVdN8KU7zA1YO/xWC9r61TLiUr+vYD/9YWg=; b=w4uheNnnZRxyBNYyl2ETPya6ooqTPOaFfR+7axZSRZxaJj0Gr/mXZ+g/dbh3BdaACCJB6I hDabmYjn5H2XCxBKHoM6fjC4wWGKC+HCR3wBkVvMwlls0OhBnRceD9KZpgelnK7N3aRO60 j5GpY75jsJwIa2zsz8qbhNgT0tkvvV0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=BHd1Y+nn; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf13.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.174 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700695531; a=rsa-sha256; cv=none; b=CBAS1dLgZs1/J5wd2nqB7YN/LB1lD2yPrKgB+kGmhFRfd4KVCkTQvVR6Z8cbbGl6eaOrZ+ c6rKOMRD0SDMGZV/Qr6GLQ2AUxP7WFOl1xVmnv3Y55Bb6y87t70x+qoe4hREg4o0k4xSR6 ScOvUmUOiP6piFZwOfgxv29AlqqXmVw= 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 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 0937B2000F X-Stat-Signature: wiceznx85tp9aqnyhpssqpt7bn4nbxu3 X-Rspam-User: X-HE-Tag: 1700695530-626814 X-HE-Meta: U2FsdGVkX18bzcxfMw/PAMGmNkq7kk8IdYTSDGPlseO5UC4J5xRAjgsNzqgIFK25dsvmAn04SxOqeTRKdvZ202rDHQ5KcEp1bOzPXUouxRhzNHpGhneewze7xErw+H+zxuESdJW78iXRSvNas8V9Ej5Eept0yzfoNMl94oCiAnHAjKPJkjNaRDCOCaf6r6NZvji8lAT/6NNpJ0bFRCODIAkSHBw2O3t3FBAa6rMcdKbUUWa/ISuTFiRXMTdudvKSuvBsYU4CcNUlLyDbm+6/F/MHbs3iyzargT7cyJrwJS0qTJ+0W/pfC8z1FdHoOOf3Q7CLaIGN+Zy2r95zMM+V0FyJMk1ar9F51yPhYNbX9IPTOw5jyyJq6RkNqCYswP8Ce/vb0a2x0RHLyV5bxeiVSm3blujxBoAn3764l8lZFM0crpcIiE8QXKSCmONwgNxk971og7XSobyMmhivzIFhyl0k97OjtaHZRaKE87Ros33eKsTs5mIR1Esv5PssEOIwYYmrvWzh04r47Yx5K3yOP9j9i3D3yHgwNEJJL3OhEE7ld4WthKblLuxdFN+UTJU7EsEWwkvlDtoxBzXiC7HYEIGiO0tKPiwD8ykiLc0g69F7QYynQw5eh/znxBqqM/7clEfrf6m70Sy4NEaRSHuOa3wr3OfJlqLVCaCYhkTC1F+lNQ1EC6gHOeejEXmB1tWYo/FLe2AIng4vBhDjAS7qDrXyLTYMp+IiI8tnwsUs8bvJoVFgdbVDqiA4ZV2A0uIV7HvkERiUVTDktvfI8vJkHy5Wd7EgfWdMBH7l+gVg5I1oz1IKUaIFr3swRgpDoXqpGkJ89ibSdOu9NTqDKBTQzxj/75QyCC0bMISmrLkCgkDmGLF7ga3CZ29KK4LlbURvr0YHuUGaxSeOu7We/6Gz5aSHdULtfVYKkC7ee1ZsDgbYztIpay9Vtt8I9ghcGLDkz1ALorkrHNhjCPIosgd re7C2bhN C6cf3pYzNqW3LO3tSl2iUI2AJ9PTOjt8ZtxT3cl/mB12UpEhn/bHnaYkRelA34EMOuEmdYvZu5hIntOgRFWUnvb5oqRfuypU6SIYDGc7tBncPg2xhF4kfMZqOubCxmsSlYLIn 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: 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; }