From patchwork Wed Sep 15 18:15:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12497127 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.5 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,URIBL_BLOCKED,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 612CDC433F5 for ; Wed, 15 Sep 2021 18:15:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F0BA8600D4 for ; Wed, 15 Sep 2021 18:15:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F0BA8600D4 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 9958E6B0074; Wed, 15 Sep 2021 14:15:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 945486B0075; Wed, 15 Sep 2021 14:15:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80DD96B0078; Wed, 15 Sep 2021 14:15:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id 713DE6B0074 for ; Wed, 15 Sep 2021 14:15:42 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1C43E827CB77 for ; Wed, 15 Sep 2021 18:15:42 +0000 (UTC) X-FDA: 78590610924.17.D29C513 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 B6279B000185 for ; Wed, 15 Sep 2021 18:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631729741; 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=DZHPDTQPmmT4S/5dP0KaRo8sVu/1OOr/SVcw78xFuwQ=; b=HTq3HH5HZHZMHEbCBv3zhXK5ciX7kxVoGE0BpaYBipwl7J3yxH6LXBqif7LaLgp1pjhV0g pg3u2OEO4Vs5YL//zLcZq+7gcM5cUsKqDMampZM3GFWlR1LVAP9JmonBdaBdT/yRDwA0yH AK9IOMOxjsnTKeeAHVxsaNvJ4IQk86E= 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-478-ZPVPw-hlNsqsftfRq75tCw-1; Wed, 15 Sep 2021 14:15:38 -0400 X-MC-Unique: ZPVPw-hlNsqsftfRq75tCw-1 Received: by mail-qk1-f197.google.com with SMTP id q13-20020a05620a038d00b003d38f784161so6054308qkm.8 for ; Wed, 15 Sep 2021 11:15:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DZHPDTQPmmT4S/5dP0KaRo8sVu/1OOr/SVcw78xFuwQ=; b=sS5cLidYug5UnJy4Qa3tncg8A9rycBhH4zWd1vmcr31jMkLx7rQazwv3xnp3fEF4cC 0wZfxebwuKHWMA/GaM3Q1hJcVBkZkkiIvVgxOc9WkxQeMZAAsDCPqxlnZ9e1iYhifwAQ ZzQY+gTEgn+/3XsHhcXU5B9APusTLqw0F3G+szZedTwySbt0LWdo5U/sRmTE3hFcT67k 6Ch0m9AECvV3HKDeu1EnDaogucLimho9dK/XKFexu9HE1hUMWv2TlqonrvnZuKjB9+Yx pSfexTbAnel5wAJvJDrURuBaDQ7SCMDu8P0XFeyFCJudDZgkIdcGyMEwfRfkDb4RD/mz QyJQ== X-Gm-Message-State: AOAM533OcK7JhzwpwFJzTPVXSFI9OhMFFQ3WbCkGNLPNxnRAwn3Ps3sH wbhxUtODVfzdsPKeOao4OKimNiNih1XHRxUfT2lxa77Elgz/FN3aUje2aPQc5y0k6xXVwA7N5uG Wa1joEeMV7qc= X-Received: by 2002:a05:620a:9c9:: with SMTP id y9mr1254070qky.207.1631729737848; Wed, 15 Sep 2021 11:15:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCDiDDdOWKMQa0nt8YhHUXf0hiyQUvKuJ0Xc/zbcBLQR8zWPpath9jFglOz4LhTP3RVO95bA== X-Received: by 2002:a05:620a:9c9:: with SMTP id y9mr1254052qky.207.1631729737639; Wed, 15 Sep 2021 11:15:37 -0700 (PDT) Received: from t490s.redhat.com ([2607:fea8:56a2:9100::d35a]) by smtp.gmail.com with ESMTPSA id c15sm531826qka.46.2021.09.15.11.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 11:15:37 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, Andrew Morton , linux-mm@kvack.org Cc: Hugh Dickins , David Hildenbrand , Liam Howlett , Mike Rapoport , Alistair Popple , Matthew Wilcox , peterx@redhat.com, Yang Shi , "Kirill A . Shutemov" , Jerome Glisse , Miaohe Lin , Andrea Arcangeli Subject: [PATCH v4 3/4] mm: Drop first_index/last_index in zap_details Date: Wed, 15 Sep 2021 14:15:35 -0400 Message-Id: <20210915181535.11238-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210915181456.10739-1-peterx@redhat.com> References: <20210915181456.10739-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HTq3HH5H; 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; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B6279B000185 X-Stat-Signature: tgd1tndmbidpicyexj5szdgqyqwi8qa3 X-HE-Tag: 1631729741-987427 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. Reviewed-by: Alistair Popple Reviewed-by: David Hildenbrand Reviewed-by: Liam Howlett Signed-off-by: Peter Xu Acked-by: Hugh Dickins --- include/linux/mm.h | 2 -- mm/memory.c | 31 ++++++++++++++++++------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 73a52aba448f..d1126f731221 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1722,8 +1722,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 */ }; diff --git a/mm/memory.c b/mm/memory.c index 7b095f07c4ef..a7e427177817 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3321,20 +3321,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; @@ -3360,18 +3360,22 @@ void unmap_mapping_page(struct page *page) { struct address_space *mapping = page->mapping; struct zap_details details = { }; + pgoff_t first_index; + pgoff_t last_index; VM_BUG_ON(!PageLocked(page)); VM_BUG_ON(PageTail(page)); + first_index = page->index; + last_index = page->index + thp_nr_pages(page) - 1; + details.check_mapping = mapping; - details.first_index = page->index; - details.last_index = page->index + thp_nr_pages(page) - 1; details.single_page = page; 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); } @@ -3391,16 +3395,17 @@ void unmap_mapping_pages(struct address_space *mapping, pgoff_t start, pgoff_t nr, bool even_cows) { struct zap_details details = { }; + pgoff_t first_index = start; + pgoff_t last_index = start + nr - 1; 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); }