Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2111787rwb; Thu, 8 Dec 2022 20:33:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf6lehIQxhqjNjFRHFFNtoEgXGznSAFEBA62qHZCfRFn7og2O8UeVijVA3SRmJfbZfBtEHTj X-Received: by 2002:a05:6402:3224:b0:46c:d2a3:76b3 with SMTP id g36-20020a056402322400b0046cd2a376b3mr5187217eda.14.1670560422363; Thu, 08 Dec 2022 20:33:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670560422; cv=none; d=google.com; s=arc-20160816; b=vrVxMhb3kQaC9NKl84Yd1Qo8srx9xCVsuf78JCLro+gxIUfBeFFDamkyV+hDDrrkfu XdD0zFxfi4c0TB/YAzN13CC8FIC1hlgO0GqDlOdc+rqSu+Ku4xfb+hQ+G1d7eW8nYRK7 DdodWqCGkxM2xjWxoEcT5jts5YgHm8r7sapqPGGjn7FG8cXozawdq4/zhAgYEgtbgl+U QLJP8SRxm1GsFXCP3s3GgKy1kjsJu9P4mPIPCZY59bO7zCCwIkZbemMoIBTKfNBw0+Tm HGrpM9G4qHLTrf28UbHKlxau4Zyc3KlViS20lGqAkyu7kgF5KBB0rS0suU9+d64mOGkF gEyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=veECtkFvxIrUADZfGGQ1OuIIjfU63XPQ4MXS4lDwq3g=; b=OY6fjVxE3XN+JAEB65RyyOPna2IC5iGtk/KlnJmpAvc7H1jqgfC4OE4prPAd5WRCc2 IdbA3IZb7d7J4XYtGHunCslKTn2dnWNNMWzfqOQynxWbw2tjeePybGSM5MwpPKTgrXVz sPRDPOBg4KkglajqO8ivSACNiZWnOTt+/d2EU+oW63gU5TDN6vqvAY6vU/7cQr3vUnsZ Ed6t43ykALJ/49Nj5ilQNO31NAyy+dleGFZzztJ8ZvtvVFzH/xO/k8sHMBgVUJMsWMOg iNNMynloZ8vtZUItttr6V+KqqZQ6EfG1wzvFWgmswo7qspMHNbZPHvTvDpknji6T2qRZ u+7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="RKAq/mrF"; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p9-20020aa7d309000000b00469d35e2f13si423522edq.522.2022.12.08.20.33.24; Thu, 08 Dec 2022 20:33:42 -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=@intel.com header.s=Intel header.b="RKAq/mrF"; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229838AbiLIDQg (ORCPT + 73 others); Thu, 8 Dec 2022 22:16:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbiLIDQd (ORCPT ); Thu, 8 Dec 2022 22:16:33 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B02278E5B0 for ; Thu, 8 Dec 2022 19:16:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670555792; x=1702091792; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=+qzWuJhdLNj38CLulD3dFODyqhkADDx3rnnROBnGehQ=; b=RKAq/mrF1/pXu60LEoGOl2edCKpJHzHXxWIGt/cFzxasio72hpC+ogGL 3NNRH3sqlCzn+iYLb1BI/YKHjUJuV/uDNrO4JUM74HijM4zC5wJHko4KG BCDqkR4KDO0dbl7TPCOZ4lYqrfjz6sW/RjFRWxH+rfPATgDN+oqNO3e7I sHbJF84+m3WpuzmTbET7H3d4cVYiL4nYNtuHDwYfftMSLMj0z2L9SA4fI 3nxCLegW88S22b40C9RE6GcsC8zUfsYRpKDbxpZggtwGEVzk429aSL0Fe n8h0CMc+N+Hyo/8G2wPxBi3tRdNWoRNK95QGyrya19vz6JwZLMgKjs/Nq g==; X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="315005978" X-IronPort-AV: E=Sophos;i="5.96,228,1665471600"; d="scan'208";a="315005978" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 19:16:32 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="649416107" X-IronPort-AV: E=Sophos;i="5.96,228,1665471600"; d="scan'208";a="649416107" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 19:16:30 -0800 From: "Huang, Ying" To: Kairui Song Cc: linux-mm@kvack.org, Kairui Song , linux-kernel@vger.kernel.org, Andrew Morton , Miaohe Lin , David Hildenbrand , Hugh Dickins Subject: Re: [PATCH 2/5] swap: avoid a redundant pte map if ra window is 1 References: <20221208180209.50845-1-ryncsn@gmail.com> <20221208180209.50845-3-ryncsn@gmail.com> Date: Fri, 09 Dec 2022 11:15:41 +0800 In-Reply-To: <20221208180209.50845-3-ryncsn@gmail.com> (Kairui Song's message of "Fri, 9 Dec 2022 02:02:06 +0800") Message-ID: <87v8mlqnc2.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE 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 Kairui Song writes: > 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(-) Good to reduce the line of code. Thanks! Reviewed-by: "Huang, Ying" > 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)