From patchwork Fri Nov 4 09:33:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13031546 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 B8FDAC4332F for ; Fri, 4 Nov 2022 09:34:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 528058E0005; Fri, 4 Nov 2022 05:34:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B1EB8E0002; Fri, 4 Nov 2022 05:34:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32AB28E0005; Fri, 4 Nov 2022 05:34:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 16E698E0002 for ; Fri, 4 Nov 2022 05:34:18 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BE6DEC145A for ; Fri, 4 Nov 2022 09:34:17 +0000 (UTC) X-FDA: 80095248954.07.F217E9E Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf22.hostedemail.com (Postfix) with ESMTP id 29D2EC0005 for ; Fri, 4 Nov 2022 09:34:16 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EF5191F8C8; Fri, 4 Nov 2022 09:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1667554455; 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=uL2I7PHjAFL8wwyrnZLGiRmIfuUYeK00tu0Z3hdbT3k=; b=DUQ8gDjB3AbF7aAFYp3cf73rrg7rxISxQVeKrFk9UMeDmSEnJr0x88quAbrXTReruO23Up nGm6Us5KaFkT3xbbaotZldg3Se0q9CkRtBsQuFiSzTroeGdXfyizEkFCh9Pj20vRO61zep ruzmGb6fhZm1+EgfQxmnZoe9I7tMMmI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1667554455; 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=uL2I7PHjAFL8wwyrnZLGiRmIfuUYeK00tu0Z3hdbT3k=; b=8gpZar+FBkFd8Tjn016GU3FcGMaGjV6S9jhIbQtaLCw+FxLyOi665XxaLoCzzVIcFUOHhV ej1iy+tCaLfJ3rBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1DB401346F; Fri, 4 Nov 2022 09:34:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MJNsApXcZGP3BQAAMHmgww (envelope-from ); Fri, 04 Nov 2022 09:34:13 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Eric Dumazet , Waiman Long , Suren Baghdasaryan , Marco Elver , Andrey Konovalov , Alexander Potapenko , Oscar Salvador Subject: [PATCH v3 3/3] mm,page_owner: Filter out stacks by a threshold counter Date: Fri, 4 Nov 2022 10:33:54 +0100 Message-Id: <20221104093354.6218-4-osalvador@suse.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221104093354.6218-1-osalvador@suse.de> References: <20221104093354.6218-1-osalvador@suse.de> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=DUQ8gDjB; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=8gpZar+F; spf=pass (imf22.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.29 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=1667554457; a=rsa-sha256; cv=none; b=raOOsuD7fyfURFPK4PBnaCdiaU1MCjs+v3wpkXLdYHAeBAke90f/urMoiFy2sLjzsAkmX9 fhq+pdoJFS0jD7x2Ika4EPqcztkAjCy7sDhCqjNMnnJA7raEohmDlkm3xzI9dnSkBcwyK5 5lagvT1bC2TnGszvryFw6Xfk4eM7MUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667554457; 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=uL2I7PHjAFL8wwyrnZLGiRmIfuUYeK00tu0Z3hdbT3k=; b=Q2dnAhRPHt+7Mvak9O0k93RQvu6YCnJXReSTUdAIXusNVaQdpzS+ONiyuc1S8J7CFWkcGG Q27z+D0/3O2n+flYjm8TAX3YSPuwpAOL3HQIVOX0yPWD7TWbhA40vxTz6Xd2tRReTKqNOc wwwFbjNtIQ3ib03SmGlqVBozZuEIsbs= X-Stat-Signature: 5ra5yh7ea7h7n4unpotcrqny5enahtb7 X-Rspamd-Queue-Id: 29D2EC0005 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=DUQ8gDjB; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=8gpZar+F; spf=pass (imf22.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de X-Rspamd-Server: rspam03 X-Rspam-User: X-HE-Tag: 1667554456-705632 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: We want to be able to filter out the output on a threshold basis, in this way we can get rid of a lot of noise and focus only on those stacks which have an allegedly high counter. We can control the threshold value by a new file called 'page_owner_threshold', which is 0 by default. Signed-off-by: Oscar Salvador --- include/linux/stackdepot.h | 3 +++ lib/stackdepot.c | 17 ++++++++++++++++- mm/page_owner.c | 5 +++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index ca048a79bf7c..c998b8024534 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -70,6 +70,9 @@ depot_stack_handle_t stack_depot_save_action(unsigned long *entries, void *stack_start(struct seq_file *m, loff_t *ppos); void *stack_next(struct seq_file *m, void *v, loff_t *ppos); int stack_print(struct seq_file *m, void *v); + +int page_owner_threshold_get(void *data, u64 *val); +int page_owner_threshold_set(void *data, u64 val); #endif unsigned int stack_depot_fetch(depot_stack_handle_t handle, diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 97e5dce40f4b..b70d081d7c61 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -569,6 +569,9 @@ depot_stack_handle_t stack_depot_save_action(unsigned long *entries, EXPORT_SYMBOL_GPL(stack_depot_save_action); #ifdef CONFIG_PAGE_OWNER + +static unsigned long page_owner_stack_threshold = 0; + void *stack_start(struct seq_file *m, loff_t *ppos) { unsigned long *table = m->private; @@ -624,7 +627,7 @@ int stack_print(struct seq_file *m, void *v) if (!stack->size || stack->size < 0 || stack->size > PAGE_SIZE || stack->handle.valid != 1 || - refcount_read(&stack->count) < 1) + refcount_read(&stack->count) < page_owner_stack_threshold) return 0; buf = kzalloc(PAGE_SIZE, GFP_KERNEL); @@ -637,4 +640,16 @@ int stack_print(struct seq_file *m, void *v) return 0; } + +int page_owner_threshold_get(void *data, u64 *val) +{ + *val = page_owner_stack_threshold; + return 0; +} + +int page_owner_threshold_set(void *data, u64 val) +{ + page_owner_stack_threshold = val; + return 0; +} #endif diff --git a/mm/page_owner.c b/mm/page_owner.c index 3808c0985060..3e05ebd25ba0 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -694,6 +694,9 @@ const struct file_operations page_owner_stack_operations = { .release = seq_release, }; +DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get, + &page_owner_threshold_set, "%lu"); + static int __init pageowner_init(void) { if (!static_branch_unlikely(&page_owner_inited)) { @@ -706,6 +709,8 @@ static int __init pageowner_init(void) debugfs_create_file("page_owner_stacks", S_IRUSR, NULL, NULL, &page_owner_stack_operations); + debugfs_create_file("page_owner_threshold", 0600, NULL, NULL, + &proc_page_owner_threshold); return 0; }