Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp148377rwb; Thu, 27 Jul 2023 10:33:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlG7sYTPmijtwQ0IE/6mglOQdhA1OevkXQ08CeUshCmt8g/Zg1sNyzR/+BrHPt+jkcMi4KYm X-Received: by 2002:a05:6a20:6d1d:b0:132:bdba:5518 with SMTP id fv29-20020a056a206d1d00b00132bdba5518mr5878154pzb.54.1690479233212; Thu, 27 Jul 2023 10:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690479233; cv=none; d=google.com; s=arc-20160816; b=G9MCebKPbfGR6OMgdRNM1Mr6BZk7s0Tr6zW89kwjXO1F+uaqkt8AqYOqC31BRwPtsJ MonWTJZAVxdMKPTAXExAMflG70z2+sS9i9exfoN+QOxx2jKUK8l+sPdaIRTGmCc4bOF5 H6xtI4GR3qjw05V4R8OhRx6yZR0ENz+VeUo9INmNIcRMRObw1YC/r5ZYMOQJ8CLUDLcN jvQVBoNLAlLiBU5P53yxVEayHkV7x11t7QGKFIFeVwDj9PwPV/NC97IqBH9oZtnZtjLu 823k9yLIXNm0W21wA0DdyfPd8hmtco/QkdDhbl0UuzpBreZegtyTp/GkREDme/Qj6Kny s5rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=2yDMqgwJZJpeLWzTC3EjN9bRwWDIhFu5M1m3QL8b53s=; fh=W+zRaSlwm0oumvYDqrRaxNIjsVvEtYHeEyqKXSjefoI=; b=dpkKubBQbbQdAA3BBIhme/m9yjp6uTUr5q544uTc18VC7RXcp9tGpjBZUIn1OKS3n6 ITAN9/aECu6XRHWmyHyzzHdEUd669Sjv0OVpZjl4vsd2X/gKDsYFZQe0c8ayGZSkTkFh UGk19kfVloS9lwQzAh8aTIs0hfYMglfltr+/0vxP6KqEjnb8jYTN6EwX1VDpN6PKeStm 3y9Ssf3KyZ60KiDwiFnuP9PLFWBdaQ+MuGuUe/8yvMQBmbrV+6ijSYC0EHzN/Tu5MnfA eaSWx51kfIQClN6TbeWFdLwR002axn6DkH6/xDQcJzpyCo4J7TxzkoFDMYKAECX93aB0 FZ6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=AdhfcTm8; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c66-20020a633545000000b00563fc0d174esi138762pga.819.2023.07.27.10.33.41; Thu, 27 Jul 2023 10:33:53 -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; dkim=pass header.i=@google.com header.s=20221208 header.b=AdhfcTm8; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbjG0QjV (ORCPT + 99 others); Thu, 27 Jul 2023 12:39:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232135AbjG0QjU (ORCPT ); Thu, 27 Jul 2023 12:39:20 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 276B62D54 for ; Thu, 27 Jul 2023 09:39:19 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-40540a8a3bbso304571cf.1 for ; Thu, 27 Jul 2023 09:39:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690475958; x=1691080758; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2yDMqgwJZJpeLWzTC3EjN9bRwWDIhFu5M1m3QL8b53s=; b=AdhfcTm82K1GjFLigVcxGTETbwB4Hu0ZKLK+rVeYJhk06k5aXEomtq0SuD4my1yUGg G6a/EeSTlThiC82+Z4bb/j+2s0ml/xUhySNsXFOA6VBQOFGZDamFXY9HPFc97j6VTYG5 1e3d2EFDPlJjT/zTfCt+EjkDltdCVWOfiGhis7IWPppJdrn0DD5QVUmWhlKEzl+bjSib UYXeS7mDMrpUEzNQ3lX5EVaJgq/MZDpL+9hmU+DGwhEBLNQsOasCoVnXS4xZoegM3c2P U6gEU7zhObGvROVJgWVeMRLMV+9gxdLqC4/35IJiVicb67MCUB2Azg0hfZNEGGq3G8kR 5mXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690475958; x=1691080758; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2yDMqgwJZJpeLWzTC3EjN9bRwWDIhFu5M1m3QL8b53s=; b=RWEDy+jndlyOfPwaZxzrHtFvbaayR1qir84+OE3/6FMwI5nxGX1dlF9RmLpe7lRwph mrLIdDgGLAVormh/OfpZI0CJ9gjLZ9Vafx3ZjREnZ9B5jVk/mF6gKdmPbidTDyGe6gol 1bKLoCliZRV9ED8Tyj1SaXAOpAxNjK8edOOmNTGyawLYiGpw7tbuDYrEMwkDS/dwRANb vHF0fm8CZij3oerC/qXPXhFRDbjh7QFwMiqKYaG136V3MW1s7Ue2msGFyDvbgIGWYy8q M4abP+4mTHc6jh3JruNhPEEhB9bEX44d4BC3QWZyMqbzq//5vWJHILW4G/LwsKSCm6rX jokA== X-Gm-Message-State: ABy/qLb17hVMX8oupxEtCTjfuPkidushaUyGzSztBenyI8nDuUfeXsnp Oc3S18xxize2Yz+HigvedXJ6H4iu2CtKFdHPtgBvTQ== X-Received: by 2002:ac8:7d85:0:b0:3f9:a78f:c527 with SMTP id c5-20020ac87d85000000b003f9a78fc527mr207755qtd.21.1690475958109; Thu, 27 Jul 2023 09:39:18 -0700 (PDT) MIME-Version: 1.0 References: <20230720112955.643283-1-ryan.roberts@arm.com> <20230720112955.643283-3-ryan.roberts@arm.com> <87r0ouw39n.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: From: Yu Zhao Date: Thu, 27 Jul 2023 10:38:42 -0600 Message-ID: Subject: Re: [PATCH v3 2/3] mm: Implement folio_remove_rmap_range() To: Ryan Roberts Cc: Matthew Wilcox , "Huang, Ying" , Andrew Morton , Yin Fengwei , David Hildenbrand , Yang Shi , Zi Yan , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Thu, Jul 27, 2023 at 1:26=E2=80=AFAM 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 =3D 1 << PMD_ORDER' is the same as 'compound =3D 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 =3D 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 torped= oes > > the whole idea; I'll think about it. > > This is exactly why I think the approach I've already taken is the correc= t one; > a 'range' makes no sense when you are dealing with 'compound' pages becau= se 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. 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=3D1), and this IMO is a bad design pattern.