From patchwork Thu Dec 8 18:02:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13068644 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 A1710C4332F for ; Thu, 8 Dec 2022 18:03:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EA438E0006; Thu, 8 Dec 2022 13:03:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 29A0F8E0001; Thu, 8 Dec 2022 13:03:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13B038E0006; Thu, 8 Dec 2022 13:03:25 -0500 (EST) 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 04A4F8E0001 for ; Thu, 8 Dec 2022 13:03:25 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id ADC75406FC for ; Thu, 8 Dec 2022 18:03:24 +0000 (UTC) X-FDA: 80219911128.05.BC3648B Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf14.hostedemail.com (Postfix) with ESMTP id 9BCC0100020 for ; Thu, 8 Dec 2022 18:03:22 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iViaYugs; spf=pass (imf14.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670522602; a=rsa-sha256; cv=none; b=lXaZDBKwmKuDBXOLKmWdWc0z4TmJw8gC0aJRAB7MO/5ZTBxBYhKzXLLdDDfyuPQV8W0PAL 8fJ45utUw3bBrRoi7kWRmORYIgrGsiuTkoDxE5PJVGNMU5zqk6tvUuKiPVby4zUBnY5q+Y LOa6WopYRHdPkFeRpTnQx30OZRzDTps= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iViaYugs; spf=pass (imf14.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670522602; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=riLhoP57eVPqwj4BrvS8Vazxssa2eImOkYsWKI1T0t8=; b=vtxvbxw7LW5OiITxpjY5iJb12+rr7gezpE/dvjmArLW+tigIu2dRUofpxvtQenpFjlVx7a KeGAkT+XEpykzi/bUr3fecOklbXIdy4gmH6trzOUh1zUGJTYG9VzgkS9KZthZc5ZvDolsY PnY9tO8OeTEwPNquFsJ74GNtZGVoiXQ= Received: by mail-pl1-f182.google.com with SMTP id k7so2258714pll.6 for ; Thu, 08 Dec 2022 10:03:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=riLhoP57eVPqwj4BrvS8Vazxssa2eImOkYsWKI1T0t8=; b=iViaYugsyY36Co7pKi2yW3+3twUOGGTtNqIFgF0+7MBH5JAuAvr7KaDfROp3l9GO1t Srqh6rR1dXZMZbpBUXgZqXAo4mtoHxV4pakZa2i/mghgx0d8YgDWCqTQH6v3TePUuhHI yX3yaekIseUtoERJq9NEzxrgtTJrfI8d5Cp1R6AWvyBnz6vV1oUAR2djd1j/hMSt2k+Z 4+LL5CGtnmGv/5ZLisC4P7VAVLqe/cweXpWm3xgkYbR/b+jTCHWNVTBP/iMbpt1jht3L panlWfFI7BbV1LS54KzTKj/isn6g3pxCZzMObb0FaAMwDqDUsIUTZlII4ARmHeQIrm9x GrGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=riLhoP57eVPqwj4BrvS8Vazxssa2eImOkYsWKI1T0t8=; b=gRM/HM52mQbfuyJXt+/JXrAZWJmaBlZly8RyXfM3uSP9SwxX0sxjKQ1UaMVBQxuY25 iHGixLGS1eOZOYWexy3dkFqY10Qo95ed10d+eRyOP9NOhwrE4t3DrEE/wtoNGW9OaorP 00sQivbcXcjOUHgDp+2BCIcgPDYUGmRMs5JCzmSqTQajm1eGylL0zwdnw7TC3EilHhPa vAfsdxphIw+zi8aaevsKhE7MlNer4czSwjA1nDIAuBb/5zReKWzaSo/U9EdkNi/oqnwJ u9gG7KN2uDbY667vrBvVdnrht8jMj3SRch9s2LM1YCaVDKobP1UqLpFct6kCt3DZt/y1 JJjg== X-Gm-Message-State: ANoB5plEZ5HQovljH9bA+9Gf88Xb47QM20rDkq5blQJJntJFiJR45q/P EeninR/H3wmv2G0FEGZefheIrO4l9JuyFoBy X-Google-Smtp-Source: AA0mqf6+g/Oq8lkThW8oF445SVxUDWkraBM2XVzF2FkZ356SyOkPQrUSg1X2tifk5oVpQEdOJ+/wig== X-Received: by 2002:a17:90a:8c82:b0:213:1e29:c8dd with SMTP id b2-20020a17090a8c8200b002131e29c8ddmr2896254pjo.7.1670522601220; Thu, 08 Dec 2022 10:03:21 -0800 (PST) Received: from localhost.localdomain ([198.13.51.166]) by smtp.gmail.com with ESMTPSA id x23-20020a63db57000000b004785e505bcdsm13377909pgi.51.2022.12.08.10.03.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 08 Dec 2022 10:03:20 -0800 (PST) From: Kairui Song To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Andrew Morton , Miaohe Lin , David Hildenbrand , "Huang, Ying" , Hugh Dickins , Kairui Song Subject: [PATCH 2/5] swap: avoid a redundant pte map if ra window is 1 Date: Fri, 9 Dec 2022 02:02:06 +0800 Message-Id: <20221208180209.50845-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20221208180209.50845-1-ryncsn@gmail.com> References: <20221208180209.50845-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 9BCC0100020 X-Rspamd-Server: rspam01 X-Stat-Signature: 7hwhhe4guuipsgxs53ubf8hsgnnoxqky X-HE-Tag: 1670522602-245943 X-HE-Meta: U2FsdGVkX18rgLzFwJK/arx8ynT6aDZnHuM7mAPccgsBDv48TiwZf7U5I8UcwQNkW2BCh9QaM05OttvYG79lDUfHmqqsCrUPDI7meoKvYGs6ZSEZ8phxcvFldiwyVSdc1wD/+Kl63PdNVhfFNVzHMT4HjBvkgg4Sa1KVUKxcamTRsajlQgWI5ElrtxAY5py8DbGuFsa6RcAMbPm21pqXqpPf2+2Uq20O4W9XpOWHJPBf83kltlI+2abm2a82/8yHhLd218ujdEfoZFNR7SKlLoSY01HdJGig6JSwEKX1sjSY9Erhh9avZyeZzdPPmH1jYPz91axQxNh3J/+/AZTXw5sftWzYvpEkEFFtx/+T4ABuim+wxhQWqUS8d6nAGiYbwZRvhbMtPJGb4hSbME5HwZ4lODuc5TzPvERYCIo9t57rGsT9tmo1d53cDPuWmQqypk2MRCmqyAZdcqM/CKipNVhtsVmDLYizGRNhkPLIeFN91VoezPQdYhVp1uOr52QUpU4dnr+DPvWOPJTFS+ted2r2XdPpVWF44npxQ4SOwbb8POq0NO603Tvs92xpBowkWf+FXHX5X4xPUtLK/L8zumBOmCc8a7jc5UGK0b4+E/XJYhB5mHqK+anf0P7CQAh9Y4HsISQoNBCXdbWrQiGl3HaQunQUxEP92Pn+66pQLq6xvNmshGt3yc1Rr+3eBl7mShoh/4oZe93kRIpDOrXOcWdGHKsVN329iaDZuWbEA/aYzbFxUjeMmfiiq0SSW2U20Aauvq91FFbhvXtEAQg9rdGMeXk2KGksisxSk0xWaVYT+kfVC3sZ/B8KpT9hfWzh0Hpp/2xJ8QVJ9KhNaLdGap5fUjsM/rgVcZDuxLsLtgNP68NQMmEurjQvIOBfirSvJxWEVVLsQ+as+u8ErPVH6J37v5gthcJFzLfeNk9MBtEn+Jw9OOdEqq1Xrn5QKj6oxQwE8zggKRJhlTHhXbU Nh4MH/1N 1dNMog3DG05E3scsthfzdbfplm9NkGkDs/5yl6+35qOBkfCGcqV++PAdJyAmJHpWMGaUBzMWb8eIV9iMDwn38NRD/BNi/lsD6CkpICea2bIEiPDm5nWJu3cOVUWCNpLinoU2BczMS/0c53adb8HqXCWlLQoYGrGwPCvkUF/vaSTtgqH/Z7TzOHEf7jaPnE+Aa7b0e5piZ+ePf2uz7i8oS+ducLxa3uicQ31xhJ/s0JDrddYesD20JEJ49I8FWJHewS9yo+PSuYwkNCxz2Kxaf2EYArg== 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: From: Kairui Song Avoid a redundant pte map/unmap when swap readahead window is 1. Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- mm/swap_state.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index 438d0676c5be..60136bda78e3 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -730,8 +730,6 @@ static void swap_ra_info(struct vm_fault *vmf, } faddr = vmf->address; - orig_pte = pte = pte_offset_map(vmf->pmd, faddr); - fpfn = PFN_DOWN(faddr); ra_val = GET_SWAP_RA_VAL(vma); pfn = PFN_DOWN(SWAP_RA_ADDR(ra_val)); @@ -742,12 +740,11 @@ static void swap_ra_info(struct vm_fault *vmf, atomic_long_set(&vma->swap_readahead_info, SWAP_RA_VAL(faddr, win, 0)); - if (win == 1) { - pte_unmap(orig_pte); + if (win == 1) return; - } /* Copy the PTEs because the page table may be unmapped */ + orig_pte = pte = pte_offset_map(vmf->pmd, faddr); if (fpfn == pfn + 1) swap_ra_clamp_pfn(vma, faddr, fpfn, fpfn + win, &start, &end); else if (pfn == fpfn + 1)