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 076A5C4167B for ; Tue, 5 Dec 2023 13:31:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 91E4F6B0088; Tue, 5 Dec 2023 08:31:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CE916B0089; Tue, 5 Dec 2023 08:31:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7965C6B0093; Tue, 5 Dec 2023 08:31:32 -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 654B76B0088 for ; Tue, 5 Dec 2023 08:31:32 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0F484120112 for ; Tue, 5 Dec 2023 13:31:32 +0000 (UTC) X-FDA: 81532851624.16.AE92081 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf19.hostedemail.com (Postfix) with ESMTP id D267D1A001A for ; Tue, 5 Dec 2023 13:31:29 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701783090; 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=5dFA+eVVcywgcTXfc77euqPDZsMl6aYScjZBoTyRN+c=; b=2VEBYTr9rBTnTGDu8P11oVVsFSCiZlNJkYy7jil1sN/PDUEcQ7qYAjk4pmWZXdfbhmo986 9JzC5kPv6exHZbSeShe5FWcR4+A92AaNr36EIBm5lwkFdf/KrrSxLx24MeduIpH8wR4KDn sPFnG/bA1eKWP2TVZ91llnDq4MGOC6g= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701783090; a=rsa-sha256; cv=none; b=RFDmyo6GbtovEiEs83cM716xcaJZ3BdW24lXSjvULZiwSf4pYhVA9fD20B9OLPtbjyKJcT rxPLqt87d2b2OpVNCJvAg6BGzUO/MCh+iuCVmW5YpkVF4z8orcKhaqFs7T89vlKVjYh/+A qjdRMqRJ/ni00PaNUyE/5AWDyzc5cOs= 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 71E99139F; Tue, 5 Dec 2023 05:32:15 -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 72AC43F5A1; Tue, 5 Dec 2023 05:31:27 -0800 (PST) Message-ID: <1ba5dd86-a201-4243-bab0-349395468236@arm.com> Date: Tue, 5 Dec 2023 13:31:25 +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> From: Ryan Roberts In-Reply-To: <067753e4-faf0-4bc0-9703-ec97b7de705e@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D267D1A001A X-Rspam-User: X-Stat-Signature: nohieo7rces6rt1865imeqgysgaxwuyk X-Rspamd-Server: rspam01 X-HE-Tag: 1701783089-930240 X-HE-Meta: U2FsdGVkX1+SbgcbTII+wxgC4iShsc3fFCffdmsjkzRNE5RHpZWucdNKghL/r7JrtJ5BWC00IxyJkp2+/8vuc/ahd7pefVoeKS9TMMUvmKkDIkvduhaA0iLTXfd0fN8rXgjTWSgU2ncMkB2wbd0DfkKtlcvD2zlo1JUJH7zeAZxciNi57N8PFMFdtf7kWhyu+fmprwpumeLFODrkFue+Lv6y7g2clFY1yvr3dW5JQDqBlFIUwtTcDJjZQ+1D1qFfSLl95VP2Wlrpik71PwaDJxt5MCfX45T2kQcZxGPeETwagGDxofrDg/ybD/sE/RKUm9kpkcrVtPOdZwd7f+BX0aAwQmwL+2Iaoqm1Mw3daRzAQBM3jntzh5k1gZ8Y5zKVUR+KmeDhYQBNvyMZ/QtasTU6+KDfQBZ6FXUa8QQW/NAXImxoGabNYNX+C2lBHPt9m1A0qt49p8odr6jHP5k6jxn6SDpDUnz+G2cJ+6fC/HnBaDzVA+PeG1CevNQXqzHQ1RQI3E0GkmtaDtAuA28Nte3Dz7BNma7UUefg06ub8BFwxkm29Ukfh1e+s3HyngyEFbtX/2wA7xLrWI7gacHcoBdXUoRLTqy1qf11yYZ6ddwPYBPyfV+fzs/VF7lt7wdcCvQsx1C3wIbc37jUItCcmX8cJb+FSNXrGL4WRBnVsxXpNV/iFaa/0bTp0NURrYlJDzMbH+Xjumo9BFxf7VoSLxkfV/Y5lOcjST019Jh/7TMo5P6ANwkmmtEFibP03l1nXEvEiMP4rcg2Knqm2Ick8p8YtnqbHYf5EyepAWyX5WXuwFmH90+IYQQgZlCAsEA2A60e9lReN8PppxF6UoahZDujm0hbxGdLh5Y5Ex2f/xKVoxqVoCSVvGiG82Lkk1WD7V2KdKq5ZbpzdjU9S8qfnMYw3rZKpwtCVvdTnPhkXw6Qd3+mn3wAtb27jJNyMrK6sKalzNeYxtsMN/YHKvF /VLCm2oF d85HbpH0hogvbFn1KFPpzKeJCRbu8HdVg79eS6of5mY1jlTTxec+H8tKwfk4HLZriDNyxFAaqZd+UscrPEhwUlD7UoKGwLhD6NrsWqHOo0eD0LNSE+pjO2l9wQP9crIidMVDKDHjkekC2dK4Ax0YCR8SVPw== 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 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. > > 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. > > 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. > > [...] > >>> >>> >>> 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 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 :) > > > Once could let the compiler generate specialized variants for the single-pte > versions to make the order-0 case faster. For now it's just a helper macro. >