From patchwork Mon Nov 20 08:43:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 166979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2059829vqn; Mon, 20 Nov 2023 00:43:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXRSuNO/AgTJvVR4XdYAI/Cvhf6jNIkXzLUsjgZ0S12GsGcy29u+l/XjdHYKaUlAdNhagT X-Received: by 2002:a05:6a20:da90:b0:187:d18a:3164 with SMTP id iy16-20020a056a20da9000b00187d18a3164mr10858300pzb.6.1700469827019; Mon, 20 Nov 2023 00:43:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700469827; cv=none; d=google.com; s=arc-20160816; b=b9A67CPn6CMkUTUISZE7Na0170de+saOJvujZig0N0090SwldPi9CicHPQGe702sz4 Thx/cwyCmR2KUzgGCgkOK2ZQe8X1m5G+rcUM3rKo37k1Ojs1acCOaDIjfzC7TazwtkzT CSXl0PomQjx4EkIF7fpEq+6jRcdPhBW9VoesUUaS7P1tPeSdeZZA44kRtkGtTCHw1sdj Hy9OUnNeZVxV7hhAUuYUXV0NXfZl4qclCqS8kfXXt7A5P9bVXTCh9GL1dazdDIewZTRq SfTZ2GnOrZICACPZO4mluoHI/3K/e0/u60vpXlY6KrF5c2VWdYy/gRyYV1HzhrDVJ75E baHQ== 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=PDH277g7F2wYgGggepn2hqYKq/ycO2DhoCkVXWauxYM=; fh=Nu0msm8cGz3CvEnu3k13ViJg3Y+V5oHxg1+HtdVamp0=; b=OrSQsfTA5MsJkBR/Lap3JzkqXSNDukPMsRiXJ44M7HedSvat7VnK4Nd9sfzJRg2V8f 22zx2t0+qbDL+4BwHuZeei+Eca45M4vfgYs2sA8PllR2ZYmeaKbhl9OdtXju9M6K2YYy W5wa2DkbS/k9drhSzT0k91Ez6Cg8btWLvd0zaXgR8b6PHKACFvQvNMvO3nMhBrQpfiBs FXcwqiygO3R3qynB1/O2Lyd9NWeHjtfXELm5/unyFGhM/4SpK88CJ5x4NWmT5sx9iqY0 v2CPs1hrLtYePt6vE9Idqo12nW72TcbPOMuBI8a0cgzKb1Nbl2toK0Z/z63u4woTTNKX EWKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vULYWMFM; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n5-20020a17090a9f0500b002851a01b0absi3239527pjp.151.2023.11.20.00.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 00:43:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vULYWMFM; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D29FC802A82F; Mon, 20 Nov 2023 00:43:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232381AbjKTInf (ORCPT + 27 others); Mon, 20 Nov 2023 03:43:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232346AbjKTIn0 (ORCPT ); Mon, 20 Nov 2023 03:43:26 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E2FC1AA for ; Mon, 20 Nov 2023 00:43:18 -0800 (PST) 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 58A0D1F855; Mon, 20 Nov 2023 08:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700469796; 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=PDH277g7F2wYgGggepn2hqYKq/ycO2DhoCkVXWauxYM=; b=vULYWMFMmmaG4S6iAkq5rSYmzy20p9tn1S3i6DL/n7pooOCC0Z+gGAbJ3WGHNnAFjw1Oeb OCX2wKXShH5JPzCNgEvnFq1C9WhDIOFSrP9E/HjhIs3ItAn5AwWVeq3djPr7uW40iDdPDj a7gK1tVk27s7VosOL1aTePWRIqQUGJM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700469796; 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=PDH277g7F2wYgGggepn2hqYKq/ycO2DhoCkVXWauxYM=; b=AePaBT45sbywumguZikXpcc3f5I8qh22AOKqNPJdL4aMGBn+rV5hcc7enjPGv4AhKNpohk HO99W3gl6HlKfNCg== 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 A1BEA13912; Mon, 20 Nov 2023 08:43:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uEGWJCMcW2U3VgAAMHmgww (envelope-from ); Mon, 20 Nov 2023 08:43:15 +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 v6 4/4] mm,page_owner: Filter out stacks by a threshold counter Date: Mon, 20 Nov 2023 09:43:00 +0100 Message-Id: <20231120084300.4368-5-osalvador@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20231120084300.4368-1-osalvador@suse.de> References: <20231120084300.4368-1-osalvador@suse.de> MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 4.20 X-Spamd-Result: default: False [4.20 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; R_RATELIMIT(0.00)[to_ip_from(RL5rfg3hcnr63ytnowg6b9545r)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; NEURAL_SPAM_LONG(3.50)[1.000]; RCPT_COUNT_TWELVE(0.00)[12]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[vger.kernel.org,kvack.org,suse.com,suse.cz,redhat.com,google.com,gmail.com,suse.de]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 00:43:44 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783071849281181718 X-GMAIL-MSGID: 1783071849281181718 We want to be able to filter out the output based on a certain threshold, so we can leave out stacks with a low counter of outstanding allocations. We can control the threshold value by a new file called 'page_owner_threshold', which is 0 by default. Signed-off-by: Oscar Salvador --- mm/page_owner.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mm/page_owner.c b/mm/page_owner.c index 509c11e506db..6ee345dafd01 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -41,6 +41,8 @@ static depot_stack_handle_t dummy_handle; static depot_stack_handle_t failure_handle; static depot_stack_handle_t early_handle; +static unsigned long page_owner_stack_threshold; + static void init_early_allocated_pages(void); static int __init early_page_owner_param(char *buf) @@ -763,6 +765,9 @@ static int stack_print(struct seq_file *m, void *v) int ret = 0; struct stack_record *stack = (struct stack_record *)v; + if (refcount_read(&stack->count) < page_owner_stack_threshold) + return 0; + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); ret += stack_depot_get_stack_info(stack, buf); @@ -804,6 +809,21 @@ const struct file_operations page_owner_stack_operations = { .release = seq_release, }; +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)) { @@ -815,6 +835,8 @@ static int __init pageowner_init(void) &proc_page_owner_operations); 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); return 0; }