From patchwork Wed Feb 14 17:01:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13556794 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 34EFCC48BC3 for ; Wed, 14 Feb 2024 17:01:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB5B46B00AD; Wed, 14 Feb 2024 12:01:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D41C36B00AE; Wed, 14 Feb 2024 12:01:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B915D6B00AF; Wed, 14 Feb 2024 12:01:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9C1246B00AD for ; Wed, 14 Feb 2024 12:01:04 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6386FC0DFD for ; Wed, 14 Feb 2024 17:01:04 +0000 (UTC) X-FDA: 81791024448.09.AD5A3F5 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf05.hostedemail.com (Postfix) with ESMTP id CCE8A100016 for ; Wed, 14 Feb 2024 17:01:01 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=zes+YGlv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=86Scdmj0; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=zes+YGlv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=86Scdmj0; spf=pass (imf05.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707930062; a=rsa-sha256; cv=none; b=JB+LIDO2fC1tUwnQ3xO32C/+3nRO0Ps4O0pQ7g6Z0W2FJxbbzvFVYAWgZeapB6WqaFNh3W ugTwJWLe6t5wpEzmyxqclGteGRoNmvs7pfaAALoVstJ7x4V7AH5fVRaKnDaShw5t0avxfF SEmV/w7mFhUWwUWNgMNcA7hOPj7tqF4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=zes+YGlv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=86Scdmj0; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=zes+YGlv; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=86Scdmj0; spf=pass (imf05.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707930062; 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=O95gSBj24arVN2KSdkLlOTusRHAm3etcuM3qAIyUVjc=; b=kAWZ0gEa8Xv/zKtpYHhNiDrjscvThI2S2Qp19IkT7ZjqXLgxijU61LbpWkMeySm2h/Bj7R 3RHYXZfCE1V6Dsm1YkThExHBMpRs9cf8l0do7Sn4dyGaOWNojfvm1K21EULYN744QvVW/J InWTCuOxE58PLYSF9U9C13L4kJQ7PCM= Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 021331FD29; Wed, 14 Feb 2024 17:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707930060; h=from:from:reply-to: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=O95gSBj24arVN2KSdkLlOTusRHAm3etcuM3qAIyUVjc=; b=zes+YGlvv/bao0zBIXw9Zxr3DdFVNNTRtDV+b2DD6ZqBt31dljhlZLxxPY6JnRnX/dH7Xv lEAx+JMFrM4BvoMIy5uOjmUu716LBBjYkxy3CFeOGWBCNZNDaErMrY7hpTM+OPtX0ZDRUY f2rmdN5751tBiBl7y/ifA6uZR7yZV0A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707930060; h=from:from:reply-to: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=O95gSBj24arVN2KSdkLlOTusRHAm3etcuM3qAIyUVjc=; b=86Scdmj0zPg4HuR75wAYrOc+P1+yRbV5BQV4UvtPgV/1ChGWvJVWeFILHJ7iJDt92UFN0g gTkTbDvL+T/TvACA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707930060; h=from:from:reply-to: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=O95gSBj24arVN2KSdkLlOTusRHAm3etcuM3qAIyUVjc=; b=zes+YGlvv/bao0zBIXw9Zxr3DdFVNNTRtDV+b2DD6ZqBt31dljhlZLxxPY6JnRnX/dH7Xv lEAx+JMFrM4BvoMIy5uOjmUu716LBBjYkxy3CFeOGWBCNZNDaErMrY7hpTM+OPtX0ZDRUY f2rmdN5751tBiBl7y/ifA6uZR7yZV0A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707930060; h=from:from:reply-to: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=O95gSBj24arVN2KSdkLlOTusRHAm3etcuM3qAIyUVjc=; b=86Scdmj0zPg4HuR75wAYrOc+P1+yRbV5BQV4UvtPgV/1ChGWvJVWeFILHJ7iJDt92UFN0g gTkTbDvL+T/TvACA== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 7536B13A0B; Wed, 14 Feb 2024 17:00:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id MFb7GcvxzGUfMwAAn2gu4w (envelope-from ); Wed, 14 Feb 2024 17:00:59 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Marco Elver , Andrey Konovalov , Alexander Potapenko , Oscar Salvador Subject: [PATCH v9 6/7] mm,page_owner: Filter out stacks by a threshold Date: Wed, 14 Feb 2024 18:01:56 +0100 Message-ID: <20240214170157.17530-7-osalvador@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240214170157.17530-1-osalvador@suse.de> References: <20240214170157.17530-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: CCE8A100016 X-Stat-Signature: frr15odwqawgmhxfkibs47jqshhhmhcf X-Rspam-User: X-HE-Tag: 1707930061-719050 X-HE-Meta: U2FsdG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3soZKEJYdoePkp/b7eprqf67aztNMtQXPss4DzCjMpBkLyg4MLAluKcazwn1UDs0M9HWpVDNixVayk61s7xA/8ZZ3jhDjR78pWuOPtwpXx3NgdnB6xzgI6BEf1WrjbDeUWVSeUHJ7swVP0JeuAXgm+CVhlgBwll4mTap0N61T 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: We want to be able to filter out the stacks based on a threshold we can can tune. By writing to 'count_threshold' file, we can adjust the threshold value. Signed-off-by: Oscar Salvador Reviewed-by: Vlastimil Babka --- mm/page_owner.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index 5258a417f4d1..9b975f59b773 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -846,9 +846,11 @@ static void *stack_next(struct seq_file *m, void *v, loff_t *ppos) return stack; } +static unsigned long page_owner_stack_threshold; + static int stack_print(struct seq_file *m, void *v) { - int i; + int i, stack_count; struct stack *stack = v; unsigned long *entries; unsigned long nr_entries; @@ -856,14 +858,15 @@ static int stack_print(struct seq_file *m, void *v) nr_entries = stack_record->size; entries = stack_record->entries; + stack_count = refcount_read(&stack_record->count); - if (!nr_entries || nr_entries < 0 || - refcount_read(&stack_record->count) < 2) + if (!nr_entries || nr_entries < 0 || stack_count < 2 || + stack_count < page_owner_stack_threshold) return 0; for (i = 0; i < nr_entries; i++) seq_printf(m, " %pS\n", (void *)entries[i]); - seq_printf(m, "stack_count: %d\n\n", refcount_read(&stack_record->count)); + seq_printf(m, "stack_count: %d\n\n", stack_count); return 0; } @@ -891,6 +894,22 @@ static const struct file_operations page_owner_stack_operations = { .release = seq_release, }; +static int page_owner_threshold_get(void *data, u64 *val) +{ + *val = READ_ONCE(page_owner_stack_threshold); + return 0; +} + +static int page_owner_threshold_set(void *data, u64 val) +{ + WRITE_ONCE(page_owner_stack_threshold, val); + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get, + &page_owner_threshold_set, "%llu"); + + static int __init pageowner_init(void) { struct dentry *dir; @@ -905,6 +924,8 @@ static int __init pageowner_init(void) dir = debugfs_create_dir("page_owner_stacks", NULL); debugfs_create_file("show_stacks", 0400, dir, NULL, &page_owner_stack_operations); + debugfs_create_file("count_threshold", 0600, dir, NULL, + &proc_page_owner_threshold); return 0; }