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 DF89BC4167B for ; Tue, 5 Dec 2023 14:02:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AD096B0099; Tue, 5 Dec 2023 09:02:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 75BD16B009A; Tue, 5 Dec 2023 09:02:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64AE76B009B; Tue, 5 Dec 2023 09:02:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 554396B0099 for ; Tue, 5 Dec 2023 09:02:52 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1CA0B1C030B for ; Tue, 5 Dec 2023 14:02:52 +0000 (UTC) X-FDA: 81532930584.08.280DCDD Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf20.hostedemail.com (Postfix) with ESMTP id 82A501C00B5 for ; Tue, 5 Dec 2023 14:02:32 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.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=1701784952; a=rsa-sha256; cv=none; b=e/lrTVy0f99Or/f40ivsZL8refZ0HCekT6fcRbTId64WFUSV/wiP8Zul0yQFVNCsxhDO/o Xd46B5nBRLXmrUDswcgqukEzqkq3ySnKnWCze2Ma2sA2CP/RSSBrAQKu+VwS/1eidmta7V le8E7cv3cnfP15dx9mTdHz6J6SLjgKE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.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=1701784952; 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=u9D7BV9xrZv5QhAmzxcGJGaHGh33W6GVA84bGgOea3A=; b=wsiqQOwHELVCehYkFpKMf3sB9YhcH7dWEKShQJhT5Mg3HieLrgqQ7FeWJCQ1mYVyGUteho NAutget54WlGWOvSpbNKO8k5tNerZJpmlDa25zBot+mBnvohl8PF3Rto4xpng4GtJVhz98 cXOyudHPcg5jvwb67JfGdLh3/HUxeis= 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 2B63A139F; Tue, 5 Dec 2023 06:03:18 -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 3854C3F6C4; Tue, 5 Dec 2023 06:02:30 -0800 (PST) Message-ID: Date: Tue, 5 Dec 2023 14:02:28 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC 34/39] mm/rmap: introduce folio_try_dup_anon_rmap_[pte|ptes|pmd]() 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> <20231204142146.91437-35-david@redhat.com> <88a341bf-0b6a-454a-aeb1-0699233eb37c@redhat.com> <181a1623-9285-415e-9ec6-6b6548ca7487@arm.com> <0f2bc27e-af1a-4590-985a-dc6bacdbcd57@redhat.com> From: Ryan Roberts In-Reply-To: <0f2bc27e-af1a-4590-985a-dc6bacdbcd57@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 82A501C00B5 X-Stat-Signature: 5qkkzs5y7c5wnkarw5mgby6hgjhgsqwq X-HE-Tag: 1701784952-504095 X-HE-Meta: U2FsdGVkX1876DcwNb3gT1QtF+ewiqW066wMNkk56RvbeoscFa16qmie+9J0upLnf2/rPGNxvhat53M09ovol0HfbNsxCrWDUzIQZlYVYIrotsCN/PA9ZXAcQoOHGP/FIQdsCPDXplsFqzc7+o9XFOk3RLyjZ3Q5Hmp1Pq/Hne97fo94lOOO+7ZoHmsiTEQ4JKQF8nHIWvSxzzEBSAaL4ug7+VXx/VHE4cZb3ezYP+M9lMFFT6h4+M7FhdcbJGMVePB2djuNmzvM9Z8Mh9XI0Pcz01kBzy3WhOW4ezlA/OipLbdes1ZbHIYKhbIKY61K3nvSPM6DHAFgJZvrGnjXTZa3yyAs+AJJ3+ofNiXIdoGtS7RY2lRiJOrgcvukbwiJwTKKWns/1sQm0qrI38bH5eyUJJCS+MC+VNcZYlvllUte0LybOngtWMCJp9Jo3hKZbHcP+3Bsjh9z1/V2ojsWkPUP7o1lPPCOe2hLSbINXwfv6k1dqBarvILsE4jf9s787xtR18OemGO4QlXVpn6fiaDM9c0jLGlKLQ3EQ2lBzxibfDdojeHlPAPkHuI4JD8DJxM9UIIcGgJqOjYx2SJnPbY875bk8yYn1hQTARDfany0lEEbH2TurfVDA2fzB+mF1xTely16YemLbYNGBXjxBbKuT/CVFqxDU6pHCRIGd8mMy+WnP15iKupdnD7dU0kJmyddo+HEvAucC3M4pYKcTBhVZTidRkwpEMNaGNtVHApeNL5IRKi0VvkTzEvu3dUnzeyMQIwdE5fHUsmhE5QtCkxV/pxe3zf0g4ieBqgVr/X3sPQDuPyZVXGhu0Sx2xxy9d6jlP7SrTvTtXkwK339U2OQol9npy49GzEcCDNDx8Rbzbah1Fvm1MObrhVl8r3IDRJYzgTIv2hyXyRHD4qAICeyfH5envieoBslJOrwWsU/DDYsqYEPGlhivrCV6EyH8xtTSL1higPfyN/ci1a ByVGpxoz 2hFgeTZ4YqHSGSIjxizAMJlSrRuZWd45Irb4S7lSOMKabHD8gb9qs25WaSskYU5VTBSYZ1lcKSeAWgVc/8BNDBahXAj+zko1f3vN9tXvXIFnU2ITSDaEhvU0N8hn+GFKjewddqSb1wc9UxJir3d4aMiav95pIT8xOXG6OCwNnvIUWF6ptiRtKbKvW/vUCFV46mxd2VNDtIaNCwsr0EIwqkAa1Qw== 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 13:50, David Hildenbrand wrote: > On 05.12.23 14:40, Ryan Roberts wrote: >> On 05/12/2023 13:18, David Hildenbrand wrote: >>> On 05.12.23 14:17, David Hildenbrand wrote: >>>> On 05.12.23 14:12, Ryan Roberts wrote: >>>>> On 04/12/2023 14:21, David Hildenbrand wrote: >>>>>> The last user of page_needs_cow_for_dma() and __page_dup_rmap() are gone, >>>>>> remove them. >>>>>> >>>>>> Add folio_try_dup_anon_rmap_ptes() right away, we want to perform rmap >>>>>> baching during fork() soon. >>>>>> >>>>>> Signed-off-by: David Hildenbrand >>>>>> --- >>>>>>     include/linux/mm.h   |   6 -- >>>>>>     include/linux/rmap.h | 145 +++++++++++++++++++++++++++++-------------- >>>>>>     2 files changed, 100 insertions(+), 51 deletions(-) >>>>>> >>>>>> diff --git a/include/linux/mm.h b/include/linux/mm.h >>>>>> index 24c1c7c5a99c0..f7565b35ae931 100644 >>>>>> --- a/include/linux/mm.h >>>>>> +++ b/include/linux/mm.h >>>>>> @@ -1964,12 +1964,6 @@ static inline bool folio_needs_cow_for_dma(struct >>>>>> vm_area_struct *vma, >>>>>>         return folio_maybe_dma_pinned(folio); >>>>>>     } >>>>>>     -static inline bool page_needs_cow_for_dma(struct vm_area_struct *vma, >>>>>> -                      struct page *page) >>>>>> -{ >>>>>> -    return folio_needs_cow_for_dma(vma, page_folio(page)); >>>>>> -} >>>>>> - >>>>>>     /** >>>>>>      * is_zero_page - Query if a page is a zero page >>>>>>      * @page: The page to query >>>>>> diff --git a/include/linux/rmap.h b/include/linux/rmap.h >>>>>> index 21d72cc602adc..84439f7720c62 100644 >>>>>> --- a/include/linux/rmap.h >>>>>> +++ b/include/linux/rmap.h >>>>>> @@ -354,68 +354,123 @@ static inline void folio_dup_file_rmap_pmd(struct >>>>>> folio *folio, >>>>>>     #endif >>>>>>     } >>>>>>     -static inline void __page_dup_rmap(struct page *page, bool compound) >>>>>> +static inline int __folio_try_dup_anon_rmap(struct folio *folio, >>>>> >>>>> __always_inline? >>>> >>>> Yes. >>> >>> Ah, no, I did this for a reason. This function lives in a header, so it will >>> always be inlined. >>> >> >> Really? It will certainly be duplicated across every compilation unit, but >> that's separate from being inlined - if the optimizer is off, won't it just end >> up as an out-of-line function in every compilation unit? > > Good point, I didn't really consider that here, and thinking about it it makes > perfect sense. > > I think the compiler might even ignore "always_inline". I read that especially > with recursion the compiler might ignore that. But people can then complain to > the compiler writers about performance issues here, we told the compiler what we > think is best. > To be honest, my comment assumed that you had a good reason for using __always_inline, and in that case then you should be consistent. But if you don't have a good reason, you should probably just use inline and let the compiler do what it thinks best?