Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1099193rwd; Tue, 16 May 2023 11:47:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4fQMeyJFNajpqKiPYz07yIYYL5FGtRHtB8P1A0ndhVNiDevyoPBf71+o8h4FkQfaBi2H5A X-Received: by 2002:a05:6a00:1a45:b0:643:9e7c:3829 with SMTP id h5-20020a056a001a4500b006439e7c3829mr46311373pfv.12.1684262826050; Tue, 16 May 2023 11:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684262826; cv=none; d=google.com; s=arc-20160816; b=VpTDlOMgSusSzuECO0k+1ht4t7PCzbHQQns6i1WUE5ppEk2bhGxDooF/kaG3nCCFtK l8Ap2QleGq3K5XWYbT2UpB7m/xIZVEzb3w3ga7bMLA5fPJTKKTrliY0l5MmtYZcqObY/ mB6/eCQ9cEL6c81JVQxs29+4k94oiFouwVzJhF45Yfo18/FpL2JTfa0kQrRw1rYr4yJ2 AllKSxtgGAPnDxGmuTN2sUFeP6K9el9pwT8sBd0usucga/r0EFL78vx9kfyUcfyXAveT ZAWyFB2bHhOQXoeE7ERI3QhntfLHfy3Rs7KxYYWi2++bAyK8+iaoEeYKN1O238IPkTjV qcqQ== 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=rnEOKM6Uzt/actmg7zEiIw7A6rReXqMZszIGv86v3Sc=; b=j8JnDsFNJBAzuVVrpKM2QreJfQcLv0O9Y7qD+wqQMluX1kmoNOVprSprfr8KcI4jBT V5ZeFQKioO9XCRXt/QyGFDnCO8FwdHjibYsH/JTaw0MPX+Eg5XygWMbjml6kmAN2JYcR NSDlcUnHXBiSxnk39jlcLlvRFZi4vJ8jiDJeoEkZbOquoCCg5ej0GnHjQ/C6nhOR9nYf GDJIbZJlZm8VirfvTuuZKpU1HjTQsMTEAutR6UJ+ZiHr4/vSddYT8AMzzKCu33G+L9Jj qDNDaHkeTACIwcjL37BKbVuXSzXFlVo5GPB+P2bn/RIHQBG61u0AMbS+ii63YRo/tSCb 0nwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=hVKBHkEf; dkim=neutral (no key) header.i=@suse.de header.b=tm91uIeD; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w5-20020aa79545000000b0063b652ff9cdsi19840303pfq.404.2023.05.16.11.46.52; Tue, 16 May 2023 11:47:06 -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=hVKBHkEf; dkim=neutral (no key) header.i=@suse.de header.b=tm91uIeD; 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 S231944AbjEPS0F (ORCPT + 99 others); Tue, 16 May 2023 14:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232088AbjEPSZy (ORCPT ); Tue, 16 May 2023 14:25:54 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F32066E9D for ; Tue, 16 May 2023 11:25:52 -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-out1.suse.de (Postfix) with ESMTPS id 9BBCC21FC4; Tue, 16 May 2023 18:25:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684261551; 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=rnEOKM6Uzt/actmg7zEiIw7A6rReXqMZszIGv86v3Sc=; b=hVKBHkEfp0G9WWvqDJIdHuFRXQZMHBevK/kn/dSawYU4vH2GOG6M/k8315ldc28XvmzHt7 JVVV+17V5fs2C8MT3gspinafb6B59kjzf+39pBAGAxZXwHkDOEZsIMRYRfYjKtd/j48MOe Ucek+oi57i2nKNml/BL1ltcex4CV/Ug= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684261551; 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=rnEOKM6Uzt/actmg7zEiIw7A6rReXqMZszIGv86v3Sc=; b=tm91uIeD7vPtoub1sk+jMCmayoC3m/C8kJoTmIIOUbi0fGm7KoJe0U8e8lMF9s+yzr6liW Ai4d6LArAkKNwxBA== 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 CD65E138F5; Tue, 16 May 2023 18:25:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mLsJL67KY2TeVQAAMHmgww (envelope-from ); Tue, 16 May 2023 18:25:50 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Waiman Long , Suren Baghdasaryan , Marco Elver , Andrey Konovalov , Eric Dumazet , Alexander Potapenko , Oscar Salvador Subject: [PATCH v5 3/3] mm,page_owner: Filter out stacks by a threshold counter Date: Tue, 16 May 2023 20:25:37 +0200 Message-Id: <20230516182537.3139-4-osalvador@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230516182537.3139-1-osalvador@suse.de> References: <20230516182537.3139-1-osalvador@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 --- lib/stackdepot.c | 5 ++++- mm/page_owner.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index c4af2e946500..7053221ce1d8 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -488,6 +488,9 @@ static struct stack_record *stack_depot_getstack(depot_stack_handle_t handle) } #ifdef CONFIG_PAGE_OWNER + +extern unsigned long page_owner_stack_threshold; + void *stack_start(struct seq_file *m, loff_t *ppos) { unsigned long *table = m->private; @@ -543,7 +546,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); diff --git a/mm/page_owner.c b/mm/page_owner.c index 2d97f6b34ea6..28c519fc9372 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -743,6 +743,23 @@ const struct file_operations page_owner_stack_operations = { .release = seq_release, }; +unsigned long page_owner_stack_threshold; + +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; +} + +DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get, + &page_owner_threshold_set, "%llu"); + static int __init pageowner_init(void) { if (!static_branch_unlikely(&page_owner_inited)) { @@ -755,6 +772,10 @@ static int __init pageowner_init(void) debugfs_create_file("page_owner_stacks", 0400, NULL, NULL, &page_owner_stack_operations); + debugfs_create_file("page_owner_threshold", 0600, NULL, NULL, + &proc_page_owner_threshold); + + page_owner_stack_threshold = 0; return 0; } -- 2.35.3