From patchwork Wed Feb 14 17:01:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13556795 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 30747C48BC1 for ; Wed, 14 Feb 2024 17:01:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 070786B00AF; Wed, 14 Feb 2024 12:01:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 01FFD6B00B0; Wed, 14 Feb 2024 12:01:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDC426B00B1; Wed, 14 Feb 2024 12:01:05 -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 C484B6B00AF for ; Wed, 14 Feb 2024 12:01:05 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9AF51120DDB for ; Wed, 14 Feb 2024 17:01:05 +0000 (UTC) X-FDA: 81791024490.18.FC5454A Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf12.hostedemail.com (Postfix) with ESMTP id 837D740006 for ; Wed, 14 Feb 2024 17:01:02 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="zNJ/cNYg"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=u2iYDTK6; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="zNJ/cNYg"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=u2iYDTK6; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf12.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=1707930062; 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=EpyTfdqNt961GvDxag5tkCXV2rpAMmweQFUyE+zT/FE=; b=T/oaG4XWozrVM+mTHVSNtevlQlx58KhwXx98WJGsa3oGtHYpdssEmAcOuM77UkKeVSV2si eDO2fv/gjs4Gjbq42GeOuKyBA7FAW1KYwVxmWluSWSsdmhnInurzLyLPx2AlIYBxpp6oCG SI3t0BwPNCuH/lKQZPKb821vhY3P/lo= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="zNJ/cNYg"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=u2iYDTK6; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="zNJ/cNYg"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=u2iYDTK6; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf12.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=1707930062; a=rsa-sha256; cv=none; b=a34zor7LMfoThzlnKeVFJn+GvrrvhHKthlJ6ycXhQ8fRHnDbvu8o8AqWo3vxufGY5xYUdz fyJiJ20Jj4aQdE7L/ETY8X5kbHr0wxWuiWyQsTcawNUj8she5UgDUq58tuFHcANPr84lqb xGdrRUuCp7bIo2sCeBzgm69BVcyAIz4= 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 03EC121CF4; Wed, 14 Feb 2024 17:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707930061; 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=EpyTfdqNt961GvDxag5tkCXV2rpAMmweQFUyE+zT/FE=; b=zNJ/cNYgtsmqdxiXVl4EEvvYJE01rr3DXmJEAFyXBFuryxV/fI/CpAwUdOPR0A3c+ePlXH Gr5YG/jRzuNLd9KXVxFAGtD4P68UnQTwP8bPU9luFYYY0hmh90Bu6V3tGWIzgSMoMDQnpF XRjlI1satOiBwJrojtWfY+ILrsMv2xA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707930061; 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=EpyTfdqNt961GvDxag5tkCXV2rpAMmweQFUyE+zT/FE=; b=u2iYDTK6LdrTuoQRSUXtbrkjlplp39PcCQL61pHF6at7ixPmEwh+ib2EiyT1tL4RhEC15r cnNxb18n0speCkCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707930061; 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=EpyTfdqNt961GvDxag5tkCXV2rpAMmweQFUyE+zT/FE=; b=zNJ/cNYgtsmqdxiXVl4EEvvYJE01rr3DXmJEAFyXBFuryxV/fI/CpAwUdOPR0A3c+ePlXH Gr5YG/jRzuNLd9KXVxFAGtD4P68UnQTwP8bPU9luFYYY0hmh90Bu6V3tGWIzgSMoMDQnpF XRjlI1satOiBwJrojtWfY+ILrsMv2xA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707930061; 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=EpyTfdqNt961GvDxag5tkCXV2rpAMmweQFUyE+zT/FE=; b=u2iYDTK6LdrTuoQRSUXtbrkjlplp39PcCQL61pHF6at7ixPmEwh+ib2EiyT1tL4RhEC15r cnNxb18n0speCkCQ== 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 781EF13A0B; Wed, 14 Feb 2024 17:01:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id mA2kGszxzGUfMwAAn2gu4w (envelope-from ); Wed, 14 Feb 2024 17:01:00 +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 v9 7/7] mm,page_owner: Update Documentation regarding page_owner_stacks Date: Wed, 14 Feb 2024 18:01:57 +0100 Message-ID: <20240214170157.17530-8-osalvador@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240214170157.17530-1-osalvador@suse.de> References: <20240214170157.17530-1-osalvador@suse.de> MIME-Version: 1.0 X-Spamd-Bar: / X-Rspamd-Queue-Id: 837D740006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: qprnpoij9g49r5h3u18yfd7q7bbixits X-H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OtwngHlOEaxN+0EahqXiQmm7MvFcGbWUug6SJInEB6mQD8Y/5GhjYPG/7EgHqUWTCPr0H0CE3EWmp6XgZGwAkVyoPck0Aec/siWFwQc6US5Ud11mJDUHbKi4JAxzqTdOh+zaCJdDmMug7hVBWKQsqs7krdPQH37UptxFOT9nUOoXaO1RJieopnra4fBNAa1pDFQRmPstI1Y2a2hLrB+ogZavyd1A== 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