From nobody Mon Apr 27 02:07:51 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B06B6C433EF for ; Sat, 18 Jun 2022 09:05:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232869AbiFRJFg (ORCPT ); Sat, 18 Jun 2022 05:05:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233087AbiFRJFa (ORCPT ); Sat, 18 Jun 2022 05:05:30 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F055F313BA for ; Sat, 18 Jun 2022 02:05:28 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LQ91R3zkmzhYWw; Sat, 18 Jun 2022 17:03:23 +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; Sat, 18 Jun 2022 17:05:25 +0800 From: Miaohe Lin To: CC: , , Subject: [PATCH] mm/madvise: minor cleanup for swapin_walk_pmd_entry() Date: Sat, 18 Jun 2022 17:05:27 +0800 Message-ID: <20220618090527.37843-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Passing index to pte_offset_map_lock() directly so the below calculation can be avoided. Rename orig_pte to ptep as it's not changed. Also use helper is_swap_pte() to improve the readability. No functional change intended. Signed-off-by: Miaohe Lin --- mm/madvise.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 7a8af04069b3..cf49e123991c 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -195,7 +195,7 @@ static int madvise_update_vma(struct vm_area_struct *vm= a, static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start, unsigned long end, struct mm_walk *walk) { - pte_t *orig_pte; + pte_t *ptep; struct vm_area_struct *vma =3D walk->private; unsigned long index; struct swap_iocb *splug =3D NULL; @@ -209,11 +209,11 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned= long start, struct page *page; spinlock_t *ptl; =20 - orig_pte =3D pte_offset_map_lock(vma->vm_mm, pmd, start, &ptl); - pte =3D *(orig_pte + ((index - start) / PAGE_SIZE)); - pte_unmap_unlock(orig_pte, ptl); + ptep =3D pte_offset_map_lock(vma->vm_mm, pmd, index, &ptl); + pte =3D *ptep; + pte_unmap_unlock(ptep, ptl); =20 - if (pte_present(pte) || pte_none(pte)) + if (!is_swap_pte(pte)) continue; entry =3D pte_to_swp_entry(pte); if (unlikely(non_swap_entry(entry))) --=20 2.23.0