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 7C700C3DA6E for ; Wed, 10 Jan 2024 09:20:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECFAF6B0092; Wed, 10 Jan 2024 04:20:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E7E2E6B0093; Wed, 10 Jan 2024 04:20:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6E5C6B0095; Wed, 10 Jan 2024 04:20:54 -0500 (EST) 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 C60D66B0092 for ; Wed, 10 Jan 2024 04:20:54 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 79EBC160A04 for ; Wed, 10 Jan 2024 09:20:54 +0000 (UTC) X-FDA: 81662856828.30.0CF895E Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf25.hostedemail.com (Postfix) with ESMTP id 7F557A001F for ; Wed, 10 Jan 2024 09:20:52 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf25.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=1704878452; 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=Vmogz/GmRfzcu3L8ElC9QGb4vw7hk41INyPJeszwXEs=; b=Qh2zgVvivRLQEU2zJ07QGc/PYpLJlqqxuPTDosciaOQOmOWpz1Aypc+z3VbLYiXn5tPASY YbQhsVxBsCVFacgUr5Fea5esplBA/SM22q74j1mZvpkj3fzPBbkYpDtIbMEm7igvOxVsHF Qtoc68YPPevPLIL3pBI/vnR21SCu+5I= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf25.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=1704878452; a=rsa-sha256; cv=none; b=uVspCmhri48aA1wiMQDhT8LAu/Au4qA1vyAlZkt7XAcayCDLSPRC4Stsph5/DV0aCfBC34 MTrkB+mGZb1HI3I4meLQILhe/8ffERN6NIVVMFEyYnxE/ciJOC6LKXdhkxVDa3YOaQ9Bnk 2rNwrPxjR5/fbP57V4Jn0lgGyj+Vl1Q= 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 3B8AF2F4; Wed, 10 Jan 2024 01:21:37 -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 33B583F64C; Wed, 10 Jan 2024 01:20:50 -0800 (PST) Message-ID: <4b38cf27-9aee-468c-bdfb-12637b59b600@arm.com> Date: Wed, 10 Jan 2024 09:20:48 +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> Cc: John Hubbard , 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> <3bd5e4a3-9f67-4483-9a0e-9abb5eb783cd@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7F557A001F X-Stat-Signature: 3g3uniyenzr374zazwc5b8batbringsi X-HE-Tag: 1704878452-267342 X-HE-Meta: U2FsdGVkX197I+PZMuZT4/QlY+KbOVO8a5PC+3ET/4eMCc/F5+4DY69eR2rmjZJ05FFgr7tMOPLT7IDIi0kcqbI9MTb/MO/YR5JGdwY5goGe6FNgfwb4ZGP756SFwHzwtFxtuG5LdPd+Q7TxdcbVNOvgKKPe/bOf+v8ADnoWGLi4kjWoTuDReYqZNjQ3EQCC8kH0quiYKEX3etieM7NrIzq1XHNarqMpgH8M1zoXjF+Bpz1m84OGnbHZ0MjYW0utNsYT3kXVvRcwVTBNMJlwP20ZJDu0FlOw3kBUpXUVLXq6foj/4DHO87NWmQOn4EWvEtjhpgA1nX5vGzJCUVpwOasfZlw0ThbcPXPODa+uFgVGtExF3B0bfOfptpFPjtmQdaAIqELQV6qHJarc8MmFBy8y1oFwBxPlJL5xBh2Luytclfh64Ni6KvCDrYWT+3rGKLq1jbB0qkKPvWcQpzkl48K1JPOJH2W15hEecSGU8bRnC1zdXgz1RZ7CeWPeGeImBk2e8HDOb5O//7n+s0KKcPSQPvrGQIgoNfBNw5HIdhnWVC2VfWNY4CAmSmZMVhzclODRDkZhtDyDslSQi2WnIwanWGCQ4fL+qTGrSTScXY9EwJhS0XcziSIAS+znXjXoW6VgM4LS9VDiSyuikw9VVLaWM/7S9+Jcjd/VAihMcahZkrdlFy8vjioUUV6PHZdbvazSbjUkxU2GlQzgCrzR5zZ99ORGDztmdEE/C+MvV/v5DPSZ5UgKkX1N0hCNn12ydiQ70BtaOkHUdpixzxLK7z64uD7PWPtodE6n2t1Dl8JO0FFNsHa5EfJEuWPq2/eH2sEcU5BRKCg/2TRZUxaDj0qmDf28uAtyqJER5ocmxLW3pibvPMSFFmKjbtrkUwy5sLRO4mmYOd02KGKusddIj1il6UAuK9TJno35izvUSnBBzJRs3WJfWQ2btB28ek3Ru6uKhyNlOLdtH9xO6zN o46ZZqk6 fvTl3u3Np3rH2ichcXxMUdNIJPRVDGHyVBuNQ2xg/DTefNM1ePW9mIPX5pGRFHOewTvseqOYRyVnU09OvpSAg91KJSWEJdXX5VgwZ5duG9/mrI86UXLRNj0SSs6//PMqDKC1iMuJknVPP2Ucg2KxrcZbWskSM7UHxDQVk76/jftlA/t9BJtPOq3n2JYcvkNR+oKNvLo5rwmElGniixqysET9gKsy2BhNRFOWQ 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 09:09, Barry Song wrote: > On Wed, Jan 10, 2024 at 4:58 PM Ryan Roberts wrote: >> >> 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? > > for debug purposes, it should be good. imaging there is a health > monitor which needs > to sample the stats of large folios online and periodically, this > might be too expensive. Yes, understood - the long term aim needs to be to get stats into the kernel. This is intended as a step to help make that happen. > >> >> 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