From patchwork Mon Feb 12 22:30:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13554131 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 F1CAFC4829D for ; Mon, 12 Feb 2024 22:29:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F11416B008C; Mon, 12 Feb 2024 17:29:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E97FB6B009A; Mon, 12 Feb 2024 17:29:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCFA86B00C5; Mon, 12 Feb 2024 17:29:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B58A96B008C for ; Mon, 12 Feb 2024 17:29:37 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 86C83120387 for ; Mon, 12 Feb 2024 22:29:37 +0000 (UTC) X-FDA: 81784594794.15.5D7A489 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf03.hostedemail.com (Postfix) with ESMTP id 33CBF20003 for ; Mon, 12 Feb 2024 22:29:34 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=0Hkksmim; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=ZnVGi03v; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=0Hkksmim; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=ZnVGi03v; spf=pass (imf03.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=1707776975; 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=C1CzNFL4PMmMQSHbggAgsOI2ejs0tMDCon93dbkR538=; b=8TLWthE1A3NWSYaJKOEdOi+fNfxFGNmFCf2zoWMK16zYxAavG+6T5M6ht1KhRHCrZDOSI7 84CXFeinup4nssZFxOgS/3tWGfhwI+hHJqGyGqi03r3PKBeShu01o4Hb3VF8FRcKCVxcfS maj/edTuBN0QBBXK4y402dRN+nUpWUE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=0Hkksmim; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=ZnVGi03v; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=0Hkksmim; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=ZnVGi03v; spf=pass (imf03.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707776975; a=rsa-sha256; cv=none; b=xlH1fNQGairNqMazC20wURJA1SNBqOvszc+Da88dPVW9iwpHJGWgmJ414krkZhtyKd1EFE CKRYws3ZJRIhahjGQo3u53C+iYv9Dyo955jL7atvktREi2fMr1QNHrGbL8cMoN26K2pQ+i gzoA4G1RR3bdF6AZ1cSuPQqsWRb50Hc= 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 AD61222177; Mon, 12 Feb 2024 22:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707776973; 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=C1CzNFL4PMmMQSHbggAgsOI2ejs0tMDCon93dbkR538=; b=0HkksmimAKf1X2UchGs1ECrVRZPKtKpJwt693l9NOKJ5pJjpsp/SyDvukNl5wLeGnSUFbx AYwqmHSTXqM/SJpVRjlMOBOxO0rM/s0c6MDVVlIlJYcTLyTM3upL1YC6miq4zlePc2ZO79 zdX7qh0CWgh/3uAXle7lIRUwWwtjOlE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707776973; 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=C1CzNFL4PMmMQSHbggAgsOI2ejs0tMDCon93dbkR538=; b=ZnVGi03vheW9LR2lPrO/6uN0847XkDBVnIfGMln6MKkPIGMcvcEckEGoHOIS/MPPxXr9Ab pgLcrPPJ9Uwoh3Ag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707776973; 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=C1CzNFL4PMmMQSHbggAgsOI2ejs0tMDCon93dbkR538=; b=0HkksmimAKf1X2UchGs1ECrVRZPKtKpJwt693l9NOKJ5pJjpsp/SyDvukNl5wLeGnSUFbx AYwqmHSTXqM/SJpVRjlMOBOxO0rM/s0c6MDVVlIlJYcTLyTM3upL1YC6miq4zlePc2ZO79 zdX7qh0CWgh/3uAXle7lIRUwWwtjOlE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707776973; 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=C1CzNFL4PMmMQSHbggAgsOI2ejs0tMDCon93dbkR538=; b=ZnVGi03vheW9LR2lPrO/6uN0847XkDBVnIfGMln6MKkPIGMcvcEckEGoHOIS/MPPxXr9Ab pgLcrPPJ9Uwoh3Ag== 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 2A3A613212; Mon, 12 Feb 2024 22:29:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 6IORB82bymX5JgAAn2gu4w (envelope-from ); Mon, 12 Feb 2024 22:29:33 +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 5/5] mm,page_owner: Update Documentation regarding page_owner_stacks Date: Mon, 12 Feb 2024 23:30:29 +0100 Message-ID: <20240212223029.30769-6-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-Rspamd-Queue-Id: 33CBF20003 X-Rspam-User: X-Stat-Signature: ht8qndqqrcqbhri3ndagdk4ug4m677nf X-Rspamd-Server: rspam01 X-HE-Tag: 1707776974-360667 X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KN4IFbLssyRM5MGoQnBieIr3mLmQHh5KodDSXmXm1AwuCLy/9MtHGuAX8ygC5y6VR6tBHqmYkhFd1ZKRlZblfY398iJEqyE0N+Po6m1IZNCuaYhVcWaCb9jOdg2vQ9RUhoVo/+Xe6X88TLdA4tRpvAzAOYyWuHYrJofEMNIPb8obNM/lDcy9qyAqB8GKvzhXu9XrPT/tgiXRGRg== 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 --- Documentation/mm/page_owner.rst | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Documentation/mm/page_owner.rst b/Documentation/mm/page_owner.rst index 62e3f7ab23cc..bcde81bf0902 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,45 @@ 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/set_threshold > 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