From patchwork Wed Nov 10 10:54:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 12611839 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 12EFAC433EF for ; Wed, 10 Nov 2021 11:03:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B569261207 for ; Wed, 10 Nov 2021 11:03:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B569261207 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 52FD06B006C; Wed, 10 Nov 2021 06:03:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B8EE6B007E; Wed, 10 Nov 2021 06:03:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 332CF6B0080; Wed, 10 Nov 2021 06:03:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id 24E546B006C for ; Wed, 10 Nov 2021 06:03:16 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DF68F80B9117 for ; Wed, 10 Nov 2021 11:03:15 +0000 (UTC) X-FDA: 78792733950.28.57FF8E4 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf08.hostedemail.com (Postfix) with ESMTP id 0D6CA30000AE for ; Wed, 10 Nov 2021 11:02:58 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id n23so1921417pgh.8 for ; Wed, 10 Nov 2021 03:03:12 -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=Qt7zreSDUacj2v2u5kH5eyo4ziYtzmNFB0lGNIs9uO4=; b=l8SsT/vCxWFUSSMF7MX9Zo49Dqycpk/E1y+Wj4vtEiwoSuYn6Ot7lQu1+VmZimpDHK HYWgzARYq87nMhl+I6uWWdQRfQkz9hlfQW9ZUj5tw6KuEoL3xriYFo8Ofw1f8TxO4Kq7 TOr4HKwhTU6YNx9YjOX6HnODyTjswL+NE+DsDz2wqNYDFRkbSA7+rxI6jURVgWrby9sZ aQ5/aR94ZsBmjchdXP177x5J/cVtS+qn8XSbWLirL2JpO262nb7ovAfN6lmQAx5key0i 61WEurRpY1dhr6PTI8E/yv02FgJvUvY1/lBbg0vdFLL8vsYCSGc6pD9eKyvA4FXeblJt 9xHg== 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=Qt7zreSDUacj2v2u5kH5eyo4ziYtzmNFB0lGNIs9uO4=; b=a9rF3gk00VVIEy7OUtwYbHBq8B0LCBVOckgT1jbRGoGbf95SJerpP1u7qY3lzaJ8Fi Bjd4QDav2rF5CmqKWdAi2kLbCuY5zAwjaUAqVO8KRj5IoFciYjzjJzA0k7Z+DcBt4PrV ZM2JKoTssyPScaPn16ttUP2dkHgX2vzKXK0QwVwDSyAvy0g2WTmVuv8av+9rQuBUqbUS x16ZxcLyub9qwmV2LGz3Tre5YYrYugnau1eTgs3r6mB6rjHm13IdQ2eCptL7CzYfLP8q VI5UqBUd8M4M37/IcGVTmcADwkAqPRRfGm4/dRAbsic+P82Ymk3dr59q5y65SizqTlf8 b3JA== X-Gm-Message-State: AOAM530auE6YizZ1MYnoeB8cK3i1cmgpLYOuZY1SmnQIgWkJ2bwjjtED NRQBS4JBKNQ1iF5PnS7ltkfU/l/nPPWylA== X-Google-Smtp-Source: ABdhPJza7nfvYf9STeiUke1V+/jRoDSu267dlbThM8QvxtxpYIF51oy/+RM2CrjL2b6yY0gkHT246A== X-Received: by 2002:a17:902:8f93:b0:142:8731:1a5d with SMTP id z19-20020a1709028f9300b0014287311a5dmr14860865plo.60.1636541685575; Wed, 10 Nov 2021 02:54:45 -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.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Nov 2021 02:54:45 -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 01/15] mm: do code cleanups to filemap_map_pmd() Date: Wed, 10 Nov 2021 18:54:14 +0800 Message-Id: <20211110105428.32458-2-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 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="l8SsT/vC"; spf=pass (imf08.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0D6CA30000AE X-Stat-Signature: gj5ib39hmxxcho1becy9xdrq9p9urqh5 X-HE-Tag: 1636542178-277709 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: Currently we have two times the same few lines repeated in filemap_map_pmd(). Deduplicate them and fix some code style issues. Signed-off-by: Qi Zheng --- mm/filemap.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index daa0e23a6ee6..07c654202870 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3203,11 +3203,8 @@ static bool filemap_map_pmd(struct vm_fault *vmf, struct page *page) struct mm_struct *mm = vmf->vma->vm_mm; /* Huge page is mapped? No need to proceed. */ - if (pmd_trans_huge(*vmf->pmd)) { - unlock_page(page); - put_page(page); - return true; - } + if (pmd_trans_huge(*vmf->pmd)) + goto out; if (pmd_none(*vmf->pmd) && PageTransHuge(page)) { vm_fault_t ret = do_set_pmd(vmf, page); @@ -3222,13 +3219,15 @@ static bool filemap_map_pmd(struct vm_fault *vmf, struct page *page) pmd_install(mm, vmf->pmd, &vmf->prealloc_pte); /* See comment in handle_pte_fault() */ - if (pmd_devmap_trans_unstable(vmf->pmd)) { - unlock_page(page); - put_page(page); - return true; - } + if (pmd_devmap_trans_unstable(vmf->pmd)) + goto out; return false; + +out: + unlock_page(page); + put_page(page); + return true; } static struct page *next_uptodate_page(struct page *page,