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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 66351C4707F for ; Thu, 27 May 2021 20:21:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1468261360 for ; Thu, 27 May 2021 20:21:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1468261360 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9CB566B0070; Thu, 27 May 2021 16:21:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 975906B0071; Thu, 27 May 2021 16:21:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 445078D0001; Thu, 27 May 2021 16:21:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id F22356B0070 for ; Thu, 27 May 2021 16:21:35 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 96547BA12 for ; Thu, 27 May 2021 20:21:35 +0000 (UTC) X-FDA: 78188131350.20.B3B0D96 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id C1C67600027A for ; Thu, 27 May 2021 20:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622146894; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h5FCImkTLc8C+iW7llWT4B7oKe4vYYc/EBx9K8XBnj4=; b=CLY7ckGXT/WOpqSbRMeiALAPLaLEO3i+PDqGUTeBbr+Qz+LgJweRqFbYSIOWuDWk4wJLOu Tu46ueenjqwelZyWoc88mcYbCQB+AvaDQECuXLFKEmFeeU9IsuPCI5wtCOtnaZNDzo1gUn H4YNw5xSwms54f6VVF3xmXlRyELK9lg= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-260-orlctl-vMISrL73hH6XfkQ-1; Thu, 27 May 2021 16:21:31 -0400 X-MC-Unique: orlctl-vMISrL73hH6XfkQ-1 Received: by mail-qk1-f197.google.com with SMTP id z12-20020a05620a08ccb02902ea1e4a963dso1323658qkz.13 for ; Thu, 27 May 2021 13:21:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h5FCImkTLc8C+iW7llWT4B7oKe4vYYc/EBx9K8XBnj4=; b=T6oBu1SjFJ8/y/XYkcZmzws13O99mBnJrmMVq3g5KLAdTDi/o5fQTOS90r4dPUGqTL EI73V4dL+p/JvhyZfN+IXVeZ+pqWgQtz1FBY/V2eVAVMS6HeP5YT1LEpPuKTnWDrA+4X pCRHyfmwr28eCi1xcIXnniu02lWvmlHEGNOakrNJlO2FfPnoiMStcyEOxMz9xpoQQave olJHK+ZGyX7uktpsFZMeycevVv/TWCIiR95JOL/M/tk6LWS4v1juT4kY/VeZeWQPImFC NhiFLiZAQEf9xdz7aEdJV/UAVu42JzIjDZvkf4g8VqlZAxl4OK0OQPlshMCZ5/AiO4cs Dm9g== X-Gm-Message-State: AOAM5327waTGiuYSWYdw+D9DJkio39AqIs/Ck+ThtTSEMdlabqK+y0VL bB5VI+CKvdKotE8BQpquDfWhkAn3MeHOra0fyNaCIqF6DF+eMuc1S1t82q1riaI0JUGDbvoo8f+ rCn/OAu3wnOev9MsDOQoZyTm0VJ6z4RkWKFvDIsE+85N5zHqOQKp3212t+YXF X-Received: by 2002:ac8:75d3:: with SMTP id z19mr362923qtq.44.1622146890439; Thu, 27 May 2021 13:21:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypIsqd4DUNG1ZqS0UQQmBuBbvTh9zi1M5X23Oonzevxam33oO8kSwmkp38m1qPCCeZl1p/ig== X-Received: by 2002:ac8:75d3:: with SMTP id z19mr362893qtq.44.1622146890139; Thu, 27 May 2021 13:21:30 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-72-184-145-4-219.dsl.bell.ca. [184.145.4.219]) by smtp.gmail.com with ESMTPSA id 42sm2070151qtf.37.2021.05.27.13.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:21:29 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrea Arcangeli , "Kirill A . Shutemov" , Axel Rasmussen , Nadav Amit , Hugh Dickins , Jerome Glisse , Jason Gunthorpe , peterx@redhat.com, Andrew Morton , Miaohe Lin , Mike Rapoport , Matthew Wilcox , Mike Kravetz Subject: [PATCH v3 07/27] mm: Drop first_index/last_index in zap_details Date: Thu, 27 May 2021 16:21:26 -0400 Message-Id: <20210527202126.30790-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210527201927.29586-1-peterx@redhat.com> References: <20210527201927.29586-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="US-ASCII" Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CLY7ckGX; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf25.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Stat-Signature: nhgz5xkka7fa65nbj1m5nzbo1gage145 X-Rspamd-Queue-Id: C1C67600027A X-Rspamd-Server: rspam02 X-HE-Tag: 1622146886-185022 Content-Transfer-Encoding: quoted-printable 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: The first_index/last_index parameters in zap_details are actually only us= ed in unmap_mapping_range_tree(). At the meantime, this function is only calle= d by unmap_mapping_pages() once. Instead of passing these two variables throu= gh the whole stack of page zapping code, remove them from zap_details and let th= em simply be parameters of unmap_mapping_range_tree(), which is inlined. Signed-off-by: Peter Xu --- include/linux/mm.h | 2 -- mm/memory.c | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index ef9ea6dfefff..db155be8e66c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1726,8 +1726,6 @@ extern void user_shm_unlock(size_t, struct user_str= uct *); */ struct zap_details { struct address_space *check_mapping; /* Check page->mapping if set */ - pgoff_t first_index; /* Lowest page->index to unmap */ - pgoff_t last_index; /* Highest page->index to unmap */ }; =20 struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long ad= dr, diff --git a/mm/memory.c b/mm/memory.c index 45a2f71e447a..27cf8a6375c6 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3305,20 +3305,20 @@ static void unmap_mapping_range_vma(struct vm_are= a_struct *vma, } =20 static inline void unmap_mapping_range_tree(struct rb_root_cached *root, + pgoff_t first_index, + pgoff_t last_index, struct zap_details *details) { struct vm_area_struct *vma; pgoff_t vba, vea, zba, zea; =20 - vma_interval_tree_foreach(vma, root, - details->first_index, details->last_index) { - + vma_interval_tree_foreach(vma, root, first_index, last_index) { vba =3D vma->vm_pgoff; vea =3D vba + vma_pages(vma) - 1; - zba =3D details->first_index; + zba =3D first_index; if (zba < vba) zba =3D vba; - zea =3D details->last_index; + zea =3D last_index; if (zea > vea) zea =3D vea; =20 @@ -3344,17 +3344,17 @@ static inline void unmap_mapping_range_tree(struc= t rb_root_cached *root, void unmap_mapping_pages(struct address_space *mapping, pgoff_t start, pgoff_t nr, bool even_cows) { + pgoff_t first_index =3D start, last_index =3D start + nr - 1; struct zap_details details =3D { }; =20 details.check_mapping =3D even_cows ? NULL : mapping; - details.first_index =3D start; - details.last_index =3D start + nr - 1; - if (details.last_index < details.first_index) - details.last_index =3D ULONG_MAX; + if (last_index < first_index) + last_index =3D ULONG_MAX; =20 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); } =20 --=20 2.31.1