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 307C3C636C9 for ; Thu, 15 Jul 2021 20:14:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E1CA4613BB for ; Thu, 15 Jul 2021 20:14:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1CA4613BB 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 8A8F98D0104; Thu, 15 Jul 2021 16:14:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 82F668D00EC; Thu, 15 Jul 2021 16:14:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6830F8D0104; Thu, 15 Jul 2021 16:14:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 4690F8D00EC for ; Thu, 15 Jul 2021 16:14:44 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1E4AF824805A for ; Thu, 15 Jul 2021 20:14:43 +0000 (UTC) X-FDA: 78365925246.02.182C708 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf23.hostedemail.com (Postfix) with ESMTP id C650A900009B for ; Thu, 15 Jul 2021 20:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626380082; 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=qiHbtSxpM+Odw+UliFXdE+ZYHxP5T/ev+d+bKicm4LE=; b=Lb115ClYvho13P8rh8Ms1As2Up9J6xdbOqWRvEHZ4lCs4IgQrjL4brm48190sEsHZ1NfsR TeCBHiOpXadBFX9FdyWN3YAV7UyTF2STUM+3jiqEDLkTis2VH0+KG5JQoRhiQw+jfXSGir fTU8CYJqTtYJhVPlIdZXOsAfVmFaDDU= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-qPGIrxHXNvCRJUh8ce5bOA-1; Thu, 15 Jul 2021 16:14:41 -0400 X-MC-Unique: qPGIrxHXNvCRJUh8ce5bOA-1 Received: by mail-qv1-f72.google.com with SMTP id l4-20020a0ce0840000b02902cec39ab618so5035797qvk.5 for ; Thu, 15 Jul 2021 13:14:41 -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=qiHbtSxpM+Odw+UliFXdE+ZYHxP5T/ev+d+bKicm4LE=; b=JtbTghxfdmMwR05//gS4egwbGIrR/37KnWAcsh063so/8Zs4AQz09VZI62HI+iHlbO 3qy8NGKJyeK828eLkVOjfvXegCeZoxiuAJW0nJ8fM6dSHECkD6MCBmeUXboaHWWaFcvY 7Q/8YTIs+2ZsVjb3FuorrIU6M8Fv+jdP8p2IC1WKi4THE6Dtbzsrc9mcImiDrKNqNDFl iAoEb3uMoaPuL0ujT+N6YEfdgGOUVnQrQfhdjxIJbrE0+kM/NK4fAtvolPi7JzBkOA0s 5gdtPjBNzatJQSu3V+GUk7bxvTQXROYiDvq+FZnhBxAB7P76OkpRNStxnRDN2n12HXXi E86g== X-Gm-Message-State: AOAM5315Ofwju0wMdE1ZjYSHuo5PYFw1v9E/gKscaLb8nxkv+2zFXjw4 tq/2ncJl8uDpJcMAOO1ti+EUATbuBL/IkAgHj9qbGIzKW1Ca1XKoV6fAX6lWvLkmnUktOKMwhZ+ oOPmleuJi1kTPEaJmDshuk9Lx7al0jbHs+VKIJ6RPB+EcYOKjOdJeKEbRnI6K X-Received: by 2002:ac8:5896:: with SMTP id t22mr5666473qta.18.1626380080037; Thu, 15 Jul 2021 13:14:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxB1gUdSpg3BrfWWugP1tDP6eQWlvDj6gvn/hVXSSf7iM7kH8tsrmgmDrSYq93BmVDO25tm4A== X-Received: by 2002:ac8:5896:: with SMTP id t22mr5666435qta.18.1626380079728; Thu, 15 Jul 2021 13:14:39 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-65-184-144-111-238.dsl.bell.ca. [184.144.111.238]) by smtp.gmail.com with ESMTPSA id p64sm2915206qka.114.2021.07.15.13.14.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 13:14:39 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Jason Gunthorpe , Mike Kravetz , David Hildenbrand , Alistair Popple , Matthew Wilcox , "Kirill A . Shutemov" , Hugh Dickins , Tiberiu Georgescu , Andrea Arcangeli , Axel Rasmussen , Nadav Amit , Mike Rapoport , Jerome Glisse , Andrew Morton , Miaohe Lin , peterx@redhat.com Subject: [PATCH v5 07/26] mm: Drop first_index/last_index in zap_details Date: Thu, 15 Jul 2021 16:14:03 -0400 Message-Id: <20210715201422.211004-8-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715201422.211004-1-peterx@redhat.com> References: <20210715201422.211004-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: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Lb115ClY; spf=none (imf23.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: C650A900009B X-Stat-Signature: 61hj99o3a333j1cmnt3wmysump8nq936 X-HE-Tag: 1626380082-336413 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. Reviewed-by: Alistair Popple Signed-off-by: Peter Xu --- include/linux/mm.h | 2 -- mm/memory.c | 29 ++++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 57453dba41b9..795b3cd643ca 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1720,8 +1720,6 @@ extern void user_shm_unlock(size_t, struct ucounts = *); */ 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 */ struct page *single_page; /* Locked page to be unmapped */ }; =20 diff --git a/mm/memory.c b/mm/memory.c index ba8033ca6682..4c269d7b3d83 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3322,20 +3322,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 @@ -3361,18 +3361,21 @@ void unmap_mapping_page(struct page *page) { struct address_space *mapping =3D page->mapping; struct zap_details details =3D { }; + pgoff_t first_index, last_index; =20 VM_BUG_ON(!PageLocked(page)); VM_BUG_ON(PageTail(page)); =20 + first_index =3D page->index; + last_index =3D page->index + thp_nr_pages(page) - 1; + details.check_mapping =3D mapping; - details.first_index =3D page->index; - details.last_index =3D page->index + thp_nr_pages(page) - 1; details.single_page =3D page; =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 @@ -3391,17 +3394,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 =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