From patchwork Wed Jun 22 17:06:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891177 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 A0D2BC43334 for ; Wed, 22 Jun 2022 17:07:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 010D98E00D2; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E8D988E00D1; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D07098E00D2; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AB1998E00D1 for ; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 72E332142C for ; Wed, 22 Jun 2022 17:06:53 +0000 (UTC) X-FDA: 79606501506.03.5E872F9 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf09.hostedemail.com (Postfix) with ESMTP id 31A171400C7 for ; Wed, 22 Jun 2022 17:06:50 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LSqVZ3FCpz1KC4m; Thu, 23 Jun 2022 01:04:22 +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; Thu, 23 Jun 2022 01:06:29 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 05/16] mm/huge_memory: use helper touch_pmd in huge_pmd_set_accessed Date: Thu, 23 Jun 2022 01:06:16 +0800 Message-ID: <20220622170627.19786-6-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917612; a=rsa-sha256; cv=none; b=Q7PHeOMTyHZ+oSGlC5qP3xux8Y62Vm8ucEclzLwNZy/hNJbKbbIShjzmC9XkMs4f53TKS3 DTdh1VhDDi+6Xjpni12kAcaY38rNUlNo6rAab+HBeiViqcn6TWr7FfkNcaY+5FYhWTPWp3 iFQ4XSUEWVtLlFKwE1++oyGeskOGSMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655917612; 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=174fjyX0Hja8nW9P18Ui4XCy2P1Rk/MUkl0TOYVnsI0=; b=FXt3C5/lOL7+zdpEh5UjP6GQ41lqKJOJIpjYyqTMq9y/fggAdX7dMrq+fenWdO5TUUpzHv jNlPe69sF9r+ZFSstE7843Q5NdWew7Jjjd+vMY2tb2nq+xeqj6c+6gVfTHMzvvdtZGAjl6 2n6LSDzLKG+pWBle7XFIQ11NyO+wqT0= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Queue-Id: 31A171400C7 Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: o7b9zu5suxdozbdtkoqszhqa9ion56ra X-Rspamd-Server: rspam09 X-HE-Tag: 1655917610-359947 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 | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index a0c0e4bf9c1e..c6302fe6704b 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1297,21 +1297,15 @@ 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; + int flags = 0; 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); + if (vmf->flags & FAULT_FLAG_WRITE) + flags = FOLL_WRITE; + touch_pmd(vmf->vma, vmf->address, vmf->pmd, flags); unlock: spin_unlock(vmf->ptl);