From patchwork Fri May 27 09:26:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12863180 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 A7BEFC433F5 for ; Fri, 27 May 2022 09:26:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80F118D0005; Fri, 27 May 2022 05:26:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BAAF8D0008; Fri, 27 May 2022 05:26:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 541C88D0005; Fri, 27 May 2022 05:26:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3DAF28D0006 for ; Fri, 27 May 2022 05:26:19 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1272635B59 for ; Fri, 27 May 2022 09:26:19 +0000 (UTC) X-FDA: 79510992078.10.4FDC0A0 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf08.hostedemail.com (Postfix) with ESMTP id 979D916003F for ; Fri, 27 May 2022 09:25:55 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4L8fXB4Q2Kz1JByS; Fri, 27 May 2022 17:24:42 +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; Fri, 27 May 2022 17:26:15 +0800 From: Miaohe Lin To: CC: , , Subject: [PATCH 2/3] mm/swapfile: avoid confusing swap cache statistics Date: Fri, 27 May 2022 17:26:25 +0800 Message-ID: <20220527092626.31883-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220527092626.31883-1-linmiaohe@huawei.com> References: <20220527092626.31883-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 979D916003F X-Stat-Signature: buicewmtm3tiua9jf1im7143ro5qzns8 Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-HE-Tag: 1653643555-674646 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: At swapoff time, we're going to swap in the pages continuously. So calling lookup_swap_cache would confuse statistics. We should use find_get_page directly here. Signed-off-by: Miaohe Lin --- mm/swapfile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 960d14a4b19e..e033a53a99df 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1865,7 +1865,12 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, offset = swp_offset(entry); pte_unmap(pte); swap_map = &si->swap_map[offset]; - page = lookup_swap_cache(entry, vma, addr); + /* + * Since we're going to swap in the pages continuously, + * calling lookup_swap_cache() would confuse statistics. + */ + page = find_get_page(swap_address_space(entry), + swp_offset(entry)); if (!page) { struct vm_fault vmf = { .vma = vma,