From mboxrd@z Thu Jan 1 00:00:00 1970 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 4BF4CC433EF for ; Sat, 18 Jun 2022 09:05:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFDB16B0071; Sat, 18 Jun 2022 05:05:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BACF56B0072; Sat, 18 Jun 2022 05:05:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC13E6B0073; Sat, 18 Jun 2022 05:05:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A02136B0071 for ; Sat, 18 Jun 2022 05:05:33 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 6A39960C3D for ; Sat, 18 Jun 2022 09:05:33 +0000 (UTC) X-FDA: 79590773346.16.72639B9 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf29.hostedemail.com (Postfix) with ESMTP id 4EB0F12009D for ; Sat, 18 Jun 2022 09:05:32 +0000 (UTC) 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: 8bit Content-Type: text/plain 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-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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=1655543133; 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: references; bh=eh0nlqwtPRJ9LIIBgGFri0Aed7wCqctf84Lg9/xwiBM=; b=20caTrDJjjpHO6zMaJh26PRyDvGdfeoDca2+f46KiZCfZXEPk4nVlC+OFjrSLvWs/8RcGT rBjM5m9nS6NcWt6rZ+zPWnKvhOlhVaRkoM04omSquqXK/UgG2JV4ZC3TtIm483JRb/g4qD bm25mGDV5jxXd1I/3hm3Cr/kVNNasow= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655543133; a=rsa-sha256; cv=none; b=1EYpuyYozkulrTP9UOWoLTE7EUo4dizr8TIPkHwjrat8+00a/rNHJ4qqz7B1rzdomtOAe5 5IHLWGUd4l7AWtlu/uFYd18oGVCtyUfjcfRtNCgRUJ3AxMV0hmbuOopvyQOh+l7W3++mA+ cWa25JaDZe/cq03PszMqgLLsUTjEN34= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4EB0F12009D X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: ermz93xuim63w86btt3cp8r9f4hx599q X-HE-Tag: 1655543132-725132 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: 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 *vma, 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 = walk->private; unsigned long index; struct swap_iocb *splug = NULL; @@ -209,11 +209,11 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start, struct page *page; spinlock_t *ptl; - orig_pte = pte_offset_map_lock(vma->vm_mm, pmd, start, &ptl); - pte = *(orig_pte + ((index - start) / PAGE_SIZE)); - pte_unmap_unlock(orig_pte, ptl); + ptep = pte_offset_map_lock(vma->vm_mm, pmd, index, &ptl); + pte = *ptep; + pte_unmap_unlock(ptep, ptl); - if (pte_present(pte) || pte_none(pte)) + if (!is_swap_pte(pte)) continue; entry = pte_to_swp_entry(pte); if (unlikely(non_swap_entry(entry))) -- 2.23.0