Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp301458rdb; Tue, 5 Dec 2023 06:02:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtGxWB+4aoetBtsTYSOc4maDF7hu+dEYBdDTMxYXOyGhGX9K0F2dqZLLEVxTAxQeGKa0uc X-Received: by 2002:a05:6808:308c:b0:3b8:6ee4:1460 with SMTP id bl12-20020a056808308c00b003b86ee41460mr7643916oib.59.1701784974766; Tue, 05 Dec 2023 06:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701784974; cv=none; d=google.com; s=arc-20160816; b=Qw6oo2hJ0epTmZXuc5NEGWS7pXe8Y4KjfhYRyMFEQiJuc4XSxvDGNOLgdlPCiKcNZ9 k+Y+g47EkS7wN5fTVHo7ugRwMvkwT1KVk0eWa7mNI2GQA3CLtmBtT3ert4ISqaXi4Nuh i/chcxDxyBZmJrHzOSf0p/1Q7StjG3fztMPpJJ049unVTGPySPVXbh2iqnD3ksX9RAjT e+y5tiq4xUzOI+49SRxnJyzZ+7goPeqvpiM7aWFR1GcFf6XfcfWqryDGlYmOQVkXGnFe EivJC/xLixbYIgIJL0EogFTx/d//J6u4XsdOZimWYwkBJKxMuKR7jdiG/2D/k5qAxeAF VRiA== 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=u9D7BV9xrZv5QhAmzxcGJGaHGh33W6GVA84bGgOea3A=; fh=GlLzLBhqF07GE0FJUf82nnkBDPyXS9iIZ0BDzvPX32s=; b=002u3XZMVyO4xyddREyu0/BtbwDP89B+/D+EOg2RZxUXK2CEbV70sepqJGIHI+q1FZ 50asPeARoRG8S0DaN+Il49m6+4oNJW7ZSPoLIH6WACKHK9CiiBKG0ZZjl5vu/WDt1YG6 R8HQL77+ph4XtrPoMIkseR0Mfi8wt5SQ69JcthvN2KwCrT1qUDvN3uCzfNbxfR1AiLr3 tCTGsKxZzxce+FnlPBdX6m0UiI8kNg2ffQVBMbSbt8TOTzmsKrF3lF0iq3/2+HWj2T0X MOXj6CW4M2WOiQ61BREo9C+/vWdNgGXs5NNfX2nYUHnw33/1yOKJJqvBtk0Hjw401Hr1 9tnA== 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:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id s3-20020a05680810c300b003b6d8440165si3932684ois.177.2023.12.05.06.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:02:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 4F02880947C4; Tue, 5 Dec 2023 06:02:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345588AbjLEOC1 (ORCPT + 99 others); Tue, 5 Dec 2023 09:02:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345556AbjLEOC0 (ORCPT ); Tue, 5 Dec 2023 09:02:26 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 392BCB2 for ; Tue, 5 Dec 2023 06:02:32 -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 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-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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 05 Dec 2023 06:02:42 -0800 (PST) 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?