From patchwork Mon Feb 12 22:30:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13554130 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 2E576C4829D for ; Mon, 12 Feb 2024 22:29:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 107D36B00C4; Mon, 12 Feb 2024 17:29:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 03F0F6B00C5; Mon, 12 Feb 2024 17:29:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D867B6B00C6; Mon, 12 Feb 2024 17:29:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C09B16B00C4 for ; Mon, 12 Feb 2024 17:29:35 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 94235140172 for ; Mon, 12 Feb 2024 22:29:35 +0000 (UTC) X-FDA: 81784594710.01.E8A3A1F Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf28.hostedemail.com (Postfix) with ESMTP id 86C5DC0011 for ; Mon, 12 Feb 2024 22:29:33 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=U9jqloks; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=TkinlWVz; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=U9jqloks; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=TkinlWVz; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf28.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707776973; 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=wrmGvHqQzfNaShrvDguSIt1AAdF/oquPyxCU6VC3V/0=; b=ARJCUmafe0EhLnlqexBZJBnJyIH4Bb0D8DqQ0YMQYIVhFG6mxJoyg9sZKhHY804fhyLCir G+RBI5MerKTeTCCTHn61KRW/zh0pIAmPJG2Q/3VDCyuLK/Wzrwt3BLEyNfHbjePvnv3R/R 9XjTnyFjBRt1DiLhOVLMJptGV3KeZ2A= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=U9jqloks; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=TkinlWVz; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=U9jqloks; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=TkinlWVz; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf28.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707776973; a=rsa-sha256; cv=none; b=B+MqfNKaLfZ2TueZDE/YIwpG6oBrA9LeMTht7s4RSzde4/qn+vhzwvg6ECLR58lFfDqcF8 D+2lg9Ys8sAzOOow5GRRMl6kk2vrrg9L6kFRBX5myrXEBa7tC7s0lZXF/nspsUs7uWP7C3 TZDBWit0+hvjwmgPeAoozaVBVgvFFkA= Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 11AA7221A6; Mon, 12 Feb 2024 22:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707776972; 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=wrmGvHqQzfNaShrvDguSIt1AAdF/oquPyxCU6VC3V/0=; b=U9jqloksGUrl/eNBRyCLYgfj6sduFcBCUrcWKDHpeXb24Ugicd6lmLa9UnYqfvX0TuXKS7 9r60PATmtHzXICNvsY/UL9x7L2p6wP0/4TGbvNQuYcsO/8DGCByBw/voo3tYgBZwqrLSt+ VFEJVKqBubRJKJULlxT/ymJWlRYLNiU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707776972; 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=wrmGvHqQzfNaShrvDguSIt1AAdF/oquPyxCU6VC3V/0=; b=TkinlWVzB7+YhEp3jJr/aZNIP8VQuP4l4pvoZufo1Kr2/64XIZmKINju8djN6EKZQGdFX9 h1A0nNQbWXysyuDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707776972; 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=wrmGvHqQzfNaShrvDguSIt1AAdF/oquPyxCU6VC3V/0=; b=U9jqloksGUrl/eNBRyCLYgfj6sduFcBCUrcWKDHpeXb24Ugicd6lmLa9UnYqfvX0TuXKS7 9r60PATmtHzXICNvsY/UL9x7L2p6wP0/4TGbvNQuYcsO/8DGCByBw/voo3tYgBZwqrLSt+ VFEJVKqBubRJKJULlxT/ymJWlRYLNiU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707776972; 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=wrmGvHqQzfNaShrvDguSIt1AAdF/oquPyxCU6VC3V/0=; b=TkinlWVzB7+YhEp3jJr/aZNIP8VQuP4l4pvoZufo1Kr2/64XIZmKINju8djN6EKZQGdFX9 h1A0nNQbWXysyuDQ== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 806AE13212; Mon, 12 Feb 2024 22:29:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 8F2kHMubymX5JgAAn2gu4w (envelope-from ); Mon, 12 Feb 2024 22:29:31 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Marco Elver , Andrey Konovalov , Alexander Potapenko , Oscar Salvador Subject: [PATCH v8 4/5] mm,page_owner: Filter out stacks by a threshold Date: Mon, 12 Feb 2024 23:30:28 +0100 Message-ID: <20240212223029.30769-5-osalvador@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212223029.30769-1-osalvador@suse.de> References: <20240212223029.30769-1-osalvador@suse.de> MIME-Version: 1.0 X-Spamd-Bar: ++++ X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 86C5DC0011 X-Stat-Signature: j6sugk69u5mnqqpganuet34j1a8qddgx X-HE-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=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We want to be able to filter out the stacks based on a threshold we can can tune. By writing to 'set_threshold' file, we can adjust the threshold value. Signed-off-by: Oscar Salvador --- mm/page_owner.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index 3e4b7cd7c8f8..c4f9e5506e93 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -832,15 +832,18 @@ static void *stack_next(struct seq_file *m, void *v, loff_t *ppos) return stack; } +static unsigned long page_owner_stack_threshold; + static int stack_print(struct seq_file *m, void *v) { char *buf; int ret = 0; struct stack *stack = v; struct stack_record *stack_record = stack->stack_record; + int stack_count = refcount_read(&stack_record->count); if (!stack_record->size || stack_record->size < 0 || - refcount_read(&stack_record->count) < 2) + stack_count < 2 || stack_count < page_owner_stack_threshold) return 0; buf = kzalloc(PAGE_SIZE, GFP_KERNEL); @@ -851,7 +854,7 @@ static int stack_print(struct seq_file *m, void *v) goto out; scnprintf(buf + ret, PAGE_SIZE - ret, "stack_count: %d\n\n", - refcount_read(&stack_record->count)); + stack_count); seq_printf(m, buf); seq_puts(m, "\n\n"); @@ -884,6 +887,21 @@ static const struct file_operations page_owner_stack_operations = { .release = seq_release, }; +static int page_owner_threshold_get(void *data, u64 *val) +{ + *val = page_owner_stack_threshold; + return 0; +} + +static 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) { struct dentry *dir; @@ -898,6 +916,8 @@ static int __init pageowner_init(void) dir = debugfs_create_dir("page_owner_stacks", NULL); debugfs_create_file("show_stacks", 0400, dir, NULL, &page_owner_stack_operations); + debugfs_create_file("set_threshold", 0600, dir, NULL, + &proc_page_owner_threshold); return 0; }