From mboxrd@z Thu Jan 1 00:00:00 1970 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 21E2AC3DA6E for ; Wed, 10 Jan 2024 08:59:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF4746B0083; Wed, 10 Jan 2024 03:59:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AA3076B0085; Wed, 10 Jan 2024 03:59:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BA1D6B0087; Wed, 10 Jan 2024 03:59:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8B9276B0083 for ; Wed, 10 Jan 2024 03:59:00 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 51E22160A94 for ; Wed, 10 Jan 2024 08:59:00 +0000 (UTC) X-FDA: 81662801640.29.B06FF7F Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id EBA071C0007 for ; Wed, 10 Jan 2024 08:58:57 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704877138; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vYS5moUAJmJXdQvVPb4LobYvRsnIsiV8PTXEGEFqeAg=; b=ZnMQQqizUzrDVnqQhY7SUi8+BJf7BcaMQnuymU9yaB9rh/BNMQgNJM1ost+QlgDJgRsdkS Y6H+IJLC4XpoacND/GlC58zC9pGWa4pcN+4Eh8mIOgMLs2N3IC/5urSmn1ALdwNMYh7wn9 lP87igK/jnKCI+l4laYUfhVlqKS8uP4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704877138; a=rsa-sha256; cv=none; b=sY4jEdZ6uEflFP0h4Au+K6a6qautMWPtzbrScHNgPOUCCYL1VXcpGDMtICUR25Yt1NBZtJ 2o/lZ7VwQRAh9iiOF1g7iF/ouZCnFTV0XjQZ9ee81lZ0S3KvmKo0L8NCDEdYSFOjXsKfjn Iz6rlDFCIup2OZKgoJTKZ9vB3jOlw6g= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 78DAB2F4; Wed, 10 Jan 2024 00:59:42 -0800 (PST) Received: from [10.57.76.12] (unknown [10.57.76.12]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 756763F64C; Wed, 10 Jan 2024 00:58:55 -0800 (PST) Message-ID: <3bd5e4a3-9f67-4483-9a0e-9abb5eb783cd@arm.com> Date: Wed, 10 Jan 2024 08:58:54 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v1] tools/mm: Add thpmaps script to dump THP usage info Content-Language: en-GB To: Barry Song <21cnbao@gmail.com>, John Hubbard Cc: Andrew Morton , Zenghui Yu , Matthew Wilcox , David Hildenbrand , Kefeng Wang , Zi Yan , Alistair Popple , linux-mm@kvack.org References: <20240102153828.1002295-1-ryan.roberts@arm.com> <4e7445a0-acc9-487f-999f-a2b6d03d265e@nvidia.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EBA071C0007 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: tyhsyart9w6hssepa7xz5qoyxyay5897 X-HE-Tag: 1704877137-294751 X-HE-Meta: U2FsdGVkX19E76NbZNZ+JbfQHiZNHIC6hmiijgHbTfEWRjv5wljyHPImC4tDGOhmZdP9IDW1c7DukT+Ka98OdsWC32EsXOWXIoa0pko4dDEPUnN2zlYvcfRGaTykJp5ZbChbHjwyUDjicz29YGvmriwoR+SVjsGMzagOrSt+DXLUNaa/hcTY0VpZAJ6DBqiids6YXrK7yWKBkEN29a2MjFT3g/1MjjRAv5vqr/CuDPck8HMn23JwRfJXYd65+gatdKZAC9ansh0TRPcGRMX1eiOvgdAcxGm3M1/HD67Fw8M1oJyvkYweW+3DELZQlRSQDdUgTWL59F69sTs27rAhsyH3QTf9zVEEzopwkLcUiKxEZVx/pBx8qu36Asi7L0Vgdklr6tgPmy/6PWqgI8IzDRmQRiCNK2fiSW8QBeMPhSwL1xJBkZtpugDTph+jzhz13Z5TndTUFL2aYWQxy5Tx2yywtauRUp6IenybNxENpAoOhRUtNPjpWq8O1MoSDxxXLdqPvvvqISyBxtYymwlrAuYZp3pr5S9U6PgNuS4bf4NBldGt62oQWN1wzFVegv2Ep+B4jXXgyU6BrYEUeAeo+5owpWiXwlpXWtY4JOme3YxQfYoVvSgCoesADc8mrbkvgwno40HmZddDR3GSIPtFhunQR0zN1DclC1Qt7ksg6ew5KA4ivW7BJ6Dk+N4mk8utV1NSl71cITE7pmVmNeyxIR0/PLGdVITYfv8Zs8WW7+8ZOR3nlqDd7uRRI36e+h2/5DCtIOXXpkHmnkVsgsA2EHC6nI+Dupn0XPIuMJy4fFAm+vT2g2C2svvNaTcyGG6EFpaVaD5wPMDKFt2kGFVMzsAnq5eZAD/Pxo0JKyHg52veUPeMVYXPYRouZHSEU2e88VfDoZcoHT71gNVf2eboYfhD7Fm/KgIQ/Xl0ChKAURoN4oJbHucr8Gns/iO/2JcZC/30F1BUqTonQy0+jGO R84nYxAt XhdymAYPO7iuA4kjGoZjWerxbmvmCUmdBSArL9SUxIOKrti73EvWmntIH3C3dgrIX3MuwDQHQgSYjNH2n9fet0e7Vw2PdzgyFi90IXAQchMGF082+popW7nbf0j8QzhE759Wto5HskEPhB4xHY0zxqQ5t0JFJ2dF7/7t/auXAkNphmmk= 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: On 10/01/2024 08:02, Barry Song wrote: > On Wed, Jan 10, 2024 at 12:16 PM John Hubbard wrote: >> >> On 1/9/24 19:51, Barry Song wrote: >>> On Wed, Jan 10, 2024 at 11:35 AM John Hubbard wrote: >> ... >>>> Hi Ryan, >>>> >>>> One thing that immediately came up during some recent testing of mTHP >>>> on arm64: the pid requirement is sometimes a little awkward. I'm running >>>> tests on a machine at a time for now, inside various containers and >>>> such, and it would be nice if there were an easy way to get some numbers >>>> for the mTHPs across the whole machine. Just to confirm, you're expecting these "global" stats be truely global and not per-container? (asking because you exploicitly mentioned being in a container). If you want per-container, then you can probably just create the container in a cgroup? >>>> >>>> I'm not sure if that changes anything about thpmaps here. Probably >>>> this is fine as-is. But I wanted to give some initial reactions from >>>> just some quick runs: the global state would be convenient. Thanks for taking this for a spin! Appreciate the feedback. >>> >>> +1. but this seems to be impossible by scanning pagemap? >>> so may we add this statistics information in kernel just like >>> /proc/meminfo or a separate /proc/mthp_info? >>> >> >> Yes. From my perspective, it looks like the global stats are more useful >> initially, and the more detailed per-pid or per-cgroup stats are the >> next level of investigation. So feels odd to start with the more >> detailed stats. >> > > probably because this can be done without the modification of the kernel. Yes indeed, as John said in an earlier thread, my previous attempts to add stats directly in the kernel got pushback; DavidH was concerned that we don't really know exectly how to account mTHPs yet (whole/partial/aligned/unaligned/per-size/etc) so didn't want to end up adding the wrong ABI and having to maintain it forever. There has also been some pushback regarding adding more values to multi-value files in sysfs, so David was suggesting coming up with a whole new scheme at some point (I know /proc/meminfo isn't sysfs, but the equivalent files for NUMA nodes and cgroups do live in sysfs). Anyway, this script was my attempt to 1) provide a short term solution to the "we need some stats" request and 2) provide a context in which to explore what the right stats are - this script can evolve without the ABI problem. > The detailed per-pid or per-cgroup is still quite useful to my case in which > we set mTHP enabled/disabled and allowed sizes according to vma types, > eg. libc_malloc, java heaps etc. > > Different vma types can have different anon_name. So I can use the detailed > info to find out if specific VMAs have gotten mTHP properly and how many > they have gotten. > >> However, Ryan did clearly say, above, "In future we may wish to >> introduce stats directly into the kernel (e.g. smaps or similar)". And >> earlier he ran into some pushback on trying to set up /proc or /sys >> values because this is still such an early feature. >> >> I wonder if we could put the global stats in debugfs for now? That's >> specifically supposed to be a "we promise *not* to keep this ABI stable" >> location. Now that I think about it, I wonder if we can add a --global mode to the script (or just infer global when neither --pid nor --cgroup are provided). I think I should be able to determine all the physical memory ranges from /proc/iomem, then grab all the info we need from /proc/kpageflags. We should then be able to process it all in much the same way as for --pid/--cgroup and provide the same stats, but it will apply globally. What do you think? If we can possibly avoid sysfs/debugfs I would prefer to keep it all in a script for now. > > +1. > >> >> >> thanks, >> -- >> John Hubbard >> NVIDIA >> > > Thanks > Barry