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: 15443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp278242wru; Fri, 4 Nov 2022 02:37:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67Sn3lfO2KsBKmOGiWM1BiSXJTIeP/i1IcYfsOT7RllliwkiZwrd2vQDCjchX9CwDaEMQh X-Received: by 2002:a65:6d1a:0:b0:3fb:2109:7b87 with SMTP id bf26-20020a656d1a000000b003fb21097b87mr14661403pgb.127.1667554655302; Fri, 04 Nov 2022 02:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667554655; cv=none; d=google.com; s=arc-20160816; b=eU6m8RqaVwF+e35+zWil7MDVYXcrnfAfk0WexQgeQ8Vult1jblCw8koPGLYZPSc42s X2jFxpHdcqt0W8u9Xw5Mj4/BPbs/tcpxfbtwL9qZxfbYFJKrFL+bBLS23uhbjZM8jzwD 9iYfQ0rzA8zckvivWaDK1dSpRvPaBBluLzFTQygwhvrFiqNekUR1e9Bca6+SxHi8hNTs 1OIWKz2rR0lvRRqt6X3+21A5xY7t2aBlof/xmtvS3hNC7ZF0upi0KZyOrmZleXHH3Z9L CXIVJvjkDeP9jimTYGI8DPbmElxEhzB0GhGj7gGbjUgBsLMZRalO2kxTyXTiEHOi5NnS R9bA== 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:dkim-signature; bh=uL2I7PHjAFL8wwyrnZLGiRmIfuUYeK00tu0Z3hdbT3k=; b=H5+B4CeFHbjnDnPzoPhNxNJawD1ziy5wkDEDB2ma+QBoYsF1/ul5q3fy+P2zy4BA5f z0A5c6o6XLwJoyIiBS6Hu5JFoGSUpbxzRjZy1Hzx2+tGGX58TVVlBhzw5yhDfXRBMFun D9IT42fURDisClWiNRSDWWc/w29lUOJEvb5yxA7quUNUh65VK9CnYbHPs5KAj6uzPvnY 3C+fbHuJ5xPj15797XtpYSAMSadUzschQEJ8iAP6B5JIHwIB1V+AhxX1HNo5yprSApAv 1dZuHvkXUWOOT9uQyQP20hTgOO0bMbDmQYCl36Wcz0bNlQPis7JJcWaES0wn2VZlBqQ1 p9dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=DUQ8gDjB; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=8gpZar+F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x64-20020a638643000000b0046f94467a3bsi4281409pgd.76.2022.11.04.02.37.21; Fri, 04 Nov 2022 02:37:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=DUQ8gDjB; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=8gpZar+F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231596AbiKDJe2 (ORCPT + 99 others); Fri, 4 Nov 2022 05:34:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231511AbiKDJeX (ORCPT ); Fri, 4 Nov 2022 05:34:23 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84E4A26565 for ; Fri, 4 Nov 2022 02:34:17 -0700 (PDT) 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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748557790030986040?= X-GMAIL-MSGID: =?utf-8?q?1748557790030986040?= 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; }