From patchwork Fri Apr 21 10:14:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 86239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp962894vqo; Fri, 21 Apr 2023 03:26:03 -0700 (PDT) X-Google-Smtp-Source: AKy350YHNAUJuTb4jlfkFMPMqj36X4MjVoYfq/eC6VrM3Gl8HJhM+v7Y4Hmt38LACsh9/5xBkgIE X-Received: by 2002:a17:903:244a:b0:1a8:1f41:59ba with SMTP id l10-20020a170903244a00b001a81f4159bamr5221439pls.38.1682072762885; Fri, 21 Apr 2023 03:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682072762; cv=none; d=google.com; s=arc-20160816; b=YMQL1PSbcOEnAWN52Z4q7u+TYQ6sdjjIMsY1CZc14J6YIx7UkmzhTmmFCf2WHlSYpx jDeUaggDegMnEchwlmfaLT+UPNPuAEE1gjz+hrVNYbIA2tSYBDhmBKgK7jPImEjx5f3w l01enp1myc6+IBknzv3JGbh0m7UhnFUkca+mWutrPrMPSAImEUhCGN6VYGzx5UCTe1SL xyWCatARd+GvbR19P1zQMChBY4QmtXdnXA5Uw6R51BgdwfqOBVkln2lz0+Fhv5aI9nCi wO8mxKk+gpj1z73RDP4Jdy7YiAtgr+HCKSFgBZM79IfR0tK9lZEpS7HkFXdbz52GxokR n5EQ== 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=MPdsIHAkF3dojDaKePRBYhF7VPy8HOJoJzQ2IPR70Ow=; b=d9YTHBaWgFQwXmaAj6n+y4xNzeXbVMGXCU2GAxXttT+ru09qqy5tbSegnqWVWbkJmq ewxnFxd9aU3AF/nHBCui8GN6KgRh+BGwZqkZUug1q7odwYbB2ujeSX1pFyhBRyJRiHl0 +t7DWWQT5j+7W6dJLSPpXiKXnoX50PumJe51S6JI4UlaWrDu6dDy/P/LWNdJtzkppePV vTAhsNP96KCMb+vUyn/J6oCfSZ2Q1UfUR0IlydtrTyiMl8kpV5BnBxNniqc24ixsDIeI qJokBCoCuPIXcKkeAvaIdbLsHG8NxwgPpant3VSVzVlQ2ZVr18CX9bFY9NTBCgXXjHx1 de5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=DdqlQbKR; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 cp5-20020a170902e78500b001a816a7c374si2947plb.346.2023.04.21.03.25.50; Fri, 21 Apr 2023 03:26:02 -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=DdqlQbKR; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 S231592AbjDUKPG (ORCPT + 99 others); Fri, 21 Apr 2023 06:15:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbjDUKOm (ORCPT ); Fri, 21 Apr 2023 06:14:42 -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 6A5F1BBA4 for ; Fri, 21 Apr 2023 03:14:41 -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 1AD021FDDD; Fri, 21 Apr 2023 10:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1682072080; 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=MPdsIHAkF3dojDaKePRBYhF7VPy8HOJoJzQ2IPR70Ow=; b=DdqlQbKRzrk0ecb+luhX0blRgkUDuGYm7WDDLDbPi4vbYnYkhLJT1pTwGhsTuvYWAEJqri kt5QbY3sB5G4gVZ9eIoQ6+DLmEsMikliivsd9cqxZT4qwbGlwF7i+ONMsDKtZ/Y2fep0fG 7oIwPv7A4PDhJeFJjeNvR+3jlGc4xXY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1682072080; 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=MPdsIHAkF3dojDaKePRBYhF7VPy8HOJoJzQ2IPR70Ow=; b=x4vnIpaKeT0Oe6Mjy4yVpvO3QSsS3+iLzk0GjWPcysPnP0FWH94mz8RNdbfDyx1Ki8iouK v40Oc8hZwlD9BJBA== 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 BABC11390E; Fri, 21 Apr 2023 10:14:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UDFAKg5iQmRNaAAAMHmgww (envelope-from ); Fri, 21 Apr 2023 10:14:38 +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 v4 3/3] mm,page_owner: Filter out stacks by a threshold counter Date: Fri, 21 Apr 2023 12:14:15 +0200 Message-Id: <20230421101415.5734-4-osalvador@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230421101415.5734-1-osalvador@suse.de> References: <20230421101415.5734-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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1763781129054709847?= X-GMAIL-MSGID: =?utf-8?q?1763781129054709847?= 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 e1d05d9adcd1..c6b54199ea26 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -120,6 +120,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 /** diff --git a/lib/stackdepot.c b/lib/stackdepot.c index d0a4e6ac0bc9..2f1a41f0ae4f 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -502,6 +502,9 @@ static struct stack_record *stack_depot_getstack(depot_stack_handle_t handle) } #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; @@ -557,7 +560,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); @@ -570,6 +573,18 @@ 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 unsigned int stack_depot_fetch(depot_stack_handle_t handle, diff --git a/mm/page_owner.c b/mm/page_owner.c index b191ad1d41f9..daec789b0b50 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -743,6 +743,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)) { @@ -755,6 +758,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; }