From patchwork Sun Jul 18 04:30:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 12384145 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 5FDCDC636C8 for ; Sun, 18 Jul 2021 04:31:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EF6AB6101A for ; Sun, 18 Jul 2021 04:31:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF6AB6101A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 883818D00F8; Sun, 18 Jul 2021 00:31:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 85A338D00EC; Sun, 18 Jul 2021 00:31:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D4638D00F8; Sun, 18 Jul 2021 00:31:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0125.hostedemail.com [216.40.44.125]) by kanga.kvack.org (Postfix) with ESMTP id 4CE358D00EC for ; Sun, 18 Jul 2021 00:31:10 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E805620BC8 for ; Sun, 18 Jul 2021 04:31:08 +0000 (UTC) X-FDA: 78374433816.38.3D5E578 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf21.hostedemail.com (Postfix) with ESMTP id 36812D01D090 for ; Sun, 18 Jul 2021 04:31:08 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id k20so15158300pgg.7 for ; Sat, 17 Jul 2021 21:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wRajOpLA0v1TNv8hnPmCgKVUqgXOc73LdDDlPiANufk=; b=rBZ5wgb9Doxy7AHPWbdepUo9lcn6ND7c7FJWOSnkIoEE4k8CYaxkBxncbBQa5LCg4G 0TdSDv59/Vufe4EeGZ/3OwhHGxZviq9sQ6fvTUXyg9FB7Gets1PiLBwXnGckqcLRL422 yWtu/GbOnL+dmSgzrE8l7Ze9reuub+QlD9tdJsV9vqRHtw2ZwhmAd5/QI6951KFNr+g4 QxPg0hoSt3IzyWpOmrsQVWKeSUGNx3pCW8jNsf9qle7LcZy1/DeYZ2GYUh/6MDRJlwHR 6dLBWEOGC12V2+ZypC12fopRWtEvcMCjf+AAdBQJKK5LybYs3YXBoqKlU9O046UxPei6 PVZg== 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=wRajOpLA0v1TNv8hnPmCgKVUqgXOc73LdDDlPiANufk=; b=UnRrGcj4N4E/bqC+lsMNcbwl9j+ZMJgL6e9sLs66jMhw0hFRQ1rBoTEb5uPjrkZlqY bH9Y9bICoIM37gP5uEECv225C4Vw1u7RvCHsv4DVgDfYZGcIWTDgCp+sB8A8mL91Ct8z usVmzqpwG05Zht4x5cqo6Iq9xcxca94ivAMkUbhcDSLQ5gz8+NnXhJqA8T+7y9dqIWha NBxJ0wyZKB0c+YbqtnHMdL8tca7bxN1+VclWaSSCvIsYR/BLe6WGRlL4wj1yC5vKv7Ce /O/bMoMX1iziLr4OIjeaioX+mXOp61rOseoDxYIQw5TBEiPGp/yk4pUtmO6BKA7Wk6ZP Aebw== X-Gm-Message-State: AOAM533SaztrKGmF6VKGPt+qA2eLabs2P9G6sLqAkXfrvEBMeJPLs3dK pQuYqGVCu3R9/K4HMCDtfxa3jg== X-Google-Smtp-Source: ABdhPJxEcAv0pVXtSymweg/qeyMcrHmxw3wFaXKXm0btaki4iny96UKNgdRKdU2xwo7CdiLjrZptgw== X-Received: by 2002:a63:3704:: with SMTP id e4mr18222378pga.310.1626582667438; Sat, 17 Jul 2021 21:31:07 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.253]) by smtp.gmail.com with ESMTPSA id a22sm16263217pgv.84.2021.07.17.21.31.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Jul 2021 21:31:07 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, tglx@linutronix.de, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, songmuchun@bytedance.com, Qi Zheng Subject: [PATCH 4/7] mm: rework the parameter of lock_page_or_retry() Date: Sun, 18 Jul 2021 12:30:30 +0800 Message-Id: <20210718043034.76431-5-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210718043034.76431-1-zhengqi.arch@bytedance.com> References: <20210718043034.76431-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=rBZ5wgb9; spf=pass (imf21.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Server: rspam02 X-Stat-Signature: h9pi5473bsc85gnii3d4kwgkjgaumxg4 X-Rspamd-Queue-Id: 36812D01D090 X-HE-Tag: 1626582668-359593 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: we need the vmf in lock_page_or_retry() in the subsequent patch, so pass in it directly. Signed-off-by: Qi Zheng --- include/linux/pagemap.h | 8 +++----- mm/filemap.c | 6 ++++-- mm/memory.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index b071babc6629..bc23f6ff4fce 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -653,8 +653,7 @@ static inline bool wake_page_match(struct wait_page_queue *wait_page, extern void __lock_page(struct page *page); extern int __lock_page_killable(struct page *page); extern int __lock_page_async(struct page *page, struct wait_page_queue *wait); -extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm, - unsigned int flags); +extern int __lock_page_or_retry(struct page *page, struct vm_fault *vmf); extern void unlock_page(struct page *page); /* @@ -712,11 +711,10 @@ static inline int lock_page_async(struct page *page, * Return value and mmap_lock implications depend on flags; see * __lock_page_or_retry(). */ -static inline int lock_page_or_retry(struct page *page, struct mm_struct *mm, - unsigned int flags) +static inline int lock_page_or_retry(struct page *page, struct vm_fault *vmf) { might_sleep(); - return trylock_page(page) || __lock_page_or_retry(page, mm, flags); + return trylock_page(page) || __lock_page_or_retry(page, vmf); } /* diff --git a/mm/filemap.c b/mm/filemap.c index 4955641f2cf0..db0184884890 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1686,9 +1686,11 @@ int __lock_page_async(struct page *page, struct wait_page_queue *wait) * If neither ALLOW_RETRY nor KILLABLE are set, will always return 1 * with the page locked and the mmap_lock unperturbed. */ -int __lock_page_or_retry(struct page *page, struct mm_struct *mm, - unsigned int flags) +int __lock_page_or_retry(struct page *page, struct vm_fault *vmf) { + unsigned int flags = vmf->flags; + struct mm_struct *mm = vmf->vma->vm_mm; + if (fault_flag_allow_retry_first(flags)) { /* * CAUTION! In this case, mmap_lock is not released diff --git a/mm/memory.c b/mm/memory.c index 540f0c9d0970..3bf2636413ee 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3451,7 +3451,7 @@ static vm_fault_t remove_device_exclusive_entry(struct vm_fault *vmf) struct vm_area_struct *vma = vmf->vma; struct mmu_notifier_range range; - if (!lock_page_or_retry(page, vma->vm_mm, vmf->flags)) + if (!lock_page_or_retry(page, vmf)) return VM_FAULT_RETRY; mmu_notifier_range_init_owner(&range, MMU_NOTIFY_EXCLUSIVE, 0, vma, vma->vm_mm, vmf->address & PAGE_MASK, @@ -3583,7 +3583,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) goto out_release; } - locked = lock_page_or_retry(page, vma->vm_mm, vmf->flags); + locked = lock_page_or_retry(page, vmf); delayacct_clear_flag(current, DELAYACCT_PF_SWAPIN); if (!locked) {