Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp966880rwb; Fri, 28 Jul 2023 02:39:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlHriHeHuDrTDWcvZ1Y+rkOUJUGlJlRNg4bRTUqAxGAcPJE2p6CmWzrSPMLFeOFTWdRitI5M X-Received: by 2002:a17:906:310d:b0:99b:e243:9ecc with SMTP id 13-20020a170906310d00b0099be2439eccmr1672561ejx.36.1690537165767; Fri, 28 Jul 2023 02:39:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690537165; cv=none; d=google.com; s=arc-20160816; b=PRrTJEToeqwY6WV0DHd668bzNuuL6faFiw9LSjKoG8GtJMEXJA+kdaP9buPUS0QfiP vTAqDQ6vUe5JHp7wQ+7gR4pS8S3eJ99ubAU/kJMQZg+8rKs52oIqXOlnlNQyTSXgBH74 ia4kxMR7wHz2gQsCNWaP4u4XBHMjI6Jgawl0cP2iL+iSPO33D8n7qfkB3R7s02vjk8BW NS5Hi2AjQeL2tHR3wIOmNzjDn99kzvK3ocIFZ/YzgqPJX16j9xSmiCL+WI/QW8dImDEM EAhE/CWRrPWjwqo8fJn1dVW6u4iCuMRGpGJ7nz0TDNHDlh0sULI5c1nON46zuh/f90Xq cYCw== 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=rnAsgMILAtDi0kyf+w3kWqpB1Q75byCHrtNBX6IF+oQ=; fh=Yjg2ja0xfRmcTeBdDtw2hjZEspytBTgCfc6Sbd1Q33Q=; b=YgNUtQNS8eMch3gziSHCkN94a0U12dY5Hg9UgT+JSffO4wtX5z81X9H5T0qq8rlwTi PIpAwvhSdmUN2/uNW2u2kDABqpnIp7h88ee8ol7HszR1MlAdqU4GJB4xS4RdTHAv80Ya v6zvrVrc7b1nksoIhktKZXWzrrmvUJkbSoVCTomsWE+236tYf5mmPz8YlQKOSIiwc5Bl pjKyt8QJCG/+3pTC2kWHOG5E5MG7MblfQBnITufv5Vc+FqF3LDZQhkR1asYL4uA7mnc5 rmIXToe3MV0k5ytSh5XmInNeD1BFeymnkfGD7umT9hpe+AzhpMeFqdl51frfOvVJHRwW cagg== 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 w24-20020a17090652d800b0099845f657a8si2528639ejn.616.2023.07.28.02.39.01; Fri, 28 Jul 2023 02:39:25 -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 S235048AbjG1JAb (ORCPT + 99 others); Fri, 28 Jul 2023 05:00:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234102AbjG1JA0 (ORCPT ); Fri, 28 Jul 2023 05:00:26 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EE72DE69 for ; Fri, 28 Jul 2023 02:00:24 -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 BDCB32F4; Fri, 28 Jul 2023 02:01:07 -0700 (PDT) Received: from [10.57.77.173] (unknown [10.57.77.173]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 240D23F67D; Fri, 28 Jul 2023 02:00:23 -0700 (PDT) Message-ID: <3c26aa4e-fe11-09d2-c2fb-63546ba80893@arm.com> Date: Fri, 28 Jul 2023 10:00:21 +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 Cc: Matthew Wilcox , "Huang, Ying" , Andrew Morton , Yin Fengwei , David Hildenbrand , Yang Shi , 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> <87r0ouw39n.fsf@yhuang6-desk2.ccr.corp.intel.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 27/07/2023 17:38, Yu Zhao wrote: > On Thu, Jul 27, 2023 at 1:26 AM Ryan Roberts wrote: >> >> On 27/07/2023 03:35, Matthew Wilcox wrote: >>> On Thu, Jul 27, 2023 at 09:29:24AM +0800, Huang, Ying wrote: >>>> Matthew Wilcox writes: >>>>> I think that can make sense. Because we limit to a single page table, >>>>> specifying 'nr = 1 << PMD_ORDER' is the same as 'compound = true'. >>>>> Just make it folio, page, nr, vma. I'd actually prefer it as (vma, >>>>> folio, page, nr), but that isn't the convention we've had in rmap up >>>>> until now. >>>> >>>> IIUC, even if 'nr = 1 << PMD_ORDER', we may remove one PMD 'compound' >>>> mapping, or 'nr' PTE mapping. So, we will still need 'compound' (or >>>> some better name) as parameter. >>> >>> Oh, this is removing ... so you're concerned with the case where we've >>> split the PMD into PTEs, but all the PTEs are still present in a single >>> page table? OK, I don't have a good answer to that. Maybe that torpedoes >>> the whole idea; I'll think about it. >> >> This is exactly why I think the approach I've already taken is the correct one; >> a 'range' makes no sense when you are dealing with 'compound' pages because you >> are accounting the entire folio. So surely its better to reflect that by only >> accounting small pages in the range version of the API. > > If the argument is the compound case is a separate one, then why not a > separate API for it? > > I don't really care about whether we think 'range' makes sense for > 'compound' or not. What I'm saying is: > 1. if they are considered one general case, then one API with the > compound parameter. > 2. if they are considered two specific cases, there should be two APIs. > This common design pattern is cleaner IMO. Option 2 definitely makes sense to me and I agree that it would be cleaner to have 2 separate APIs, one for small-page accounting (which can accept a range within a folio) and one for large-page accounting (i.e. compound=true in today's API). But... 1) That's not how the rest of the rmap API does it 2) This would be a much bigger change since I'm removing an existing API and replacing it with a completely new one (there are ~20 call sites to fix up). I was trying to keep the change small and manageable by maintaining the current API but moving all the small-page logic to the new API, so the old API is a wrapper in that case. 3) You would also need an API for the hugetlb case, which page_remove_rmap() handles today. Perhaps that could also be done by the new API that handles the compound case. But then you are mixing and matching your API styles - one caters for 1 specific case, and the other caters for 2 cases and figures out which one. > > Right now we have an overlap (redundancy) -- people would have to do > two code searches: one for page_remove_rmap() and the other for > folio_remove_rmap_range(nr=1), and this IMO is a bad design pattern. I'm open to doing the work to remove this redundancy, but I'd like to hear concensus on this thread that its the right approach first. Although personally I don't see a problem with what I've already done; If you want to operate on a page (inc the old concept of a "compound page" and a hugetlb page) call the old one. If you want to operate on a range of pages in a folio, call the new one. Thanks, Ryan