From patchwork Thu Sep 2 20:17:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12472439 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 9E16AC433FE for ; Thu, 2 Sep 2021 20:17:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 54FD461131 for ; Thu, 2 Sep 2021 20:17:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 54FD461131 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 4D10D8D0001; Thu, 2 Sep 2021 16:17:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E0646B0075; Thu, 2 Sep 2021 16:17:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2592C8D0001; Thu, 2 Sep 2021 16:17:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 0B6DC6B0073 for ; Thu, 2 Sep 2021 16:17:33 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B2EC8183DEA84 for ; Thu, 2 Sep 2021 20:17:32 +0000 (UTC) X-FDA: 78543743544.25.63A11C4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 5D4DDD0257B8 for ; Thu, 2 Sep 2021 20:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630613851; 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=RIXlqNC3vu4lq1txSwh5vWDNYVkPD87pLVis9u4Q2wY=; b=MhT0FYGDSeGuwSZPVzG2sRiTLhFu1azjGGAji1P3oblt77jdG6gbVLYzxoc+xVonqkp/Sl Fu/QgQapwAA+866CUVTPFV0ktRGI7AS/Td0PzRnYB9iwCalirMlbEl76lEpPho69vTBz6h cGIuXKduSrHHcnITHnoLRNhtj5i+89Q= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-JvFvkZYvOq-mUyIsXUSsrQ-1; Thu, 02 Sep 2021 16:17:31 -0400 X-MC-Unique: JvFvkZYvOq-mUyIsXUSsrQ-1 Received: by mail-qv1-f71.google.com with SMTP id j11-20020a0cf9cb000000b00375f0642d2dso3455549qvo.12 for ; Thu, 02 Sep 2021 13:17: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=RIXlqNC3vu4lq1txSwh5vWDNYVkPD87pLVis9u4Q2wY=; b=X6DNTbgN76pQD0Nd44FVOuljnesl+6bZL+GvMWVTeAo1LDTACee+6B4X/+GqjOsziS crAMEr/NtG7klG6t6cRcH1NJqKmtNWJX3LUdGFQNFrkn6lGo/Q5uxoak26whC4XsO246 /z6SJ85clXOtty0fuewmz9yiGdnDr964YOSC4o4ow88jeubhUJCpK+/cVyQ28SX/nmFu 2phHkkHkylggVT7YQK9iieCA5ywnc7cdgrhRvH4ohaogKWg6kNy92XfIEP+k7vOyx3kG c2GyRhhbhHBLQJbr9Iqmw/7YwAFPSgiQd0X4iyttGIYdUBMY11hM3DGiHNQH5gmp5oYE 24Rg== X-Gm-Message-State: AOAM531rtzBRYPrjgRthueMycVH0R2CsScTNOvGgdgPyJr1dV++/U+IQ /764RFPtTIMRAEIPt0Qu2bDrqR2DuiNCZCyXVPxCDMcHmB3yZngbeVy7hzckRsT4yHTg7o0UURF g29lDlRtolZc= X-Received: by 2002:ac8:7516:: with SMTP id u22mr144385qtq.119.1630613849398; Thu, 02 Sep 2021 13:17:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiZpw2RoD+jqSjYVE5EubqqLTA6EzNyQnnsyCqxpeuFnkF3mZbnsg1EEivZeiha6W/LYzBQg== X-Received: by 2002:ac8:7516:: with SMTP id u22mr144359qtq.119.1630613849206; Thu, 02 Sep 2021 13:17:29 -0700 (PDT) Received: from t490s.redhat.com ([2607:fea8:56a3:500::ad7f]) by smtp.gmail.com with ESMTPSA id m8sm2219962qkk.130.2021.09.02.13.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 13:17:28 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, Andrew Morton , Hugh Dickins , linux-mm@kvack.org Cc: Andrea Arcangeli , Yang Shi , Matthew Wilcox , peterx@redhat.com, Jerome Glisse , Mike Rapoport , "Kirill A . Shutemov" , Miaohe Lin , David Hildenbrand , Alistair Popple Subject: [PATCH v2 3/5] mm: Drop first_index/last_index in zap_details Date: Thu, 2 Sep 2021 16:17:19 -0400 Message-Id: <20210902201721.52796-4-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902201721.52796-1-peterx@redhat.com> References: <20210902201721.52796-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MhT0FYGD; spf=none (imf21.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: rspam02 X-Rspamd-Queue-Id: 5D4DDD0257B8 X-Stat-Signature: 7c5cxnswzqpbhm96jq8zm59memydtq3g X-HE-Tag: 1630613852-775966 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 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 7ca22e6e694a..69259229f090 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1721,8 +1721,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..6bba3b9fef7c 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,21 @@ void unmap_mapping_page(struct page *page) { struct address_space *mapping = page->mapping; struct zap_details details = { }; + pgoff_t first_index, 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); } @@ -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; 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); }