From patchwork Mon Dec 19 18:58:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13077055 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 BFC16C4332F for ; Mon, 19 Dec 2022 18:59:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40D168E0005; Mon, 19 Dec 2022 13:59:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BD538E0001; Mon, 19 Dec 2022 13:59:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 285598E0005; Mon, 19 Dec 2022 13:59:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1AE1A8E0001 for ; Mon, 19 Dec 2022 13:59:26 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E512CC09CD for ; Mon, 19 Dec 2022 18:59:25 +0000 (UTC) X-FDA: 80259969090.13.ED1CFA1 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf16.hostedemail.com (Postfix) with ESMTP id 3C3DB180015 for ; Mon, 19 Dec 2022 18:59:24 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="SjsPir/G"; spf=pass (imf16.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.50 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=1671476364; a=rsa-sha256; cv=none; b=pd1cNOoDHSUeEMEi0RXq7jQV4ciz/ZRfqFQ5krkyL0fOaCsOi+8yLvTTY/28XP9qbZwArz xfDgcPwHeXVm2yp11KdqYAVPTr6vA0PpAAjoOXTs14faXJpWv0yMOqyT9LGA2BXapqefsG 91OVB3WV24wdnxiRt17yqKOnfg/bfgs= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="SjsPir/G"; spf=pass (imf16.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.50 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=1671476364; 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=rNW8A16mCA3HvLKh5wBxi0WsnpxyoQsg0W035rUDdlU=; b=WmQf2Wz5tqol2gH9CrUE4qKpheJIiCqezbSKJws0qyipz+3eGwmz7aPVMFsNOzRu126zpq WBoWbWthhxVShXBcDSNjDKdwskbhglwFJko7nxjbaJMW/Siw+RJYNGxIXorR/UV7Yx35OA yo0hmJ7vcoviGRR7fHGt+9cL7kMcAcE= Received: by mail-pj1-f50.google.com with SMTP id u5so10023278pjy.5 for ; Mon, 19 Dec 2022 10:59:23 -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=rNW8A16mCA3HvLKh5wBxi0WsnpxyoQsg0W035rUDdlU=; b=SjsPir/GRG0O5nhdNnhsaE3MhQHqJZ4mVl/THUD4eCydfYFbtbpemySFb+Ft5Wdx5U 2MrDiiZASOzg8/oHQZoGZFNeTeGjXDbgTDDOlSs6tLS6zQk1tzOsRZos8c0IR8miW92d XShpB9RiypeH8hMu1FE4S7AUJDYfQ3+9P9pQf6ZPJMJBhHCIwPruDMC6aOy6HctXFevj g9tBhlQDX3N1yS+QcdS+/VZhPcmlP+SuchHqDbQjIulJD6bCkDFcBWPKFCTTNnibzw40 FUXZN88VJWNIfWZ1wzctW56tuC23pAApGc0qxk11gf4vEEwEKzDO3uURBz3G9z0MXAFU yHsQ== 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=rNW8A16mCA3HvLKh5wBxi0WsnpxyoQsg0W035rUDdlU=; b=cGZucHHa+JO7ko14f+kzjXT6J0U5L0kmiBKwkb1VRYPE3eI+/SQIlnShpBGTlP5P4w VoRNq93Sz6YIgF/gO22oi3FoGtruPTfTnpw02M+J1ON2iY5en8XeNCWIDpryHSD/kkI7 na+I9AEPu9sF4ZrfYT96FyUR/s9haxOU5HLzwOZ27gGCVDR2VM/GQ2L0TTSYTATRZCbE x2quC/gSqvGIHwimCPpkxTd2t+4lyc2ca65YvgJYms6nomjJLmKCymipu+8rOgP77bzc fQuzUXHKa60ASl5yNzBGSWsIy+FJHMWC2Yj8oOyfHerlUlpFr9oeopRC5gWe796nJ0Zi tVBA== X-Gm-Message-State: AFqh2kq56Tc1CbNsWGWBkAReHnKHM2Q+DBw6bOxcZr3s0UjF+OGT9pMg AAZ7rYep0fD+sVLkG3jTDXgpRvJL3UGVi0b/ X-Google-Smtp-Source: AMrXdXue4571aidkiNSZgU3GJnAm6ssIl5Vm/3VAGWBWSHwRJxQCuxfwEu2/ilYQ+rpJ1+1QRO2McQ== X-Received: by 2002:a17:902:8343:b0:191:2b76:612c with SMTP id z3-20020a170902834300b001912b76612cmr2600746pln.62.1671476362679; Mon, 19 Dec 2022 10:59:22 -0800 (PST) Received: from localhost.localdomain ([198.13.51.166]) by smtp.gmail.com with ESMTPSA id i6-20020a170902c94600b00189847cd4acsm7480790pla.237.2022.12.19.10.59.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 19 Dec 2022 10:59:21 -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 , Matthew Wilcox , Kairui Song Subject: [PATCH v2 2/4] swap: avoid a redundant pte map if ra window is 1 Date: Tue, 20 Dec 2022 02:58:38 +0800 Message-Id: <20221219185840.25441-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20221219185840.25441-1-ryncsn@gmail.com> References: <20221219185840.25441-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 3C3DB180015 X-Rspamd-Server: rspam01 X-Stat-Signature: htycaabd9qww3hzkq7dmugoeqm7xmam7 X-HE-Tag: 1671476364-399590 X-HE-Meta: U2FsdGVkX18iha7DC8yxN+tZ3w3PCZtoqER/LENTR5emYuyJGiqlXUq/xgXcKjH3c2YPGcyr9KIDlM7lYnwctQXgqC2nF2965xSqzw8mPXBxSb6y6HIOHhlratH+F0BYu5Yuu1myrOSCqKmeBXe5IBE5GK3gBTQvut275lDO/EbMXiJ/DV8eKmaG2pA1zBY0E3FstMJXymuFzWn9Ln3BFdngUg83qxVZzPTfTZa9xEfJhCweO6v2js2VSVYgmyIHBMXoG1pRa1Jfx+PFl8dV7/RMhPNWy16oWUxMh3OcHlRXKT4BnOPRpSHecWUquErYJYEF2Dc3VGVCz9ok9CuBTnkeiwPubcSPGSGM5OP8aPBBA/8scsb7cZksPADDb3k3mHgatrBUyeU5wXhTCHxtC9GxEW1zDbZJAm/KA5cFGiajG+zevTPHDcfC2Bvdptk6v0RtDLqEZGd1J/mMlDcglRYfAoqO0BJ0bsrtrTypTdCofxpHR8yUXI9bfOC3pgkS9GUQJ50nAhu2zCKH8aCm1FcW1BJoCeALq7DjlJG8VyhE8rmuUbcVqs8x1LSMv1G6T506PsKk6mqCPQg6AmXlaBj7TtVyL3F18uO/3st+tVtFEzKT3OllA+uq6NzlD43LFPzDkOs+CJ6Ml+HrwYppbE5KOiFHzHs8ftoIxgy58di8fVhgP+UY6+UL/jQnrKfO2M0DrzUaqy9lj92LYjhddT8TU7yzk1OUSgtNZ+qH69RaMu1HZ6Athmv2ZFD+0GVNFxyJB/3SLxY/ckpWS2F+1O6PZpOuK0dz0cxvFrU5NBIqz5QfEyp4ykQ1lkCASZqNXO17SNICstDAF51WQPLsNsPhDJtRubVFefFDfkwzQrTslphfVZ5MgnznbToy+im/Q36S+xrCOJt2u13DAAdf6YxgcRDiusrH4rPoIV6xUKOVMA1b4M3mPCuFnIDBk7DJynVBcjdlLjb3I/ulIBE Efuxe8Pz Cw9wbFkcembH7SzD4FElQl9mAwges0yQPk4zd87PuTN+fbljJTipJYXRm9w/IEkNjvU8tYL0ZX5oJHaBSpU4DPmROGKmL/7Gp+/p3JW1wAz58vNmLnmMYZqDmjHKoaRdeQmVv5yeRuKXUnCzczHktWKykaImH0z0WJ+Bn5gpr/aLp9SuXazD6rZSkuPGI8yYP50O6bAZ/xDYrx31UuO3SwLqtoPIrUAksdFOUtBmy3KN+Shk9DAw0FvqZEasT92Ccqa1C5eEc89zJMSl98KCQP1s7jQ== 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 2927507b43d8..af8bc123b7c4 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -727,8 +727,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)); @@ -739,12 +737,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)