Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp293208rdb; Tue, 5 Dec 2023 05:49:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqNnjIVQ2G1Gr3AeUjRUlW7EunbXgyaDsEobNZdPkS0YRkQ9elMFyU47l0cTODgZwaK9E2 X-Received: by 2002:a05:6a00:1d23:b0:6ce:2731:5f6d with SMTP id a35-20020a056a001d2300b006ce27315f6dmr1028216pfx.44.1701784184975; Tue, 05 Dec 2023 05:49:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701784184; cv=none; d=google.com; s=arc-20160816; b=ZLYC7wZHTjRWNYNU5VECE6TUcEmQCmVmAu1bugN5qMH5dUDFjf0dGLg3PRNdMz/nke gRF+N2VDMf2z1+M0nXU2STNe8Jxt8b/L+z+HUEkawvjqVZdKNPET/5NKXEjDJGmpRCCR SX/xjFe4iAgRmks5eQliFoD9fX/FC8mEM1Tx48kkLMKD+6DMd7Lp7lO2rjATzbMlAflG ELTQoCb3T9a3IzO8Z+Z79cEMFzEvEKVYvFTMjgsOePgGeqDbmw5HIbadHrJTSrjFUntW cPyRcQ4579R9CKLmyEKXeRyrKiUIlIDkr50P+Qfto1du9q1PwFo0KkkqBDr5vPWZ3EWt bioA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=av/vJIbAbCBZZrA7PfY/oE3PRACpg3Nwje776j3lDJo=; fh=GlLzLBhqF07GE0FJUf82nnkBDPyXS9iIZ0BDzvPX32s=; b=IWYxyDYJoMukAqwzjkV1sRKXVbv9K0gEYvrZuTfWDG4bLwZoQ8GEimvr2m/e3o84A5 5RfCr+mpVPQpfb3tvLW1WPi7SWK6uMRwafNImDNjdO/tn4yiba9OYVeZBZboVy+xWJii qz/60q4Z33h7O63sYL5GSvRhdK8Nktnxoq+m2b4nobIyGGNcxgQL5GB8MwldpHyhfWZH ZQH6aT6l8adOgsceynf7u105QMDT70jMfigvx2gt8yBOx6GO90CvPpzgV/FgK/RD+4SC j+K6yVOAxqYI9IKSqfT87O/029/kdT7aNmepY+Crg589ux8GYJeUIWlrWzDvV9QG/2ro KOEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id q14-20020a65684e000000b005c67a42a55fsi4583107pgt.732.2023.12.05.05.49.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 05:49:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3CB4E822D572; Tue, 5 Dec 2023 05:49:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345524AbjLENtZ (ORCPT + 99 others); Tue, 5 Dec 2023 08:49:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345418AbjLENtZ (ORCPT ); Tue, 5 Dec 2023 08:49:25 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C583EB2 for ; Tue, 5 Dec 2023 05:49:30 -0800 (PST) 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 1B45D139F; Tue, 5 Dec 2023 05:50:17 -0800 (PST) Received: from [10.57.73.130] (unknown [10.57.73.130]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0837B3F6C4; Tue, 5 Dec 2023 05:49:28 -0800 (PST) Message-ID: Date: Tue, 5 Dec 2023 13:49:27 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC 00/39] mm/rmap: interface overhaul Content-Language: en-GB To: David Hildenbrand , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Andrew Morton , "Matthew Wilcox (Oracle)" , Hugh Dickins , Yin Fengwei , Mike Kravetz , Muchun Song , Peter Xu References: <20231204142146.91437-1-david@redhat.com> <993ea322-8cdb-4ab1-84d3-0a1cb40049c9@arm.com> <067753e4-faf0-4bc0-9703-ec97b7de705e@redhat.com> <1ba5dd86-a201-4243-bab0-349395468236@arm.com> <537ac106-e4f6-4845-aa09-29b775269562@redhat.com> From: Ryan Roberts In-Reply-To: <537ac106-e4f6-4845-aa09-29b775269562@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 05 Dec 2023 05:49:42 -0800 (PST) On 05/12/2023 13:39, David Hildenbrand wrote: > On 05.12.23 14:31, Ryan Roberts wrote: >> On 05/12/2023 09:56, David Hildenbrand wrote: >>>>> >>>>> Ryan has series where we would make use of folio_remove_rmap_ptes() [1] >>>>> -- he carries his own batching variant right now -- and >>>>> folio_try_dup_anon_rmap_ptes()/folio_dup_file_rmap_ptes() [2]. >>>> >>>> Note that the contpte series at [2] has a new patch in v3 (patch 2), which >>>> could >>>> benefit from folio_remove_rmap_ptes() or equivalent. My plan was to revive [1] >>>> on top of [2] once it is merged. >>>> >>>>> >>>>> There is some overlap with both series (and some other work, like >>>>> multi-size THP [3]), so that will need some coordination, and likely a >>>>> stepwise inclusion. >>>> >>>> Selfishly, I'd really like to get my stuff merged as soon as there is no >>>> technical reason not to. I'd prefer not to add this as a dependency if we can >>>> help it. >>> >>> It's easy to rework either series on top of each other. The mTHP series has >>> highest priority, >>> no question, that will go in first. >> >> Music to my ears! It would be great to either get a reviewed-by or feedback on >> why not, for the key 2 patches in that series (3 & 4) and also your opinion on >> whether we need to wait for compaction to land (see cover letter). It would be >> great to get this into linux-next ASAP IMHO. > > On it :) > >> >>> >>> Regarding the contpte, I think it needs more work. Especially, as raised, to not >>> degrade >>> order-0 performance. Maybe we won't make the next merge window (and you already >>> predicated >>> that in some cover letter :P ). Let's see. >> >> Yeah that's ok. I'll do the work to fix the order-0 perf. And also do the same >> for patch 2 in that series - would also be really helpful if you had a chance to >> look at patch 2 - its new for v3. > > I only skimmed over it, but it seems to go into the direction we'll need. > Keeping order-0 performance unharmed should have highest priority. Hopefully my > microbenchmarks are helpful. Yes absolutely - are you able to share them?? > >> >>> >>> But again, the conflicts are all trivial, so I'll happily rebase on top of >>> whatever is >>> in mm-unstable. Or move the relevant rework to the front so you can just carry >>> them/base on them. (the batched variants for dup do make the contpte code much >>> easier) >> >> So perhaps we should aim for mTHP, then this, then contpte last, benefiting from >> the batching. > > Yeah. And again, I don't care too much if I have to rebase on top of your work > if this here takes longer. It's all a fairly trivial conversion. > >>> >>> [...] >>> >>>>> >>>>> >>>>> New (extended) hugetlb interface that operate on entire folio: >>>>>    * hugetlb_add_new_anon_rmap() -> Already existed >>>>>    * hugetlb_add_anon_rmap() -> Already existed >>>>>    * hugetlb_try_dup_anon_rmap() >>>>>    * hugetlb_try_share_anon_rmap() >>>>>    * hugetlb_add_file_rmap() >>>>>    * hugetlb_remove_rmap() >>>>> >>>>> New "ordinary" interface for small folios / THP:: >>>>>    * folio_add_new_anon_rmap() -> Already existed >>>>>    * folio_add_anon_rmap_[pte|ptes|pmd]() >>>>>    * folio_try_dup_anon_rmap_[pte|ptes|pmd]() >>>>>    * folio_try_share_anon_rmap_[pte|pmd]() >>>>>    * folio_add_file_rmap_[pte|ptes|pmd]() >>>>>    * folio_dup_file_rmap_[pte|ptes|pmd]() >>>>>    * folio_remove_rmap_[pte|ptes|pmd]() >>>> >>>> I'm not sure if there are official guidelines, but personally if we are >>>> reworking the API, I'd take the opportunity to move "rmap" to the front of the >>>> name, rather than having it burried in the middle as it is for some of these: >>>> >>>> rmap_hugetlb_*() >>>> >>>> rmap_folio_*() >>> >>> No strong opinion. But we might want slightly different names then. For example, >>> it's "bio_add_folio" and not "bio_folio_add": >>> >>> >>> rmap_add_new_anon_hugetlb() >>> rmap_add_anon_hugetlb() >>> ... >>> rmap_remove_hugetlb() >>> >>> >>> rmap_add_new_anon_folio() >>> rmap_add_anon_folio_[pte|ptes|pmd]() >>> ... >>> rmap_dup_file_folio_[pte|ptes|pmd]() >>> rmap_remove_folio_[pte|ptes|pmd]() >>> >>> Thoughts? >> >> Having now reviewed your series, I have a less strong opinion, perhaps it's >> actually best with your original names; "folio" is actually the subject after >> all; it's the thing being operated on. >> > > I think having "folio" in there looks cleaner and more consistent to other > functions. > > I tend to like "rmap_dup_file_folio_[pte|ptes|pmd]()", because then we have > "file folio" and "anon folio" as one word. > > But then I wonder about the hugetlb part. Maybe simply > "hugetlb_rmap_remove_folio()" etc. > > Having the "hugetlb_" prefix at the beginning feels like the right thing to do, > looking at orher hugetlb special-handlings. > > But I'll wait a bit until I go crazy on renaming :) I suspect we could argue in multiple directions for hours :) Let's see if others have opinions. FWIW, I've looked through all the patches; I like what I see! This is a really nice clean up and will definitely help with the various patch sets I've been working on. Apart from the comments I've already raised, looks in pretty good shape to me. > >> >>> >>>> >>>> I guess reading the patches will tell me, but what's the point of "ptes"? >>>> Surely >>>> you're either mapping at pte or pmd level, and the number of pages is >>>> determined >>>> by the folio size? (or presumably nr param passed in) >>> >>> It's really (currently) one function to handle 1 vs. multiple PTEs. For example: >>> >>> void folio_remove_rmap_ptes(struct folio *, struct page *, unsigned int nr, >>>          struct vm_area_struct *); >>> #define folio_remove_rmap_pte(folio, page, vma) \ >>>      folio_remove_rmap_ptes(folio, page, 1, vma) >>> void folio_remove_rmap_pmd(struct folio *, struct page *, >>>          struct vm_area_struct *); >> >> Yeah now that I've looked at the series, this makes sense. "ptes" was originally >> making me think of contpte, but I suspect I'll be the only one with that >> association :) > > Ah, yes :) >