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 BE1D3C3DA6E for ; Wed, 10 Jan 2024 11:02:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D3F66B0099; Wed, 10 Jan 2024 06:02:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 35CD26B009A; Wed, 10 Jan 2024 06:02:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AF8F6B009B; Wed, 10 Jan 2024 06:02:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 02B4F6B0099 for ; Wed, 10 Jan 2024 06:02:53 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B9989140B54 for ; Wed, 10 Jan 2024 11:02:52 +0000 (UTC) X-FDA: 81663113784.03.3729D84 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 3BA96160019 for ; Wed, 10 Jan 2024 11:02:50 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AV6eSmbr; spf=pass (imf08.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704884570; 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:dkim-signature; bh=tD76wzdtsJlNvbHAByUCx8bSNol4ShJBHdcwlH/uwWk=; b=kn7UoMTPB8Ui0mgSfqVFcUW7L2qAJSiJkhBctsdCbuEU6YFkkKMA+xULjK7kdvVOr5jtuW OgQQGU8aUGbVfhAtjdRXJVAbmjI9Vp7KOGjMRlENqR6bN6UI1ootGTxZ+rrGxBmUwlCDpZ VTMg2R+FGHmRZuYdHdEoZacZmEifZnU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AV6eSmbr; spf=pass (imf08.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704884570; a=rsa-sha256; cv=none; b=jKCfBD3uWo2vXRj+AAckHdveQL2JXCzmYC9vACoJt11NOzfIgx4uWGJF1cleAYHhKFmASi f2YSJJz2Ny/90gvgOkfbiBbIhq7SZ64Vew5ux3s3avEftuqlwslT/bZNpswUYdpmJf/Kg6 WnepWyVGP/jy++JcU1rbdp+wyyeDr6I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704884569; h=from:from: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:autocrypt:autocrypt; bh=tD76wzdtsJlNvbHAByUCx8bSNol4ShJBHdcwlH/uwWk=; b=AV6eSmbrDsXG9ymnstqLgC567bQRp3EL5IhfAmuD3AWMv7OZxXUdMdyJlVBdpQqCSd5zQn p3Bkh2hlHJuJnBEp7KYIPg20PhmJc5sIDnW67i4xWqYEmNwF0ruGpw6AVrBeMWjQnpubHG Iy0FXKbN5DUDCbfl2d23m6bvviKfT2Q= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-07QeLSthOOCXZf0rUGgLYQ-1; Wed, 10 Jan 2024 06:02:48 -0500 X-MC-Unique: 07QeLSthOOCXZf0rUGgLYQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-40d3c533083so31766435e9.1 for ; Wed, 10 Jan 2024 03:02:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704884567; x=1705489367; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tD76wzdtsJlNvbHAByUCx8bSNol4ShJBHdcwlH/uwWk=; b=Xx5dQYdWsQDkR+2D0Y0xj28A0t8h2YZNVu+7SyT8s/kkFlwCMclpVl9gPdl29u8v6I bhFu1QFOq76hf2gENCZ9niBsTabNDOGBDmpnWARQzKCXhkj6SKsK2jNJlDQYIlLr31Rm QvFSOYbhwWV13oCT2BK+Mlij4VEd2Y7SZrv2E3fA9NJYD3GGwXdKuGO/Vc8/oSBZL2QJ 98AEfbqAg5bkYCeWaL6A40zNqdkRJNQRKtcm8emmJYyip1C0f7ALnEZw4+wDNQyRqMb/ yT3y7kY+JeQ4SuM9Q+Q5zT8RZhE7cAh7MeJI7F1UBpw8y8uNYPh+ApN84u6Q83GMtyF/ 9ciw== X-Gm-Message-State: AOJu0YyuuIHmfCowb/GXPDfRTCl1kjkRtspRtTyO0moqkIiA2Xu445Ay yBkqkuh7wg+Mn9YiS+mbqdu4cwHaABI8Qa/a3yIFpIvrKydXcOkAMBjfpyJaGwU9A9smu1GqgVj oH/mkHLwiQsdxniPlkM8= X-Received: by 2002:a05:600c:3486:b0:40e:5966:fcaa with SMTP id a6-20020a05600c348600b0040e5966fcaamr124489wmq.0.1704884567122; Wed, 10 Jan 2024 03:02:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQ3Km2t4gOd5pG8TiA3ch/XotQBVUU6u3PjEnSJwkC+R3VtxUYWyM5Ln1+2zjEDt+CQyCeKA== X-Received: by 2002:a05:600c:3486:b0:40e:5966:fcaa with SMTP id a6-20020a05600c348600b0040e5966fcaamr124478wmq.0.1704884566604; Wed, 10 Jan 2024 03:02:46 -0800 (PST) Received: from ?IPV6:2003:cb:c73d:de00:7cf7:9482:e5dc:6ad0? (p200300cbc73dde007cf79482e5dc6ad0.dip0.t-ipconnect.de. [2003:cb:c73d:de00:7cf7:9482:e5dc:6ad0]) by smtp.gmail.com with ESMTPSA id k16-20020a5d5190000000b00336c43b366fsm4628284wrv.12.2024.01.10.03.02.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Jan 2024 03:02:46 -0800 (PST) Message-ID: <70c30979-e793-4fcb-99b3-e9f2e8fbbf3b@redhat.com> Date: Wed, 10 Jan 2024 12:02:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v1] tools/mm: Add thpmaps script to dump THP usage info To: Ryan Roberts , Barry Song <21cnbao@gmail.com> Cc: John Hubbard , Andrew Morton , Zenghui Yu , Matthew Wilcox , 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> <94ebe62b-5f55-4be9-b464-4105b4692496@arm.com> <68d5ce7e-6587-47c6-bd0f-988adf5d92a4@arm.com> <714438db-b83b-41e7-bf73-b95267fa34c2@redhat.com> <8070266d-7cff-40c9-892c-2c7d1ca2e85d@arm.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCB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zu9w7Kv AxBQXWeXhJI9XQssfrf4Gusdqx8nPEpfOqCtbbwJMATbHyqLt7/oz/5deGuwxgb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <8070266d-7cff-40c9-892c-2c7d1ca2e85d@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3BA96160019 X-Rspam-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zYOQtssVjblMIsMW6JWpurh8hKM4eRDIGbsphNC4QXplEclwtxTV1H/9CnKLyTj7X2WTWPubRrJTA/NgKkhyxtRqJiw38chmUAgvUJLoyWMYK1t/d5LQx/VDcfkG9rVNi5IY4gcFYT4F0DG1NzEk6WgnbdUhBqqJA8X1Htuuw270X4PMcsf/sY9ehhECoWTWf5wvRRYw07l23xO1IlryqrkvMVZO+y83ypN7eaWIy7drNM9t25+9+TwlNyArG2CyJiSGTFrX/pdn4kusEjavapTfYSm1Mf5xndrkRog/OFmiMHRU1J2jiyOaTEEstbvOpbDGQLCLR+/3EYFcOm9mOvGhuXSA7urDUkt9R9p+gPi6DkzqNV72weQGjj/FnXnU102NfodLWwNNf7x2xRl6fewgeze8PSZlNUe57Y2g1nOQR10LLaPVrrj94T7qmucOvAvTe07A6jF2LC/TWUzNP4qPAy51JWiB++/hrZprug9POHam8OK6l+07OGE4v 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.24 11:58, Ryan Roberts wrote: > On 10/01/2024 10:54, David Hildenbrand wrote: >> On 10.01.24 11:48, Barry Song wrote: >>> On Wed, Jan 10, 2024 at 6:38 PM Ryan Roberts wrote: >>>> >>>> On 10/01/2024 10:30, Barry Song wrote: >>>>> On Wed, Jan 10, 2024 at 6:23 PM Ryan Roberts wrote: >>>>>> >>>>>> 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? >>>>>> >>>>>> Having now thought about this for a few mins (in the shower, if anyone >>>>>> wants the >>>>>> complete picture :) ), this won't quite work. This approach doesn't have the >>>>>> virtual mapping information so the best it can do is tell us "how many of each >>>>>> size of THP are allocated?" - it doesn't tell us anything about whether >>>>>> they are >>>>>> fully or partially mapped or what their alignment is (all necessary if we want >>>>>> to know if they are contpte-mapped). So I don't think this approach is >>>>>> going to >>>>>> be particularly useful. >>>>>> >>>>>> And this is also the big problem if we want to gather stats inside the kernel; >>>>>> if we want something equivalant to /proc/meminfo's >>>>>> AnonHugePages/ShmemPmdMapped/FilePmdMapped, we need to consider not just the >>>>>> allocation of the THP but also whether it is mapped. That's easy for >>>>>> PMD-mappings, because there is only one entry to consider - when you set >>>>>> it, you >>>>>> increment the number of PMD-mapped THPs, when you clear it, you decrement. But >>>>>> for PTE-mappings it's harder; you know the size when you are mapping so its >>>>>> easy >>>>>> to increment, but you can do a partial unmap, so you would need to scan the >>>>>> PTEs >>>>>> to figure out if we are unmapping the first page of a previously >>>>>> fully-PTE-mapped THP, which is expensive. We would need a cheap mechanism to >>>>>> determine "is this folio fully and contiguously mapped in at least one >>>>>> process?". >>>>> >>>>> as OPPO's approach I shared to you before is maintaining two mapcount >>>>> 1. entire map >>>>> 2. subpage's map >>>>> 3. if 1 and 2 both exist, it is DoubleMapped. >>>>> >>>>> This isn't a problem for us. and everytime if we do a partial unmap, >>>>> we have an explicit >>>>> cont_pte split which will decrease the entire map and increase the >>>>> subpage's mapcount. >>>>> >>>>> but its downside is that we expose this info to mm-core. >>>> >>>> OK, but I think we have a slightly more generic situation going on with the >>>> upstream; If I've understood correctly, you are using the PTE_CONT bit in the >>>> PTE to determne if its fully mapped? That works for your case where you only >>>> have 1 size of THP that you care about (contpte-size). But for the upstream, we >>>> have multi-size THP so we can't use the PTE_CONT bit to determine if its fully >>>> mapped because we can only use that bit if the THP is at least 64K and aligned, >>>> and only on arm64. We would need a SW bit for this purpose, and the mm would >>>> need to update that SW bit for every PTE one the full -> partial map transition. >>> >>> My current implementation does use cont_pte but i don't think it is a must-have. >>> we don't need a bit in PTE to know if we are partially unmapping a large folio >>> at all. >>> >>> as long as we are unmapping a part of a large folio, we do know what we are >>> doing. if a large folio is mapped entirely in a process, we get only >>> entire_map +1, >>> if we are unmapping a subpage of it, we get entire_map -1 and remained subpage's >>> mapcount + 1. if we are only mapping a part of this large folio, we >>> only increase >>> its subpages' mapcount. >> >> That doesn't work as soon as you unmap a second subpage. Not to mention that >> people ( :) ) are working on removing the subpage mapcounts. > > Yes, that was my point - Oppo's implementation relies on the bit in the PTE to > tell the difference between unmapping the first subpage and unmapping the > others. We don't have that luxury here. Yes, and once we're thinking of bigger folios that eventually span multiple page tables, these PTE-bit games won't scale. -- Cheers, David / dhildenb