Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4231410iog; Tue, 21 Jun 2022 15:09:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sJdr0Tv1OY8kW+V2ISN5QcqhXnwNpaGnOVpEsWGakkMlzZzpeoIHw9uj+IHnp3PMFU3wMP X-Received: by 2002:a05:6402:1f82:b0:42f:c541:4fd1 with SMTP id c2-20020a0564021f8200b0042fc5414fd1mr329975edc.172.1655849345191; Tue, 21 Jun 2022 15:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655849345; cv=none; d=google.com; s=arc-20160816; b=axXez+g0ufI3a4EoqRQYRWqx+C3ntz1YdzMJpnL/lJ+tCaD3y3XiIszNL612o4Jrqx 3NzRv1uILhuBrxQU7V5Rv9MpgQrhdJ+qTt4KojsmPQyLI19C+bDPdCPVTzh4PBfCIZ6v umpLC9/l9H6FcQuWafToORYN9/DhBB4kHzR0M3IkN0IB6CCsjpD8tw/ZWnGsomM46nVY ILPd35JOlXLoweWOD9ybhrG28abtZseqaVThzHXOcpedKfs4fkfuD7OpWMc6Yf6iYEyV w4ESykKb6SfGr83ivDBHY3sezbJOHYGKtMhaCpFFkrEIPxCSww1QFcNqccVSTlSxThW2 k1SA== 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 :organization:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=p2ZyEjz/X1rrSRyY38O7XcVSbvfO1EBTiv9ehORRiiM=; b=PfYN+DOm5tYc9WxgzUHUh4XqRcbPuNiT8jeKhbwiACFCTN+T+vmRMN5UyZJXCQC+3z HANvwQqJboCX5GqaWKpsbVwnOLYgZGPpjtnEhV0vQrTuj7hg5VynLYTBeK+im+5sx2VF VR+vrN4USfxH456erI2khDvptchYMJs4pRqsDqH4Qi3uMl7HSO5pGYb4e9f5n/M1dzLD +URCroZU8zH5TF9eUsR6corzEV6uplUk/+MszeheNIBkmCwOhlNK8vwjaTqDleOyyrOD +WHpmiO9XEggGsndjkwG5U8OMFAU4V6X62NXEFJdgXc/VsNwM96/v+Qp8DmVKYwm6uYG Ctwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=amlFTC61; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y23-20020aa7ca17000000b0043579abb9f3si9246925eds.532.2022.06.21.15.08.40; Tue, 21 Jun 2022 15:09:05 -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=@redhat.com header.s=mimecast20190719 header.b=amlFTC61; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355450AbiFUVXu (ORCPT + 99 others); Tue, 21 Jun 2022 17:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355139AbiFUVXK (ORCPT ); Tue, 21 Jun 2022 17:23:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9A6D05FF7 for ; Tue, 21 Jun 2022 14:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655846015; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p2ZyEjz/X1rrSRyY38O7XcVSbvfO1EBTiv9ehORRiiM=; b=amlFTC61cxaMpJAJOk7D9m9lnlqVWMxEAopTgTXzBpiliSYNg3e53VVgIaN8Pr2Io3QMzU CoJ2dAPtBXM36VqI/3/NblxCQnfnJumBNMx1tvsJvWYuwq0J7fXuZAgaKlGQpnIJtUcvtc ExI1L3NnvSoBHRS0gJIFtpjpd/X6RNA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-74-hrp6LAabP5WbMd84IijUfg-1; Tue, 21 Jun 2022 17:13:34 -0400 X-MC-Unique: hrp6LAabP5WbMd84IijUfg-1 Received: by mail-wm1-f71.google.com with SMTP id h205-20020a1c21d6000000b0039c96ec500fso8963349wmh.8 for ; Tue, 21 Jun 2022 14:13:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:organization:in-reply-to :content-transfer-encoding; bh=p2ZyEjz/X1rrSRyY38O7XcVSbvfO1EBTiv9ehORRiiM=; b=2YFa9ag35AUUZk2F79IWPyjDVjZUWO1xT86vRU3bWTgCaIoJEJxsO3BshVdrKdBV0r bjbgVl7MZJWwA0N9BIE1e+QIWmcPTd8VmQRlT39YYbJWVIH1Kfg0gtc6jdGeDbNJlUnx IWLYTV8E5UnqZM2Ir+38LNFVUI6ZLgnVEliICBZhQSIhmetRGBMqIhwyUAUstQrRmKE2 B/FNSg0Wzyr2HtV9omMcoR2HNdET+yByqeEM46c2IAdRmOW2BIderoU5lkrXO4uHRmsG vXTYiRdpDMremBSMK5lGk5m2B2q2CfNeV7oXvCY0liMrpdWPCJ+rXkk+SG8I3KUgOUrN cFUw== X-Gm-Message-State: AOAM530CuBtDVkzNBk707oFYZG4t61FRTJM3OGH1HjFvUVAWAbuVsIye ZbPQaPKHN/5RgB0qT0ZO3h0qcF+FF3ZNdtp8AFtguULck7VsBYRLS3hfK7IUkpyWN96a4HMIhNb cgPfFqY2B3FvbxURz6DUJ5QzF X-Received: by 2002:a05:600c:583:b0:39c:3637:b9f with SMTP id o3-20020a05600c058300b0039c36370b9fmr41890250wmd.79.1655846013138; Tue, 21 Jun 2022 14:13:33 -0700 (PDT) X-Received: by 2002:a05:600c:583:b0:39c:3637:b9f with SMTP id o3-20020a05600c058300b0039c36370b9fmr41890234wmd.79.1655846012925; Tue, 21 Jun 2022 14:13:32 -0700 (PDT) Received: from ?IPV6:2003:cb:c705:bc00:a63c:7e37:6061:1706? (p200300cbc705bc00a63c7e3760611706.dip0.t-ipconnect.de. [2003:cb:c705:bc00:a63c:7e37:6061:1706]) by smtp.gmail.com with ESMTPSA id 64-20020a1c1943000000b0039c6390730bsm22251249wmz.29.2022.06.21.14.13.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jun 2022 14:13:32 -0700 (PDT) Message-ID: <5d3bf51b-3bba-3bd4-db1f-1c0a3930a1e4@redhat.com> Date: Tue, 21 Jun 2022 23:13:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v10 10/69] mmap: use the VMA iterator in count_vma_pages_range() Content-Language: en-US To: Liam Howlett , "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton , "damon @ lists . linux . dev" , SeongJae Park References: <20220621204632.3370049-1-Liam.Howlett@oracle.com> <20220621204632.3370049-11-Liam.Howlett@oracle.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220621204632.3370049-11-Liam.Howlett@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,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 21.06.22 22:46, Liam Howlett wrote: > From: "Matthew Wilcox (Oracle)" > > This simplifies the implementation and is faster than using the linked > list. > > Link: https://lkml.kernel.org/r/20220504010716.661115-12-Liam.Howlett@oracle.com > Signed-off-by: Matthew Wilcox (Oracle) > Signed-off-by: Liam R. Howlett > Acked-by: Vlastimil Babka > Cc: Catalin Marinas > Cc: David Howells > Cc: SeongJae Park > Cc: Will Deacon > Cc: Davidlohr Bueso > Signed-off-by: Andrew Morton > --- > mm/mmap.c | 24 +++++++----------------- > 1 file changed, 7 insertions(+), 17 deletions(-) > > diff --git a/mm/mmap.c b/mm/mmap.c > index 6be7833c781b..d7e6baa2f40f 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -675,29 +675,19 @@ munmap_vma_range(struct mm_struct *mm, unsigned long start, unsigned long len, > > return 0; > } > + > static unsigned long count_vma_pages_range(struct mm_struct *mm, > unsigned long addr, unsigned long end) > { > - unsigned long nr_pages = 0; > + VMA_ITERATOR(vmi, mm, addr); > struct vm_area_struct *vma; > + unsigned long nr_pages = 0; > > - /* Find first overlapping mapping */ > - vma = find_vma_intersection(mm, addr, end); > - if (!vma) > - return 0; > - > - nr_pages = (min(end, vma->vm_end) - > - max(addr, vma->vm_start)) >> PAGE_SHIFT; > - > - /* Iterate over the rest of the overlaps */ > - for (vma = vma->vm_next; vma; vma = vma->vm_next) { > - unsigned long overlap_len; > - > - if (vma->vm_start > end) > - break; > + for_each_vma_range(vmi, vma, end) { > + unsigned long vm_start = max(addr, vma->vm_start); > + unsigned long vm_end = min(end, vma->vm_end); I thought using max_t and min_t was the latest advisory. I might be wrong and simply kept doing it that way ;) > > - overlap_len = min(end, vma->vm_end) - vma->vm_start; > - nr_pages += overlap_len >> PAGE_SHIFT; > + nr_pages += (vm_end - vm_start) / PAGE_SIZE; PHYS_PFN(vm_end - vm_start) > } > > return nr_pages; Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb