From patchwork Tue May 16 18:25:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13243494 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 462C8C77B7F for ; Tue, 16 May 2023 18:25:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DF22900003; Tue, 16 May 2023 14:25:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98F3D900002; Tue, 16 May 2023 14:25:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 830BD900003; Tue, 16 May 2023 14:25:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 72902900002 for ; Tue, 16 May 2023 14:25:53 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3A3A3ADC41 for ; Tue, 16 May 2023 18:25:53 +0000 (UTC) X-FDA: 80796946986.29.EA33E65 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf25.hostedemail.com (Postfix) with ESMTP id 3D676A000D for ; Tue, 16 May 2023 18:25:50 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=cEjcmQRQ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=U1isGRPg; spf=pass (imf25.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684261551; 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=7KL/dXtFEdOnEfVR0/wTEI+YBtSMcDXHenOau1SyaXc=; b=nlzLQdVCAZ+bxpjKvyUZaqHDmtwfjYThl+kL9X4hmWrafRIdsxrbcIj02B2ZcaIPNszJOe j5Z00XLpGTC+JIK6ruW2gFxJjfFRwhnATXb2YSVcjkEeSTJ8BEaRf1OiOkg0pUojeZKqJ5 PMAJqCB5GlLbvZh07gPkk7Kjh7roke4= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=cEjcmQRQ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=U1isGRPg; spf=pass (imf25.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684261551; a=rsa-sha256; cv=none; b=tF/1tk6P8dp8XFZhjeCdDXvOmHQQl8TyJUrddcE999a8wXiFZ9Uqb5yj5F2iGP3SD7sfRF HxKZsKPKa3Yp9NpsVQukahTnHEFl7JPhmNYDhduRux2dxahvzk9K+reiUoX39ZpA8vEhv1 SzVUyxNxMiXenv8iFRrLzWpgYf+oThg= 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 E99F521FC3; Tue, 16 May 2023 18:25:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684261549; 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=7KL/dXtFEdOnEfVR0/wTEI+YBtSMcDXHenOau1SyaXc=; b=cEjcmQRQcZ2ZGxlIrGFO/fHeKI7bSvFFqb4MlkEoRHEwqAPg8cbzoPwyJg05hnyzr7jicw QtGyuCl8JPPozT9Vq/t2IzXoT5buJAxffnQSWaSjI+Revy8gSDgJz7ac2Bw4i+3UCVoYOB CoDyJJURtzVNcQkY9IZM00Vk96alflw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684261549; 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=7KL/dXtFEdOnEfVR0/wTEI+YBtSMcDXHenOau1SyaXc=; b=U1isGRPgj9zBn2wBkYSDbqg4syQUiecak5cJPf49i1Ql1C+VeCvdxaSVF96XIdIvPwX76m yxY9fcYxdzLu8dDg== 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 3017B138F5; Tue, 16 May 2023 18:25:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IICYCK3KY2TeVQAAMHmgww (envelope-from ); Tue, 16 May 2023 18:25:49 +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 2/3] mm, page_owner: Add page_owner_stacks file to print out only stacks and their counte Date: Tue, 16 May 2023 20:25:36 +0200 Message-Id: <20230516182537.3139-3-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 X-Stat-Signature: 8s5kogn91hk7ak5r6hejt7bie5uij6dc X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3D676A000D X-Rspam-User: X-HE-Tag: 1684261550-749515 X-HE-Meta: U2FsdGVkX1+bUMNglpmrp9ydqOtdGSOm7TJ7cgqDmWsXv6zjZO9LpfVw4xE15G+JSBJe2RN2vQpDxPKuUj4HcOwQRy/U0Zq/ZjF5P/1Hg7gYasQyEVzrIR1M35qlfSoc3toPUyDyih51UOzCGX3+mJ+L8aiStE5Vv1pR4EeIz/VTG8B+75TRvHQCqI6SqmNt/N7K+zl7XWzVKjqLinNQAAiqY7QJvHL5LxYIlMpSH1DmpbBz3NC4bISLq4Yupi5+xy+9Fs65tU5Lr697kBWzzUrzy1ZgO2A/E5KZOORiMAPhea+fEdtjdCElfjjsxdn3zMBisWnd2EBPp7YHdI+L+z++uyFcUrlAHBC3QkFTEvtewRlERLFQCQkfDQio+P0AXk2tmYfz5ASvbWsVjTVCrUR6P+jEIHvadE5lwiHU3Mb86MELPJKrWcFbKtzoRGGoJs1yoUdKSuhGTkupg+B5RNozFUevxfhHdWqKh9tcX+eqSG3YW5gbsvQuKjCCitvIutEMcy5waKvqjqZ/qjDnNKnCXtbE7P0KaMCKpolLhoWfsHhw8D1qWjcWKMvVOZ6vrAPndyiGbpeno9a5DixmVSwgCs/tE66Rtr3zEuRVZWnXzlNGMbYoyu0vCinFHBdsh3aFDV66CYgTzfBuPlDUWGv0pj1HA+4lmWPZ+Gpg+mITp/bFbn5i10XKUVjsoSg+P+HnMoVCpVLokw05J+SXH/Ma034iV47ANZpAyiNi0xjJlHoNJ3kM1MwLN1JxERjbDQbgeoKHVLn+MWHx4RoDjbhp4S+LMKcP06XftOx0XQuJcpBYezqG1GGfBBk1UgGf4nE6sTBA1ty2a23vg0T6rP+2uF8ewAtn/lY4Pf1l6qKa/2SZoa5vuoI5Re8xaECxQ7xW3XyHvdQR9bnbY2qeUJGb+G7TidYGdXrMoCXF5WokQKZM1oBlcmhn3UqjQBoknjCotO4KX7LWmz6zsF3 e1XW8k+Z eXXJUHuD7X4794ri+T7XycEJgbjKVJ/eBvUKxaboYXYA3e5MhkdlA4B5I1l8jobkfOKQndEeVKK9lzp+VFgyaSyw5jfIHyKwvPHbcCV9N/rehy50Q7iejYuGZf0PQ3mH1KAxXxkYeHuh2ANoWXTgMzRF2K5ki+L8DAa0zp3QEVze8tr45kVBkyuOaEBCMfWXES7aexIjETZBbCoGDt7ErkGdIdWMxDK8TkOlsYr8K4g7sx4hGNNl8eL2qfKcTM+HXHiQx X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We might be only interested in knowing about stacks <-> count relationship, so instead of having to fiddle with page_owner output and screen through pfns, let us add a new file called 'page_owner_stacks' that does just that. By cating such file, we will get all the stacktraces followed by its counter, so we can have a more global view. Signed-off-by: Oscar Salvador --- include/linux/stackdepot.h | 6 ++++ lib/stackdepot.c | 72 ++++++++++++++++++++++++++++++++++++++ mm/page_owner.c | 27 ++++++++++++++ 3 files changed, 105 insertions(+) diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index 6ba4fcdb0c5f..7e9d0e9ec66b 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -112,6 +112,12 @@ void stack_depot_dec_count(depot_stack_handle_t handle); depot_stack_handle_t stack_depot_save(unsigned long *entries, unsigned int nr_entries, gfp_t gfp_flags); +#ifdef CONFIG_PAGE_OWNER +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); +#endif + /** * stack_depot_fetch - Fetch a stack trace from stack depot * diff --git a/lib/stackdepot.c b/lib/stackdepot.c index bc4a9cd25834..c4af2e946500 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -29,6 +29,7 @@ #include #include #include +#include #define DEPOT_HANDLE_BITS (sizeof(depot_stack_handle_t) * 8) @@ -486,6 +487,77 @@ static struct stack_record *stack_depot_getstack(depot_stack_handle_t handle) return stack; } +#ifdef CONFIG_PAGE_OWNER +void *stack_start(struct seq_file *m, loff_t *ppos) +{ + unsigned long *table = m->private; + struct stack_record **stacks, *stack; + + /* First time */ + if (*ppos == 0) + *table = 0; + + if (*ppos == -1UL) + return NULL; + + stacks = &stack_table[*table]; + stack = (struct stack_record *)stacks; + + return stack; +} + +void *stack_next(struct seq_file *m, void *v, loff_t *ppos) +{ + unsigned long *table = m->private; + unsigned long nr_table = *table; + struct stack_record *next = NULL, *stack = v, **stacks; + unsigned long stack_table_entries = stack_hash_mask + 1; + + if (!stack) { +new_table: + /* New table */ + nr_table++; + if (nr_table >= stack_table_entries) + goto out; + stacks = &stack_table[nr_table]; + stack = (struct stack_record *)stacks; + next = stack; + } else { + next = stack->next; + } + + if (!next) + goto new_table; + +out: + *table = nr_table; + *ppos = (nr_table >= stack_table_entries) ? -1UL : *ppos + 1; + return next; +} + +int stack_print(struct seq_file *m, void *v) +{ + char *buf; + int ret = 0; + struct stack_record *stack = v; + + if (!stack->size || stack->size < 0 || + stack->size > PAGE_SIZE || stack->handle.valid != 1 || + refcount_read(&stack->count) < 1) + return 0; + + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + ret += stack_trace_snprint(buf, PAGE_SIZE, stack->entries, stack->size, 0); + scnprintf(buf + ret, PAGE_SIZE - ret, "stack count: %d\n\n", + refcount_read(&stack->count)); + seq_printf(m, buf); + seq_puts(m, "\n\n"); + kfree(buf); + + return 0; +} +#endif + unsigned int stack_depot_fetch(depot_stack_handle_t handle, unsigned long **entries) { diff --git a/mm/page_owner.c b/mm/page_owner.c index 2d5d07013e4e..2d97f6b34ea6 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -719,6 +719,30 @@ static const struct file_operations proc_page_owner_operations = { .llseek = lseek_page_owner, }; +static void stack_stop(struct seq_file *m, void *v) +{ +} + +static const struct seq_operations page_owner_stack_op = { + .start = stack_start, + .next = stack_next, + .stop = stack_stop, + .show = stack_print +}; + +static int page_owner_stack_open(struct inode *inode, struct file *file) +{ + return seq_open_private(file, &page_owner_stack_op, + sizeof(unsigned long)); +} + +const struct file_operations page_owner_stack_operations = { + .open = page_owner_stack_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static int __init pageowner_init(void) { if (!static_branch_unlikely(&page_owner_inited)) { @@ -729,6 +753,9 @@ static int __init pageowner_init(void) debugfs_create_file("page_owner", 0400, NULL, NULL, &proc_page_owner_operations); + debugfs_create_file("page_owner_stacks", 0400, NULL, NULL, + &page_owner_stack_operations); + return 0; } late_initcall(pageowner_init) From patchwork Tue May 16 18:25:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13243495 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 19C40C77B75 for ; Tue, 16 May 2023 18:25:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 85AAF900004; Tue, 16 May 2023 14:25:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BB15900002; Tue, 16 May 2023 14:25:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 571F6900004; Tue, 16 May 2023 14:25:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 47D3C900002 for ; Tue, 16 May 2023 14:25:55 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E2BE1A02EE for ; Tue, 16 May 2023 18:25:54 +0000 (UTC) X-FDA: 80796947028.17.A659F1D Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf30.hostedemail.com (Postfix) with ESMTP id DE88A80010 for ; Tue, 16 May 2023 18:25:52 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=hVKBHkEf; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=tm91uIeD; spf=pass (imf30.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684261553; 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=rnEOKM6Uzt/actmg7zEiIw7A6rReXqMZszIGv86v3Sc=; b=jRTgpYwU2fO3KqfK4vjL3hPEbGLZ3glSjD6CFqWh+6H1TW13ZqoLqKaaEodylTfly31hj/ dMs2EJ+pMBjrY7gc38ltyj0sisrdpOhqxt5efRQ99Fl9A3Z11BsLGMf3HgaHrIJpRrAhUK sK36o1g0OqoK7Ipa/qKiVmGAZu1M0Dk= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=hVKBHkEf; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=tm91uIeD; spf=pass (imf30.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684261553; a=rsa-sha256; cv=none; b=x4cds/B+5h0dccHSg40IVLtvuphbt3gMDQcWgMyoSwL9TZV2NZBA/1y8Uc4zNb0UbdqSgM 9+9pQkODus4FA3xPRBszF5EiSsz/jTeC0tGhAToraqSVADb/ijNU8eKuPLf3Jmy5SRJiCM Woo9Q8p8kzJH1rY5CNDIkd/TP3QAybk= 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 X-Stat-Signature: 3ti64g1rs8tmyw4886p76jr8pwfz36ad X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: DE88A80010 X-Rspam-User: X-HE-Tag: 1684261552-178355 X-HE-Meta: U2FsdGVkX19NErLnDRoBHx6YsMl5OQCmvkLdKRYUHBfgWrikcKYJX/qB9CbUoc6rsI1aDUAQWkVh28fHvmihjlhDlogt4VUWJMwN1iYyLAahUliTtSahvnTCrHF2UZdcE+VmZht5dfhSeOJkfyft9d4ZBz8ieqCSxDtFJ+88nCNKEAuaU71+Uhj8izrE9N41ixAhK6eKTMzLniDDYrWHMl8tKGE6aBUAYL+c5ib+EWyFkvD9ZLW8OPugz93ZfjfXll22ku7Pidj3Eq62BD1nVJR3Z+AqigJs0ONYPIXohxRP01xhTbYbSPPoRUEMvmtxvs7DUoIGqnzf4VHfAW5MO7iAWl/X0bdZksgzGpv5CzQpSEcwEeIqG0OuKfBGHMEAEZtRV4JT3+ldYNMJRCc3NN77kPLDObmeV61vGDB1gbz+LMjjl7q+FLqBW4FaPk0EYyujUtTQbaorVMck3cZeLECkNLRZ27k62WdrG4KJ9toPQs1dbWJwDx9Wj6TuQ1Mh2HtUElD1sAaMn+5jbc21/wwF94YalbjMf4UtFQTTqlIcwJQk+1p8w2z1jZzHgOTTU799liPM3nhXc7ogwXO8U5e+wHfSdMEPcv6bfQmecQ/7F1NXdCy3eYLUwmjmmID+OvN//IupVWsr4o3XHojF3YLNLhXyfaNqrT/3VmU2jj2QMbH6xkO/qCBpdUBuEQz5kOL5rxqRcxbCEFXtXaBi2Dnh3SewWsPxXvQLoNL8m7Fcad/eFEaHyfcn0+tdDOj6FjeY7Yz7HgJkmNOgcfa/SvXOs3mYoZ7eZPLWkC5dQ2Zv13BArYzlE/TgDrZdzav5gLLQDZBjFjQQ2f7dE88goXqEmA1lFq70mHeO76P6rWpXEWSfXtvxNRAQ36/+vV2lfhXUFxd1eDuL1j2mgxK/0maS5FwoG3GFq07x3XjGg9BkVMv8/PnB4Yo3SWLZmZCpG7QddylYcwBS561CRHX uAvlNNmi v8bg8shD4NcRAgl053CQrihs7o9lI+T94XMozDkL/fkav+FSwLC8sR/VtyiaqfbeeBnLWMCHYgqYNDkpowzWivSTGCR78vrcZautr4lpSuBAeliaZRTCVtQ72uSDbfzdoAhwmRbqPFN64KCg9mJVEUfSCaA9kqPnnR5p27k4Lz8vQUgmiXEPNHZ7qgjsOsnVQADi+TSPAOZ1h6ZkYIJlKCz93IcwzQ9dHhROGt6zcpch/sr0Xacq5kTSwCDX3OxBpmv2L X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; }