From patchwork Tue Apr 27 16:12:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12226877 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 9434DC433ED for ; Tue, 27 Apr 2021 16:13:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2286E613C2 for ; Tue, 27 Apr 2021 16:13:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2286E613C2 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 D908E6B0074; Tue, 27 Apr 2021 12:13:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D67176B0075; Tue, 27 Apr 2021 12:13:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE25A6B0078; Tue, 27 Apr 2021 12:13:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id A0BFF6B0074 for ; Tue, 27 Apr 2021 12:13:35 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5EF2F2C96 for ; Tue, 27 Apr 2021 16:13:35 +0000 (UTC) X-FDA: 78078642390.26.9963421 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id B9D2480192ED for ; Tue, 27 Apr 2021 16:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619540014; 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=gIgjn5S8tiLrRboG7Na97CFc3ZndoZkUNAZThQ2rzRU=; b=SW9XZ6L2p71Wt8w5B3xG/3aM8wQ+SHrfjt/1XZLGIXG+baZSaOIiz8Wv7UduNw7ZNSe7fq nOr7o3G/ejFL2pLZ5rGfoYR2ctmI2KKKY45V+UfO0XN3/9GR48bvyrUDB50Fukn1btu0ch h5pwcmF16N+HhlOh9j5+G2B1n/Ilmfs= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-80-D5aEe_7oMpqHzBP7VaXZTQ-1; Tue, 27 Apr 2021 12:13:32 -0400 X-MC-Unique: D5aEe_7oMpqHzBP7VaXZTQ-1 Received: by mail-qt1-f198.google.com with SMTP id r20-20020ac85c940000b02901bac34fa2eeso1691295qta.11 for ; Tue, 27 Apr 2021 09:13:32 -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=gIgjn5S8tiLrRboG7Na97CFc3ZndoZkUNAZThQ2rzRU=; b=Oa1FeaWMhkY7m2Matq9eUzUpTViE3PKl6idViRmLHmRT8vToEaKIX5T/y4DqzPDtgJ P4I2SS+H0LGb7ccgUVlK2XN2XCrUkW743sClHmKeqvF18k6Wb5o7C4EIcTZLjrLviNOM qyAzbS6Km4EviZQ1ECDof4Kqoa7yCpM3mBISaQmszgMkskXKBzuOAAxOBXcDowThD1GA dfj88TpRTEW5kTEIGi3B/ytAAFghfA8PlOJAmOQkLJs7AuK+kQ0sGsZrGtCG1mOHO+FG MlS8nkvGmccQMr/EUk2qsoklYgN/N1fLSgGZAMEMGqWRcijZ5cBBljvtX92bnRzrwRC4 S0YA== X-Gm-Message-State: AOAM531oPrv+sBfoWiHgVzVbrwFkggM8Pweb/Mq5g00afTXch9IqaqFi A4N//MNVgUcixt+95ONCtu1qlzSnbFxZh9KyqVYqP73st1EGtdBkCMs1E7XJWvzzVRrWHUvMuRc c/RVuVrWnVVnnKuCVLC+q8k9e5r1x65FosErK2F1CiibSU6b6kad7yWIbtqyi X-Received: by 2002:a05:620a:1387:: with SMTP id k7mr21581815qki.134.1619540011360; Tue, 27 Apr 2021 09:13:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW/1PVlT3w2la6TsTdJYih8T6xfjtv6F8WrSt8l1jAsJMc097j8PN/4aDHkK+EGk9Dc9uj4w== X-Received: by 2002:a05:620a:1387:: with SMTP id k7mr21581769qki.134.1619540010984; Tue, 27 Apr 2021 09:13:30 -0700 (PDT) Received: from xz-x1.redhat.com (bras-base-toroon474qw-grc-77-184-145-104-227.dsl.bell.ca. [184.145.104.227]) by smtp.gmail.com with ESMTPSA id v66sm3103621qkd.113.2021.04.27.09.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 09:13:30 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Nadav Amit , Miaohe Lin , Mike Rapoport , Andrea Arcangeli , Hugh Dickins , peterx@redhat.com, Jerome Glisse , Mike Kravetz , Jason Gunthorpe , Matthew Wilcox , Andrew Morton , Axel Rasmussen , "Kirill A . Shutemov" Subject: [PATCH v2 06/24] mm: Drop first_index/last_index in zap_details Date: Tue, 27 Apr 2021 12:12:59 -0400 Message-Id: <20210427161317.50682-7-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210427161317.50682-1-peterx@redhat.com> References: <20210427161317.50682-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: rspam05 X-Rspamd-Queue-Id: B9D2480192ED X-Stat-Signature: iu8egwaq8md8s1aww86tkyr7k8bjkxwk Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619539992-984075 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 84fb1697b20ff..9060b497f4d5c 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 02db41bad3340..bcbce803e6850 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3213,20 +3213,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; @@ -3252,17 +3252,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); }