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=ham 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 8EEBAC433F5 for ; Thu, 9 Sep 2021 18:13:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 178686105A for ; Thu, 9 Sep 2021 18:13:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 178686105A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 65CB96B006C; Thu, 9 Sep 2021 14:13:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E4256B0072; Thu, 9 Sep 2021 14:13:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45DB46B0073; Thu, 9 Sep 2021 14:13:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id 3476A6B006C for ; Thu, 9 Sep 2021 14:13:48 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B4CDE8249980 for ; Thu, 9 Sep 2021 18:13:47 +0000 (UTC) X-FDA: 78568833294.03.96D7336 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 68EFDF000136 for ; Thu, 9 Sep 2021 18:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631211226; 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=L1lqDw5XKN+DQ8ryhvZP2JOz381u8wB+zKuI7YtsSrGIlH8w7IyuIO8g+m7Bv7fK37/1Om hSv6DWvhTEr1FOw6rD487wJV8/Z7Hrwmi648i/KJuoHzOAI19rBBT9Q60O0qfndo8WQFyp HFsSxCqKPRmuuCKAyHVj+nfS2egpvCg= Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-Sy0wy4kYP9iUaKzO3aidJA-1; Thu, 09 Sep 2021 14:13:44 -0400 X-MC-Unique: Sy0wy4kYP9iUaKzO3aidJA-1 Received: by mail-io1-f71.google.com with SMTP id n189-20020a6b8bc6000000b005b92c64b625so2389798iod.20 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=dIRLLS2nRlDDm7N1ZD0ZKlBNP90xfsMUyYz3dPV2hBPFTJh3mi0zLSPQ32yrdlu5Ox 5CqUDZx3X5cxAR1fOkjT/LEdUobWH2NMZiNAdW0Vu2NWAYJEMwX+SbixpJ8Ax4oY9+BR L5F+0MoIeHFqB6YIPKN5nCHSUzSZ+IlvmdYH0cS3SPFPaocAlsVmXPaWK1RPT2tgvOFO rbdERePB/WnHUosQoRD7K1147K3oW37Q4lJoVcNLh4KkhIqIzv5vGh0Ny6ri2Uf9iW2+ RIA448BjZo8pSBaP7FO0wKGE6j6pqkjuBRH4zahh/zrIxKS6BW5XK9Oa1ZwYSAwhrAHz vbdg== X-Gm-Message-State: AOAM532x4tfnslxqbNNasMNUAMUmIPEU9KZu8bELkM+WwRTl2KwNdWNd o6juvIfaTVrGD/3Ral4m3O0Rkf9R/h43iMZ6+N9f9nH8zYMM+A3/tIC9WKUjF4WX4bHnxb65GXj KQjEF6dB0xZo= X-Received: by 2002:a6b:7710:: with SMTP id n16mr3658157iom.101.1631211223656; 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 In-Reply-To: <20210909025417.occtqoo6l7x5tnuy@revolver> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 68EFDF000136 X-Stat-Signature: xbo9bo8sd4jtxn3kb7nuprri6whfcq48 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=L1lqDw5X; spf=none (imf17.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1631211227-382914 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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