From patchwork Wed Nov 10 10:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 12611765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0A18C433F5 for ; Wed, 10 Nov 2021 10:55:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 869D5611BF for ; Wed, 10 Nov 2021 10:55:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 869D5611BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2A1426B0072; Wed, 10 Nov 2021 05:55:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 22AB96B0073; Wed, 10 Nov 2021 05:55:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A3B86B0074; Wed, 10 Nov 2021 05:55:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0128.hostedemail.com [216.40.44.128]) by kanga.kvack.org (Postfix) with ESMTP id ED7166B0072 for ; Wed, 10 Nov 2021 05:55:02 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A44E77DCBA for ; Wed, 10 Nov 2021 10:55:02 +0000 (UTC) X-FDA: 78792713370.05.BC3E9C9 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf29.hostedemail.com (Postfix) with ESMTP id 419199000271 for ; Wed, 10 Nov 2021 10:55:02 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id gt5so1249254pjb.1 for ; Wed, 10 Nov 2021 02:55:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zr0rEdADAEaJn1N2dbntb6SW/6iRFYHNNestGTjHAUw=; b=HPUN9ql1FG+neFcOlqge+XfZ9d8NFw14fMg58AGUz+eydfvC09cyZa+jcxb37NzfN5 V+H/2f3OtvfVTRoEPwomKmsxjjqz2tMWLvloxX+azi3MAXcdKwuvd5OnzjaVX0gKhPzL ivUobAdbapEhRBbzYIxpjYe2raMmkrMTaIWLIz41b0EYHen3+ZyyirO8ubW0jWEHLAVq tjmAUQ1Up9N/eOYzd9ojy70F+Imu2eGknw+fLV/mxocHK4wNJ8/9NmMaQPze5m7I23w2 QNSqhp1lPC8zoP39jltkuYN/T7wIgJRV4kG4gznwzXCpvqxw44X5adLh0RLH7Oazvq6W n2Vw== 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=Zr0rEdADAEaJn1N2dbntb6SW/6iRFYHNNestGTjHAUw=; b=4vIk1BOYUTvKbmccNVM8Pb5xSPgBzkGyhU580PbN4zsVMU7+Hr568viG7yzq2m+rrN DGE2+tDechsqK7l+Ic0fVkj/fpTY4PPQxuW8DnmXEZha0rJ1+/cgjg5zxQfSRHfWq8AH lUzvvkFNDLYXZjfmzoSWQp8iciAQZXKIvcNL1axVVKwkBxD8XD26hJYFuv8CgoeGR2MX g7260xTD6Tx76BVuQWerQObskLwumkpCR/h4k4IRh46mffTwI4OV0knvGJAdojTBqUMR RXEvTy3vQqcktlN1Kz7Q7IQ196X20/vDI3gCsZJF2bmVt+fRfZ8eUr6IEZ9oVW1d45ZW 1kJQ== X-Gm-Message-State: AOAM531j+w/8fzg1vuVqWaWBGuqCbmFvHVknTRFUTGDNtclld5v/wfvy uOKgCT29bEAVVmJ8XJD9THF/iQ== X-Google-Smtp-Source: ABdhPJwFh1bEBmmrAr/exJm9KrX1d9IXTLyrDWgr/IvlDLpUmsG5/fJDb/+NBSZdkcokjcHWkv0S4A== X-Received: by 2002:a17:902:f693:b0:142:9ec:c2e1 with SMTP id l19-20020a170902f69300b0014209ecc2e1mr14415302plg.34.1636541701391; Wed, 10 Nov 2021 02:55:01 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.251]) by smtp.gmail.com with ESMTPSA id v38sm5865829pgl.38.2021.11.10.02.54.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Nov 2021 02:55:01 -0800 (PST) From: Qi Zheng To: akpm@linux-foundation.org, tglx@linutronix.de, kirill.shutemov@linux.intel.com, mika.penttila@nextfour.com, david@redhat.com, jgg@nvidia.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, songmuchun@bytedance.com, zhouchengming@bytedance.com, Qi Zheng Subject: [PATCH v3 04/15] mm: rework the parameter of lock_page_or_retry() Date: Wed, 10 Nov 2021 18:54:17 +0800 Message-Id: <20211110105428.32458-5-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20211110105428.32458-1-zhengqi.arch@bytedance.com> References: <20211110105428.32458-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 419199000271 X-Stat-Signature: 9wwxd5c66njst5b8uw95ynj5ft5u5j35 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=HPUN9ql1; spf=pass (imf29.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1636541702-975046 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 6a30916b76e5..94f9547b4411 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -709,8 +709,7 @@ static inline bool wake_page_match(struct wait_page_queue *wait_page, void __folio_lock(struct folio *folio); int __folio_lock_killable(struct folio *folio); -bool __folio_lock_or_retry(struct folio *folio, struct mm_struct *mm, - unsigned int flags); +bool __folio_lock_or_retry(struct folio *folio, struct vm_fault *vmf); void unlock_page(struct page *page); void folio_unlock(struct folio *folio); @@ -772,14 +771,13 @@ static inline int lock_page_killable(struct page *page) * Return value and mmap_lock implications depend on flags; see * __folio_lock_or_retry(). */ -static inline bool lock_page_or_retry(struct page *page, struct mm_struct *mm, - unsigned int flags) +static inline bool lock_page_or_retry(struct page *page, struct vm_fault *vmf) { struct folio *folio; might_sleep(); folio = page_folio(page); - return folio_trylock(folio) || __folio_lock_or_retry(folio, mm, flags); + return folio_trylock(folio) || __folio_lock_or_retry(folio, vmf); } /* diff --git a/mm/filemap.c b/mm/filemap.c index 07c654202870..ff8d19b7ce1d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1695,9 +1695,11 @@ static int __folio_lock_async(struct folio *folio, struct wait_page_queue *wait) * If neither ALLOW_RETRY nor KILLABLE are set, will always return true * with the folio locked and the mmap_lock unperturbed. */ -bool __folio_lock_or_retry(struct folio *folio, struct mm_struct *mm, - unsigned int flags) +bool __folio_lock_or_retry(struct folio *folio, 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 b00cd60fc368..bec6a5d5ee7c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3443,7 +3443,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, @@ -3576,7 +3576,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) {