From patchwork Tue Jun 28 13:28:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898290 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 DF803C43334 for ; Tue, 28 Jun 2022 13:28:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18DD38E0003; Tue, 28 Jun 2022 09:28:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D0138E0006; Tue, 28 Jun 2022 09:28:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B758E8E0003; Tue, 28 Jun 2022 09:28:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6D91F6B0073 for ; Tue, 28 Jun 2022 09:28:45 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4A637611B5 for ; Tue, 28 Jun 2022 13:28:45 +0000 (UTC) X-FDA: 79627724610.06.BCC5F42 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf09.hostedemail.com (Postfix) with ESMTP id EC6ED14003A for ; Tue, 28 Jun 2022 13:28:43 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LXQQ8311tz9sqr; Tue, 28 Jun 2022 21:28:00 +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:39 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 04/16] mm/huge_memory: use helper touch_pud in huge_pud_set_accessed Date: Tue, 28 Jun 2022 21:28:23 +0800 Message-ID: <20220628132835.8925-5-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-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.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422924; a=rsa-sha256; cv=none; b=mCQaxePoAa3Kk6gBTtJbx+PGudfqvSjedJvbkUmtUK/H9x4oA41XR5hStDPyoiMa8ISQGS K/fOcD7q7mVyXP740Y4yDKgdgyTm8MfdnqLdpBEZ3kaUbGD4/Q7//4Ba9+qzSkHQk2RMuK ASIwIaWdP3i3GnfIAcng1gIc9fgG7fk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422924; 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=o5HiH1O7osVRwJnFwVWTRthO9yg/7gewOsnHNaFn3/k=; b=q8byYJk0r1oKi8EKt27jSjA1110T6sbZZ1eRIwvUxcs9/65c+LBJAVqjApoaqSuLVuXVVr QBfXgiGBbtKhgfRn+m9MNqQSRRuv0MB1nrvhXRfVw5A4WHKK56S4qAHoggyjvp5WVCCv7U HQrVrOTPWHb88NfJ446Vb2QFPKKVAsE= X-Stat-Signature: ywgnaosnsj15pig8aumaopy5h39efanq X-Rspamd-Server: rspam08 X-Rspam-User: X-Rspamd-Queue-Id: EC6ED14003A 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.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1656422923-243911 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_pud to set pud 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, 4 insertions(+), 12 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f7164ef8b6e3..d55d5efa06c8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1284,15 +1284,15 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD static void touch_pud(struct vm_area_struct *vma, unsigned long addr, - pud_t *pud, int flags) + pud_t *pud, bool write) { pud_t _pud; _pud = pud_mkyoung(*pud); - if (flags & FOLL_WRITE) + if (write) _pud = pud_mkdirty(_pud); if (pudp_set_access_flags(vma, addr & HPAGE_PUD_MASK, - pud, _pud, flags & FOLL_WRITE)) + pud, _pud, write)) update_mmu_cache_pud(vma, addr, pud); } @@ -1384,21 +1384,13 @@ int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm, void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud) { - pud_t entry; - unsigned long haddr; bool write = vmf->flags & FAULT_FLAG_WRITE; vmf->ptl = pud_lock(vmf->vma->vm_mm, vmf->pud); if (unlikely(!pud_same(*vmf->pud, orig_pud))) goto unlock; - entry = pud_mkyoung(orig_pud); - if (write) - entry = pud_mkdirty(entry); - haddr = vmf->address & HPAGE_PUD_MASK; - if (pudp_set_access_flags(vmf->vma, haddr, vmf->pud, entry, write)) - update_mmu_cache_pud(vmf->vma, vmf->address, vmf->pud); - + touch_pud(vmf->vma, vmf->address, vmf->pud, write); unlock: spin_unlock(vmf->ptl); }