Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1423057rwb; Thu, 8 Dec 2022 10:24:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Re4U3dpFGJFudqXAIwd0WXy/50EMUonYt6fECNsH7uDel9ubtg3cwH81wYi5cAynF4lTo X-Received: by 2002:aa7:d601:0:b0:46c:7da6:7320 with SMTP id c1-20020aa7d601000000b0046c7da67320mr18271541edr.227.1670523872132; Thu, 08 Dec 2022 10:24:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670523872; cv=none; d=google.com; s=arc-20160816; b=pBcPj62xmSa1HWKVSywQUg2YH/qefj1GtUADMcfBvUrPZpxFoQuMmu8Wp3xJxoqdLb FkW4uqSwvi0vxpZGsuo6pHAIozsX2YR85ygnzjQu+lS/IXR/Dk1wLTy0j/7lJOL+jdtA WwEx26EtBL3bKdMI9q7r/3JxeijbY78hi+xcaHbUGnK4avPwuRKr9MrRPWw5/Gk+i2d9 zW9ShNmYAWtIhWLjkvoUgz2RNxzQNpJOldMW5II/UXTdglEEVJWPR7ubn++3ZTjewyEr IMxrFYjrnWz7RSXJsx1fbmJsyFyJQb9VpgOLxNTiN4QSuQDru8BRRfqQgDhtpN28VklL 1uow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=riLhoP57eVPqwj4BrvS8Vazxssa2eImOkYsWKI1T0t8=; b=vdoHRh8IA1UsPyLWc0bC9OFHf2ZWmpRIm1gnOjyq3G8l5UkkEqFLa5vfblFYHBMn1X r3oxPrlegqyBSS68iwVnvrxRePgNtjKC9QQGzxfxLqXphIFzvXbATWYmEbgRRH3Ms+4Y 81sbt5n3XWwZ77gm+P78EDhGIcFBB3KqLpyVjDdZluNB3XeonRLCIq3+zIozcBpUbL2U Ma1+wGPCPi1hqgzuB/2QGs0+Cdek7ZCEWKtrfC571WDMBvPA2Txes3e9zlTkhL7H5czn gMc3YTDotLFJV98Zpj2CDkkt5e0xgA2X22wY8yznJZFYoLHFKEUI37TXwDQnZi96jpxz bLcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iViaYugs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xi10-20020a170906daca00b007c1292a824asi2792282ejb.731.2022.12.08.10.24.14; Thu, 08 Dec 2022 10:24:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iViaYugs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbiLHSD1 (ORCPT + 72 others); Thu, 8 Dec 2022 13:03:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbiLHSDX (ORCPT ); Thu, 8 Dec 2022 13:03:23 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04EDB5BD60 for ; Thu, 8 Dec 2022 10:03:21 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so5459620pje.5 for ; Thu, 08 Dec 2022 10:03:21 -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=pZ5OcCK2yfOwutj/74jiOeQGySPltPyOqYae79+vY8acZPkJckWCwOy0Rk59bTPWTj TkHQTtZsShnQNRk+DBMJJGg1DMvf+EByNGveXo/RbAW6uCkJaotmWQUIQqba5OiTjGlG dhGciw9QFdJI14tkoRNdmROiealM2Jg4818niQXVUtdxKieoVnQP+eXGIyuVAnH5Byl+ S/DZoIiarcUBSeqr8UnojihQcz3p8ilZr01Uw/NalWowd2mXb7a7ZBAapDeCTbksGFQo JjSeLy5NKzkzs/fwrg00AvM4ZF1ycuZRwzFxglvuX6H+T9QtwALeytvGHDcFODRysYtA fqsg== X-Gm-Message-State: ANoB5pk8VJG+qq9uyx/y2e1rq/AGGLiO7HVaJbW3P1KOfAscVK5UWQUv 602ll6c1fdu1viR9492O4iU= 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kairui Song Avoid a redundant pte map/unmap when swap readahead window is 1. Signed-off-by: Kairui Song --- 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) -- 2.35.2