From patchwork Tue Mar 23 00:48:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12156487 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 BC937C433E0 for ; Tue, 23 Mar 2021 00:49:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 60C456196C for ; Tue, 23 Mar 2021 00:49:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 60C456196C 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 0C3276B011F; Mon, 22 Mar 2021 20:49:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 024956B0122; Mon, 22 Mar 2021 20:49:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB9EB6B0123; Mon, 22 Mar 2021 20:49:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id B6E6A6B011F for ; Mon, 22 Mar 2021 20:49:29 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 811928249980 for ; Tue, 23 Mar 2021 00:49:29 +0000 (UTC) X-FDA: 77949305658.26.BDAD197 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 379FC407F8E8 for ; Tue, 23 Mar 2021 00:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616460568; 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=jLKkf+ZPkMgUQMvwd6XDyh9qcQY+uJivyMkVgKqyvds=; b=DglbnqE3gGL7uWHXw4R5qlxNZQZ1iWKfzcq/cSp7vIgypLMkGn69AkbUxSbP6w8DxASIE5 pOx8mhyP0cfG27FSl5tOV7LKZFU9QzSnVNf/GwlmlkwpeS8LQw8hDj9byIOgbrvEHpuBAJ IJVJyVLtWa4BjkJxgfgrottq1UtnUg4= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-193-o5fsniqMMyOXrhYzNeIakg-1; Mon, 22 Mar 2021 20:49:25 -0400 X-MC-Unique: o5fsniqMMyOXrhYzNeIakg-1 Received: by mail-qt1-f197.google.com with SMTP id v18so418386qtx.0 for ; Mon, 22 Mar 2021 17:49:25 -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=jLKkf+ZPkMgUQMvwd6XDyh9qcQY+uJivyMkVgKqyvds=; b=cwJKW02vsXn5mfAndMVrdGJtk9JVxo4MDF95EPDMoj0MrLOhYi+LR40pRdXuWrZ9Ta z7wOuO4mZLhTDiHEIlgb/W/pa07cF/GnmyPmvLHN5yY3mL6VKf8SbnpHbG5UrFaRGBFp O3qA07PDl+FOaF29aGtgPjeBCpuAjgLjEWf9CkOlxHICF+eR4plFpnIeypF+C7ipoKnE lsR/ctIH01f2OFBn5O+7Ovnszti3n6SL3GMki4qCpA8x6prVnXnFrboADR9pJ19Y7RBx 3KGuVXtyeXFi4Vk2FoFE55t4alwzj7hiBROcpFDjM1hsW9/NiswaS5dQH5gRpzd8dFcZ QzEg== X-Gm-Message-State: AOAM530/2HNV+xpVMR3ec2Y+zwlZ88rIsYVgrnCfY0EUIx4ZbAWTqmeE ArHSX/rmzKaI8MKWS2/u/ogIJ1miGtlCgajo00r0TnsWuxWTmmgSA5e4cRzSQxzHfN6dO6NKyJq OlXnwFt8s01k= X-Received: by 2002:a05:622a:38a:: with SMTP id j10mr2356387qtx.321.1616460564553; Mon, 22 Mar 2021 17:49:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWTu7ggSiwl9a2400ldzG7CNv+Tgn2StD4wlyGGg2tML5uryFjvwpa6kp0vQM/I+lvGp7Ilw== X-Received: by 2002:a05:622a:38a:: with SMTP id j10mr2356368qtx.321.1616460564311; Mon, 22 Mar 2021 17:49:24 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-82-174-91-135-175.dsl.bell.ca. [174.91.135.175]) by smtp.gmail.com with ESMTPSA id n6sm5031793qtx.22.2021.03.22.17.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 17:49:23 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: "Kirill A . Shutemov" , Jerome Glisse , Mike Kravetz , Matthew Wilcox , Andrew Morton , Axel Rasmussen , Hugh Dickins , peterx@redhat.com, Nadav Amit , Andrea Arcangeli , Mike Rapoport Subject: [PATCH 06/23] mm: Drop first_index/last_index in zap_details Date: Mon, 22 Mar 2021 20:48:55 -0400 Message-Id: <20210323004912.35132-7-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210323004912.35132-1-peterx@redhat.com> References: <20210323004912.35132-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 379FC407F8E8 X-Stat-Signature: e4qukhpnmkcbr1r7kggmkpmr6qn69tmp Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616460568-218694 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 used in unmap_mapping_range_tree(). At the meantime, this function is only called by unmap_mapping_pages() once. Instead of passing these two variables through the whole stack of page zapping code, remove them from zap_details and let them 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 b78306eb7a63..389dd91134f9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1707,8 +1707,6 @@ extern void user_shm_unlock(size_t, struct user_struct *); */ 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 *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, diff --git a/mm/memory.c b/mm/memory.c index b4ddba343abc..5e6175e00617 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3202,20 +3202,20 @@ static void unmap_mapping_range_vma(struct vm_area_struct *vma, } 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; - vma_interval_tree_foreach(vma, root, - details->first_index, details->last_index) { - + vma_interval_tree_foreach(vma, root, first_index, last_index) { vba = vma->vm_pgoff; vea = vba + vma_pages(vma) - 1; - zba = details->first_index; + zba = first_index; if (zba < vba) zba = vba; - zea = details->last_index; + zea = last_index; if (zea > vea) zea = vea; @@ -3241,17 +3241,17 @@ static inline void unmap_mapping_range_tree(struct 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 = start, last_index = start + nr - 1; 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; + 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); }