Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp648643rwb; Wed, 26 Jul 2023 00:00:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlHm3job9RXg62JMwli1F7AsM/4UOpFHhKKhFnBJVHHyfdC4iaVEDBZ0aWfBNoJgUk+swOD0 X-Received: by 2002:aa7:d71a:0:b0:522:36e8:bc88 with SMTP id t26-20020aa7d71a000000b0052236e8bc88mr759992edq.12.1690354858830; Wed, 26 Jul 2023 00:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690354858; cv=none; d=google.com; s=arc-20160816; b=A49UOVTa/zE4Jp3igU8cRXPR4ENKQoI7t5Xsv3fBZLgtZDrGvvuP34XmAnzWervnFn 22croE9eEUwGGzHWgx8SmA6N1rWfFzO9D0osS1k62e2dDnQyUGh6kPlCJ6RrmsuwAj0E LBFrV4jdTRoauqVdfhuUcBYuUT8PlEixaoFybzXBcdC0ohf3u99IyDlj3+4J/i6aMH+E iGXxTHMjrTJQTvk9B2P10mfWf9SQso5oOO1wL6Xn6faSolCkb9u2XRatsXGAnwhkuUx+ Qop0CrhMKX2Im3Q2Tzn0l6c6j6l5CwagIR8Xy2AvGlB+NggkQBydAPdJLdTQYZtvSuGp DVzg== 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:subject:user-agent:mime-version:date:message-id; bh=oGKah+zZpY7eMBG6ew35+6MeM0tgLOYKjMmq066ah3o=; fh=zL42lwrWw90uiA//oVqo8O1+jC2c/jSOE2CrM5G914Q=; b=fnSepYpWFatLI0kV0Lr4dht4CW/g79x3Yxrpp+AhkgqNS41BAlXBj6fT+hOmx7Isyo kyluyrt5L6o8rHTWVB+rlQn/6TDhd9PkiJQ4EiL0qtJfgD+rU8/ynjmMDr2OG0TT9zS3 rt+fLiswH2paNeh2BPCVgySFGFwhM6+sHVxP/JAKdicibXEzS4BdUc6cOYzbJ9LMXn1s G+fw/Viyk11lH04tGRNBw+uI8IZynQgrNBsaHK3m2Djge0D4Qiwex8I6wQeqUJJhuCPi /JtMEm3tqOJwIT2DV60Da0bCs+O4lXCFE0xhLuHEPDyaD0Q+D42QODY0mldSBoMwOwz/ MnaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a056402028500b0052256bd1890si1532160edv.516.2023.07.26.00.00.34; Wed, 26 Jul 2023 00:00:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbjGZGmf (ORCPT + 99 others); Wed, 26 Jul 2023 02:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbjGZGmd (ORCPT ); Wed, 26 Jul 2023 02:42:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 07EA72132 for ; Tue, 25 Jul 2023 23:42:31 -0700 (PDT) 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 3BDEF11FB; Tue, 25 Jul 2023 23:43:14 -0700 (PDT) Received: from [10.57.77.6] (unknown [10.57.77.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3FB0B3F5A1; Tue, 25 Jul 2023 23:42:28 -0700 (PDT) Message-ID: <4ae1b75e-8e9b-c4f5-a50c-9fbeca245cee@arm.com> Date: Wed, 26 Jul 2023 07:42:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 2/3] mm: Implement folio_remove_rmap_range() To: Yu Zhao , Matthew Wilcox Cc: Andrew Morton , Yin Fengwei , David Hildenbrand , Yang Shi , "Huang, Ying" , Zi Yan , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230720112955.643283-1-ryan.roberts@arm.com> <20230720112955.643283-3-ryan.roberts@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26/07/2023 06:53, Yu Zhao wrote: > On Thu, Jul 20, 2023 at 5:30 AM Ryan Roberts wrote: >> >> Like page_remove_rmap() but batch-removes the rmap for a range of pages >> belonging to a folio. This can provide a small speedup due to less >> manipuation of the various counters. But more crucially, if removing the >> rmap for all pages of a folio in a batch, there is no need to >> (spuriously) add it to the deferred split list, which saves significant >> cost when there is contention for the split queue lock. >> >> All contained pages are accounted using the order-0 folio (or base page) >> scheme. >> >> page_remove_rmap() is refactored so that it forwards to >> folio_remove_rmap_range() for !compound cases, and both functions now >> share a common epilogue function. The intention here is to avoid >> duplication of code. >> >> Signed-off-by: Ryan Roberts >> --- >> include/linux/rmap.h | 2 + >> mm/rmap.c | 125 ++++++++++++++++++++++++++++++++----------- >> 2 files changed, 97 insertions(+), 30 deletions(-) >> >> diff --git a/include/linux/rmap.h b/include/linux/rmap.h >> index b87d01660412..f578975c12c0 100644 >> --- a/include/linux/rmap.h >> +++ b/include/linux/rmap.h >> @@ -200,6 +200,8 @@ void page_add_file_rmap(struct page *, struct vm_area_struct *, >> bool compound); >> void page_remove_rmap(struct page *, struct vm_area_struct *, >> bool compound); >> +void folio_remove_rmap_range(struct folio *folio, struct page *page, >> + int nr, struct vm_area_struct *vma); > > I prefer folio_remove_rmap_range(page, nr, vma). Passing both the > folio and the starting page seems redundant to me. I prefer to pass folio explicitly because it makes it clear that all pages in the range must belong to the same folio. > > Matthew, is there a convention (function names, parameters, etc.) for > operations on a range of pages within a folio? > > And regarding the refactor, what I have in mind is that > folio_remove_rmap_range() is the core API and page_remove_rmap() is > just a wrapper around it, i.e., folio_remove_rmap_range(page, 1, vma). I tried to do it that way, but the existing page_remove_rmap() also takes a 'compound' parameter; it can operate on compound, thp pages and uses the alternative accounting scheme in this case. I could add a compound parameter to folio_remove_rmap_range() but in that case the range parameters don't make sense - when compound is true we are implicitly operating on the whole folio due to the way the accounting is done. So I felt it was clearer for folio_remove_rmap_range() to deal with small page accounting only. page_remove_rmap() forwards to folio_remove_rmap_range() when compound=false and page_remove_rmap() directly deals with the thp accounting when compound=true. > > Let me post a diff later and see if it makes sense to you.