From patchwork Tue Jun 28 13:28:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898292 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 573A1C43334 for ; Tue, 28 Jun 2022 13:28:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9A3E8E0008; Tue, 28 Jun 2022 09:28:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF9DD8E0007; Tue, 28 Jun 2022 09:28:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B74368E0008; Tue, 28 Jun 2022 09:28:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9A8548E0007 for ; Tue, 28 Jun 2022 09:28:47 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 62AE7606A9 for ; Tue, 28 Jun 2022 13:28:47 +0000 (UTC) X-FDA: 79627724694.21.4E79D73 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf20.hostedemail.com (Postfix) with ESMTP id 2F6791C0042 for ; Tue, 28 Jun 2022 13:28:45 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LXQLv1wYpzTgJ6; Tue, 28 Jun 2022 21:25:11 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:28:40 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 05/16] mm/huge_memory: use helper touch_pmd in huge_pmd_set_accessed Date: Tue, 28 Jun 2022 21:28:24 +0800 Message-ID: <20220628132835.8925-6-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422927; a=rsa-sha256; cv=none; b=5Sr7rzRxyZPelstdp3NKnHKTYLCdrFLDYTss/7yIuygUpTz2OHd7iH6G/yLV68Rf9qHzB4 Z8/x5T7NpXShWT85dc8bFOdPph9ScEqBVPAypzBt6KpGj/gHUe/x9bs6SHjUIJC+1mEiyw 8DUAxK2p3PvMMn6xf5SHFuoxIlcusPY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422927; h=from:from:sender: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=dOx+R3saS3YDAxS2/+TLnMOE7l0dSUBD5WAgrYqRlag=; b=eyxBKWc0nVtoiZvZ7dsCmYCD6Ht8m6sxR782xfwoHkP0ZbV8gsP3R/ksxGFjNQmtdmKeYj 5G8Aswi9t0pKsbGvvkASTI8fW7Me6/9ndHiJm/MYMqtAACuK/+s2UJdvw/rYird7uIHpSO K+B+nM5RqA6RuXI0Kj/CU94lBy9LGVY= X-Stat-Signature: ci9npnb5939mqjexas5g5r5ix75oeygt X-Rspamd-Queue-Id: 2F6791C0042 Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1656422925-839376 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: Use helper touch_pmd to set pmd accessed to simplify the code and improve the readability. No functional change intended. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index d55d5efa06c8..d9fe9b034783 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1120,15 +1120,15 @@ EXPORT_SYMBOL_GPL(vmf_insert_pfn_pud_prot); #endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ static void touch_pmd(struct vm_area_struct *vma, unsigned long addr, - pmd_t *pmd, int flags) + pmd_t *pmd, bool write) { pmd_t _pmd; _pmd = pmd_mkyoung(*pmd); - if (flags & FOLL_WRITE) + if (write) _pmd = pmd_mkdirty(_pmd); if (pmdp_set_access_flags(vma, addr & HPAGE_PMD_MASK, - pmd, _pmd, flags & FOLL_WRITE)) + pmd, _pmd, write)) update_mmu_cache_pmd(vma, addr, pmd); } @@ -1398,21 +1398,13 @@ void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud) void huge_pmd_set_accessed(struct vm_fault *vmf) { - pmd_t entry; - unsigned long haddr; bool write = vmf->flags & FAULT_FLAG_WRITE; - pmd_t orig_pmd = vmf->orig_pmd; vmf->ptl = pmd_lock(vmf->vma->vm_mm, vmf->pmd); - if (unlikely(!pmd_same(*vmf->pmd, orig_pmd))) + if (unlikely(!pmd_same(*vmf->pmd, vmf->orig_pmd))) goto unlock; - entry = pmd_mkyoung(orig_pmd); - if (write) - entry = pmd_mkdirty(entry); - haddr = vmf->address & HPAGE_PMD_MASK; - if (pmdp_set_access_flags(vmf->vma, haddr, vmf->pmd, entry, write)) - update_mmu_cache_pmd(vmf->vma, vmf->address, vmf->pmd); + touch_pmd(vmf->vma, vmf->address, vmf->pmd, write); unlock: spin_unlock(vmf->ptl);