From patchwork Thu Feb 15 21:59:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13559176 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 ADCFDC4829E for ; Thu, 15 Feb 2024 21:58:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E1A08D001D; Thu, 15 Feb 2024 16:58:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F5FA8D0017; Thu, 15 Feb 2024 16:58:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F7C18D001D; Thu, 15 Feb 2024 16:58:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 27B3B8D0017 for ; Thu, 15 Feb 2024 16:58:16 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EE8C61C1A54 for ; Thu, 15 Feb 2024 21:58:15 +0000 (UTC) X-FDA: 81795402150.17.172612C Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf21.hostedemail.com (Postfix) with ESMTP id B0BEE1C0019 for ; Thu, 15 Feb 2024 21:58:13 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=LJB6aK5O; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=yjRw1o2a; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=LJB6aK5O; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=yjRw1o2a; spf=pass (imf21.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 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=1708034294; 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=45ycMV23TmrOoOgGTYCtcczz/iV5aW1RGHy4jThaFhM=; b=mpH+VufE94OiKEdS0oxi1ql1tEmL5OWm3RRdEANfemyKhcHQAKDdF9SYXWnjZ78yeJ8hnN W9pPjd6hXHRRCeezAziLoUhVBuZvoAccERC4hHpaz1OvmSyCbT49XXZNvH+NIbxONqIQJ4 FOorya1eSEiJR4NzXbSn36pCvYlbOAo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708034294; a=rsa-sha256; cv=none; b=Pyhlbpsb1SHT1C6N9U0XhluXZk5cYOxA/taKxGCU2j+5fjxrORtEa+g6klqWrdKyQymv0z vJPNsJ8UFkIsfYAYX6vxlFP7d7TslcpdTNige4EIO4Qa/L6OVYCX1Wlw9KRbDH3nVAHJ8Q wJuxZ3h6Ho4VGQwAlW8vkOnmHKhCilE= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=LJB6aK5O; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=yjRw1o2a; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=LJB6aK5O; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=yjRw1o2a; spf=pass (imf21.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de 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 43E60220A6; Thu, 15 Feb 2024 21:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708034292; 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=45ycMV23TmrOoOgGTYCtcczz/iV5aW1RGHy4jThaFhM=; b=LJB6aK5OjyTaCsvR/Y/MYtJhQBBo677GYHNToIlp0BrUevFN/3pIcfZe3+64Sf7R+SkLlC 1sDXYhcKZW5Mv+LDQhc1WB5vnajZeF3sHR30b6d7CWWXYFs43wDicC8BiLt7A25Tu/7ers MmYc5Aysfb+HRQPW+AX8BtKFCOpObL0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708034292; 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=45ycMV23TmrOoOgGTYCtcczz/iV5aW1RGHy4jThaFhM=; b=yjRw1o2arAmOwuH6tTsX4slhZ4kvqiJ9bnKXfwy1k8W4FziPhlqX4a8OC35C3jV+ZpcEIX UB7FIoWfnHXvuCCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708034292; 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=45ycMV23TmrOoOgGTYCtcczz/iV5aW1RGHy4jThaFhM=; b=LJB6aK5OjyTaCsvR/Y/MYtJhQBBo677GYHNToIlp0BrUevFN/3pIcfZe3+64Sf7R+SkLlC 1sDXYhcKZW5Mv+LDQhc1WB5vnajZeF3sHR30b6d7CWWXYFs43wDicC8BiLt7A25Tu/7ers MmYc5Aysfb+HRQPW+AX8BtKFCOpObL0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708034292; 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=45ycMV23TmrOoOgGTYCtcczz/iV5aW1RGHy4jThaFhM=; b=yjRw1o2arAmOwuH6tTsX4slhZ4kvqiJ9bnKXfwy1k8W4FziPhlqX4a8OC35C3jV+ZpcEIX UB7FIoWfnHXvuCCQ== 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 DD8561346A; Thu, 15 Feb 2024 21:58:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id QE89M/GIzmXPAQAAn2gu4w (envelope-from ); Thu, 15 Feb 2024 21:58:09 +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 v10 7/7] mm,page_owner: Update Documentation regarding page_owner_stacks Date: Thu, 15 Feb 2024 22:59:07 +0100 Message-ID: <20240215215907.20121-8-osalvador@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215215907.20121-1-osalvador@suse.de> References: <20240215215907.20121-1-osalvador@suse.de> MIME-Version: 1.0 X-Spamd-Bar: ++++ X-Stat-Signature: k9411qzmghrnahxp83747ibinootqp7c X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: B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lCnWGmUzLcBatnpo8602JbV7j//mFB30jkY90KPWfjzi9Co8rE5D3ye5toHlEHGw8ORSr6E3ojcLxBXOEIPQJ3JEQYLGs1uzqsBvZJ6m9v5wfYTPfX14fRZUdtztldlY1ez3HpAgpEKCD8x92juO9DUwRdyhw3Ak0EmULKmW9KMP2mlJ+WhzATLRGmE5EE74J6ZeYavUyNDTJsreP2isFeAC2kr6J3nf5rnEKAo+JUOeWV+j86HflcHuKWCYYeIjdd0Ape5DBH6/Wh08QJg== 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: List-Subscribe: List-Unsubscribe: Update page_owner documentation including the new page_owner_stacks feature to show how it can be used. Signed-off-by: Oscar Salvador Reviewed-by: Vlastimil Babka Reviewed-by: Marco Elver --- Documentation/mm/page_owner.rst | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Documentation/mm/page_owner.rst b/Documentation/mm/page_owner.rst index 62e3f7ab23cc..0d0334cd5179 100644 --- a/Documentation/mm/page_owner.rst +++ b/Documentation/mm/page_owner.rst @@ -24,6 +24,11 @@ fragmentation statistics can be obtained through gfp flag information of each page. It is already implemented and activated if page owner is enabled. Other usages are more than welcome. +It can also be used to show all the stacks and their outstanding +allocations, which gives us a quick overview of where the memory is going +without the need to screen through all the pages and match the allocation +and free operation. + page owner is disabled by default. So, if you'd like to use it, you need to add "page_owner=on" to your boot cmdline. If the kernel is built with page owner and page owner is disabled in runtime due to not enabling @@ -68,6 +73,46 @@ Usage 4) Analyze information from page owner:: + cat /sys/kernel/debug/page_owner_stacks/show_stacks > stacks.txt + cat stacks.txt + prep_new_page+0xa9/0x120 + get_page_from_freelist+0x7e6/0x2140 + __alloc_pages+0x18a/0x370 + new_slab+0xc8/0x580 + ___slab_alloc+0x1f2/0xaf0 + __slab_alloc.isra.86+0x22/0x40 + kmem_cache_alloc+0x31b/0x350 + __khugepaged_enter+0x39/0x100 + dup_mmap+0x1c7/0x5ce + copy_process+0x1afe/0x1c90 + kernel_clone+0x9a/0x3c0 + __do_sys_clone+0x66/0x90 + do_syscall_64+0x7f/0x160 + entry_SYSCALL_64_after_hwframe+0x6c/0x74 + stack_count: 234 + ... + ... + echo 7000 > /sys/kernel/debug/page_owner_stacks/count_threshold + cat /sys/kernel/debug/page_owner_stacks/show_stacks> stacks_7000.txt + cat stacks_7000.txt + prep_new_page+0xa9/0x120 + get_page_from_freelist+0x7e6/0x2140 + __alloc_pages+0x18a/0x370 + alloc_pages_mpol+0xdf/0x1e0 + folio_alloc+0x14/0x50 + filemap_alloc_folio+0xb0/0x100 + page_cache_ra_unbounded+0x97/0x180 + filemap_fault+0x4b4/0x1200 + __do_fault+0x2d/0x110 + do_pte_missing+0x4b0/0xa30 + __handle_mm_fault+0x7fa/0xb70 + handle_mm_fault+0x125/0x300 + do_user_addr_fault+0x3c9/0x840 + exc_page_fault+0x68/0x150 + asm_exc_page_fault+0x22/0x30 + stack_count: 8248 + ... + cat /sys/kernel/debug/page_owner > page_owner_full.txt ./page_owner_sort page_owner_full.txt sorted_page_owner.txt