From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA198C433EF for ; Thu, 9 Sep 2021 18:13:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1E146105A for ; Thu, 9 Sep 2021 18:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243623AbhIISPF (ORCPT ); Thu, 9 Sep 2021 14:15:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26700 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237297AbhIISO4 (ORCPT ); Thu, 9 Sep 2021 14:14:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631211225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RIWjeeOoa1VabWi3B7TlOtz3Y4ofdlgGcEa+gLerJBI=; b=i6Pui8bj/iyI+VbNdm2sPK5s893npU84dCviXqjYBjEd3lWvL/OgAqFRu7GBAkw4wtt3MK fo2LElPXP8KMLAcch8nY/FOeAAo2MRZ6r1wwA13qhpT968wPRP9ZO6L2RPmh+ok389+YKH UeCuiZNlwuQyZdvmgVzHvLD+PBbJhyQ= Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-35-18U08jF9Ozy_5I1pmKyJ0g-1; Thu, 09 Sep 2021 14:13:44 -0400 X-MC-Unique: 18U08jF9Ozy_5I1pmKyJ0g-1 Received: by mail-il1-f197.google.com with SMTP id s15-20020a056e02216f00b002276040aa1dso2820130ilv.3 for ; Thu, 09 Sep 2021 11:13:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RIWjeeOoa1VabWi3B7TlOtz3Y4ofdlgGcEa+gLerJBI=; b=hglmctgno+8lvhHVc3Qx0StiuBGwoLFl79AswQNvd489EEclZaYtF+KOAQJx3pfCO9 edW7kM6y88dqPZZqS3bgvvGgk5u2UyaFAY5Imra6+FToljGtjvbpVhORiLbJcsj6L/tU ytOk3HVkYrCUPDHj94juo1i7FC4Ats5v2IfngjVi/zE4uCJAmtKUR29gJr/wiDYmJTaW b98GeYD7nV/rO460ncqpBCrHlnyLGFdBQ6k5ArzqVV2nZ9QhzF40O14MsQXyLyLkGJc9 WTWhMuy2ApIN9792U7Nzx+lmtpYuQ2izprwt8C+Hda1wlxstrF0mCmwRNMwMDWSlxRgO hxRw== X-Gm-Message-State: AOAM531OBrz+UPb6vUNkGzIhCdX2t0eryr8jvl3+W/jx88XqzSVJfcc4 CXx7D1Mm0XizYoA9g7JMM1gIzvUOm0iqGJnM9m3IBYiLetbDUunKqsKzQqb3T80b35wV69vBC47 /P1QRN91RyJp9H6x4t1xbaKlL X-Received: by 2002:a6b:7710:: with SMTP id n16mr3658165iom.101.1631211223657; Thu, 09 Sep 2021 11:13:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzkCSATJElsUKeXdLlSO3aGUQTKN6vio39mP/DTTO36pPZKKiCNGeWvgE4VfkouIG8DfjqVg== X-Received: by 2002:a6b:7710:: with SMTP id n16mr3658143iom.101.1631211223417; Thu, 09 Sep 2021 11:13:43 -0700 (PDT) Received: from t490s ([2607:fea8:56a3:500::ad7f]) by smtp.gmail.com with ESMTPSA id f3sm1177173ilu.85.2021.09.09.11.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 11:13:42 -0700 (PDT) Date: Thu, 9 Sep 2021 14:13:40 -0400 From: Peter Xu To: Liam Howlett Cc: "linux-kernel@vger.kernel.org" , Andrew Morton , Hugh Dickins , "linux-mm@kvack.org" , Miaohe Lin , David Hildenbrand , Andrea Arcangeli , Yang Shi , Alistair Popple , Matthew Wilcox , "Kirill A . Shutemov" , Jerome Glisse , Mike Rapoport Subject: Re: [PATCH v3 3/5] mm: Drop first_index/last_index in zap_details Message-ID: References: <20210908163516.214441-1-peterx@redhat.com> <20210908163622.214951-1-peterx@redhat.com> <20210909025417.occtqoo6l7x5tnuy@revolver> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210909025417.occtqoo6l7x5tnuy@revolver> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 09, 2021 at 02:54:37AM +0000, Liam Howlett wrote: > > @@ -3390,17 +3393,17 @@ void unmap_mapping_page(struct page *page) > > void unmap_mapping_pages(struct address_space *mapping, pgoff_t start, > > pgoff_t nr, bool even_cows) > > { > > + pgoff_t first_index = start, last_index = start + nr - 1; > > Nit: If you respin, can first_index and last_index be two lines please? Sure. > > > struct zap_details details = { }; > > > > details.check_mapping = even_cows ? NULL : mapping; > > - details.first_index = start; > > - details.last_index = start + nr - 1; > > - if (details.last_index < details.first_index) > > - details.last_index = ULONG_MAX; > > Nit: Maybe throw a comment about this being overflow check, if you > respin. It may not be "only" an overflow check, e.g., both unmap_mapping_range() and unmap_mapping_pages() allows taking the npages to be zero: For unmap_mapping_range: * @holelen: size of prospective hole in bytes. This will be rounded * up to a PAGE_SIZE boundary. A holelen of zero truncates to the * end of the file. For unmap_mapping_pages: * @nr: Number of pages to be unmapped. 0 to unmap to end of file. So we must set it to ULONG_MAX to make sure nr==0 will work like that. I won't bother adding a comment, but if to add it I'll probably also mention about that part on allowing a nr==0 use case, please let me know if you insist. > > > + if (last_index < first_index) > > + last_index = ULONG_MAX; > > > > i_mmap_lock_write(mapping); > > if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))) > > - unmap_mapping_range_tree(&mapping->i_mmap, &details); > > + unmap_mapping_range_tree(&mapping->i_mmap, first_index, > > + last_index, &details); > > i_mmap_unlock_write(mapping); > > } > > > > -- > > 2.31.1 > > > > Reviewed-by: Liam R. Howlett Thanks for reviewing. -- Peter Xu