Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2976819rwj; Mon, 19 Dec 2022 11:11:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5A9vn8cUc/BFMkMBY+bvmVxtSS9k589YcZ63fiESMLrjiI7VVg/4hudYpOpz1B0yCiMCp6 X-Received: by 2002:a05:6a21:c019:b0:af:8128:757 with SMTP id bm25-20020a056a21c01900b000af81280757mr27855707pzc.61.1671477089370; Mon, 19 Dec 2022 11:11:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671477089; cv=none; d=google.com; s=arc-20160816; b=Inr6U4aQLbGNOpqTalLu6bDl0l4/r4LayZ6ERBCgWwyAIv6YJSLO2An8KGBw0b5+j0 jbIMmCtpSxiD0g23rnabwrInJywi0fJE4UvKy+hy5tSW6qiIQDjpWg6F/j1GDv0HMpre aYXebD8kqqaIFvZOG5esDBVT5OYFgn3S9RAgY6DDgAnfjc9fa7Q8DEw2fiAa7DPk/sR2 ZHfmJgC3YrdQNU98XV6tIGvNMi6ixuUNhXTgHDugjjDhrthjrdIG1CYgr5TJUiVVe8hw b0500zMILUExdVKrShIWgeboHo8AuY2mAUQkA7NApWpN0hokA0S/KawgHQWNDnfMg9Nv R9ow== 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=rNW8A16mCA3HvLKh5wBxi0WsnpxyoQsg0W035rUDdlU=; b=kqfwUdnw0ot2LGH9LuDjYYhjxSPQ5SdA4gW+fOzyTHDtZp6wxtFJ2rlD/kDY9fI7ol YZEvsMlKqM90jJlSqW4z/qHFyhFiHSwhdE6a2wSpm5J54g9vWWgG/F25u+zBpY/epbmL 23qlX8V7uTOqEzppN9P8IQQa3auvE46Y4HQPZu5f3EF2NPhYHxO3jy3M/MgqbdqmWe1x LUb68BA3TZH/RFBE+TubiE7/95wztMMdAbI9TMR6eRAO3IyVPDTTmo4O2u6s2E40VWhm OtZ8gcq5SgQSaJ0pBJ4Uy+cOff9+PnrigSazMyLUb3cZddZXrjXuGjLTk0CtN6ILf/QC UT1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="SjsPir/G"; 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 f19-20020a631013000000b0046fc9e82c99si12027485pgl.206.2022.12.19.11.11.20; Mon, 19 Dec 2022 11:11:29 -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="SjsPir/G"; 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 S232226AbiLSTAc (ORCPT + 71 others); Mon, 19 Dec 2022 14:00:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232590AbiLSTAB (ORCPT ); Mon, 19 Dec 2022 14:00:01 -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 21D8114D17 for ; Mon, 19 Dec 2022 10:59:23 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id js9so10055637pjb.2 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=ZwDubtLYKdepH8XPwhlbNpbugkBUQRsNdmuYNz6PzxV4Pb383+fvqMhBcr1kVdBDP0 j3gTm6RpjXeYGAJjNhtwbzpp/5qWKk9vlsQn0WHED1Il6P40yFpIs16QCoYTp7HeoybV pmRf9CrKIXCqfpWt3Smbaf8HFDrX/cYYN9lwt11x5KBg6gBtNBGbbUc7Sn/Oq6ig4U/R J1tcDRa8x8wQd9fffyGrFnLnq+Q/cCx0L60j5A3kzvGVqb6iI8kVPNisbtxwn2cj64eF MuCT4c8wU1FXAVGDZ1+1NEME/JfaIToT8OmKX+SmZUCRV1zCbEcCnKIVHpwE7DvNEo2g qDSw== X-Gm-Message-State: AFqh2kooQeGpYtjSbgg4CHbI0gndepYQi+RcEDZqoQGsFBbx4Ql1PWoc I4OBupa6uyZAKkZSYS8EJSY= 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 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 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) -- 2.35.2