From patchwork Mon Dec 19 18:58:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 34696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2563183wrn; Mon, 19 Dec 2022 11:01:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXuGuds2qqPJ0BuxwRoo9tFktBEF1QsBAfglo3QjzxpOA8BRM5m1SBEKV3Ir6A4Mz0jWxqeL X-Received: by 2002:a17:907:80cd:b0:801:d0bc:f616 with SMTP id io13-20020a17090780cd00b00801d0bcf616mr11463725ejc.62.1671476505347; Mon, 19 Dec 2022 11:01:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671476505; cv=none; d=google.com; s=arc-20160816; b=T25w2mXnDZFXO9I2tI0ia+AzT9iN7g8Cud8ZL9tZJDoaxCkRFyxduqcnQySRZmqbxS 2lAuPBOZk6mlKXDTDKR7pZXB/RVL+ji7fFG2p5uh3y7AewRYryLebQFr3+SMEuXWjujR CduV7lC6Mj4VfZLnCFmBbrT3Fu4S/CPOErf355t1gB7XOvgyCe4cy/sFEKwp2LGe4sIG jVBMftxh/WOpyKUZJvYYRuPKg8FG9qtgeydvAz6qAToxQAx7LaetV4K/prum8/KbeC5x oWbuJJIOUIdcE8/ziiYgWqTiPuXLpsO8BA7Y82rweAjjVEWkbNkW2yfLmJVQuUF7uxY1 gbbQ== 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=XocXQJ8/KIfX9/nTT1Ghmvl4XAcC2jwtLySqVPgnO78=; b=bUailLbhg6MnIMOQoFdE008I24LeKF81g3snaj2DlIbibPkLohkAXSrkGjiGMNQjRh wrcSQWTqIytvneTzF1sxmzZmEKztv0PwFrCptkj3rrW5XMYvSnU5MuTMTQXF6fdiJD8U Xh6E84AIYpEYNosTgVVzzsHcMUqzGvzeOYb69ViOcZrhJt/89NnHACcD1iochF38tC4o nsBF/gsSb33YFtrECF8hQKGScgu7DyvlkmqPnobPaVwecM2LShgqgyPTRf1XA19P8aFq RiLnpWiqjJf4Dnzb8ubcAb3Ql729BGkN0KWcMSRfy+AY01MsevC8zN8QinqnauI20fvJ lo9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gTdt6BQe; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb22-20020a170907961600b007c4f78e610asi9242732ejc.442.2022.12.19.11.01.22; Mon, 19 Dec 2022 11:01:45 -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=gTdt6BQe; 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 S232171AbiLSTA2 (ORCPT + 99 others); Mon, 19 Dec 2022 14:00:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232488AbiLSTAB (ORCPT ); Mon, 19 Dec 2022 14:00:01 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB1A76585 for ; Mon, 19 Dec 2022 10:59:16 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id u5so10022956pjy.5 for ; Mon, 19 Dec 2022 10:59:16 -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=XocXQJ8/KIfX9/nTT1Ghmvl4XAcC2jwtLySqVPgnO78=; b=gTdt6BQeQx60iQ2xEpVkG9N2cVTn02TqELcNPrH2DPQHOHfHgBH7nbVVm4lJ0If6bi u8KJrL4+epaHOp5Ca5289ihVcOtRR8nvfWgIYq4R4IUNs45HAdcXI2X0EmzFMGuLVQRm rYddyOZNUm6HMseaqPywQxKdvhG2PrAOir8HWF8OlQ3muwxqLRO1dpkL6Eof7Lc5DHsW nExx/9uTYg/ylbOa4u5j4XAy35yUDRjgsu1L3drtgnxRxc5xbLN9wgJjbTR5fPIq5k7h kjMeYKpySfSdX4ZrmK7ECOULbiV6BH1SAgg3unw12ilu4j/ouOJRVoSSO7S4krtdRzZV sWaQ== 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=XocXQJ8/KIfX9/nTT1Ghmvl4XAcC2jwtLySqVPgnO78=; b=D3GxN6IM1VWdCuz4lGvkOldxbz8aa8quQfkJQzlS3wuTfIRPn5WxPm/4abSSBXDTDy n1MG6HfTy2hn99bXzPxR7q2gsInjtgW/A2aPqZZ+aoOUL0BhV8/8NKNwcFlQ4SvNzOgv 7Rz5DrDdQ667mMhLzb5U1gw6fVwL/r8naRKMlYi+Ari2CJsoBh09yZF2smcZT4nsflYX gyVEiylEk4/SlvLuC1sqL8zj+l2GA9STl75WwUB9zLEjqiHx/0m8yjvjGk1YlDg1Ir4J fHpCQIyb2E8MDsQb4Fj0tyY+Gesnr8lVmsHLsXi1oaUBq0On1p4ZJn1+ntVU060w+pFd 9WPQ== X-Gm-Message-State: ANoB5pmGsecc5B9HMYLbQp/rzY5pbzSxl+CjQCPyV8DAA4b+HNTkQB2G QgVejTy+Z3q/DPygWpo2hVI= X-Received: by 2002:a17:902:8209:b0:189:851d:644c with SMTP id x9-20020a170902820900b00189851d644cmr40913337pln.40.1671476356452; Mon, 19 Dec 2022 10:59:16 -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.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 19 Dec 2022 10:59:15 -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 1/4] swapfile: get rid of volatile and avoid redundant read Date: Tue, 20 Dec 2022 02:58:37 +0800 Message-Id: <20221219185840.25441-2-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-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752670148217687858?= X-GMAIL-MSGID: =?utf-8?q?1752670148217687858?= From: Kairui Song Convert a volatile variable to more readable READ_ONCE. And this actually avoids the code from reading the variable twice redundantly when it races. Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- mm/swapfile.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 908a529bca12..6d3f60bd383b 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1835,13 +1835,13 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, pte_t *pte; struct swap_info_struct *si; int ret = 0; - volatile unsigned char *swap_map; si = swap_info[type]; pte = pte_offset_map(pmd, addr); do { struct folio *folio; unsigned long offset; + unsigned char swp_count; if (!is_swap_pte(*pte)) continue; @@ -1852,7 +1852,6 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, offset = swp_offset(entry); pte_unmap(pte); - swap_map = &si->swap_map[offset]; folio = swap_cache_get_folio(entry, vma, addr); if (!folio) { struct page *page; @@ -1869,8 +1868,10 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, folio = page_folio(page); } if (!folio) { - if (*swap_map == 0 || *swap_map == SWAP_MAP_BAD) + swp_count = READ_ONCE(si->swap_map[offset]); + if (swp_count == 0 || swp_count == SWAP_MAP_BAD) goto try_next; + return -ENOMEM; } 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: 34697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2563249wrn; Mon, 19 Dec 2022 11:01:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4nali1+0NgYbKYZ+Xrg7qFkzPr8+R5byR/z1IoR+NXvDtiCex+xqfQfgrZdfSC1Kbk9zUs X-Received: by 2002:a05:6402:1ccc:b0:461:8a1a:271f with SMTP id ds12-20020a0564021ccc00b004618a1a271fmr40678235edb.11.1671476510774; Mon, 19 Dec 2022 11:01:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671476510; cv=none; d=google.com; s=arc-20160816; b=Z9M6rPkXH1QhTJH+Rzmrn1DWKzcRzEweBIhZ+pXSXi9ZSutyj8V5/0Dzk54MmyVuQV eyRG08NSQMDukSOqo6zYXC00c2wJ1UoYi26fnKkCWRuDJBJ4CrfWwb4cbPKpEmnKq9Bd gg78YuiGgxAVezxfc/L4gpgwraJJ4rBJ9A4dowNyr3CaH1NgDeIylu+xJkqEVpS5gRls Hg7jXaEYk3ldJRcD1i/5G+qzejjQnDERTMzJUNbca4ryK9R9y7LpZ6YPynpNk5q8yRtk X1tXV7EiKDh60NiT2UD4PVN7qIf9HEkXMmOD0dxyw40DFYOd3eiyWaepxOoor9uH8uFA juNQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dk21-20020a0564021d9500b0046f7741bd0esi8616234edb.598.2022.12.19.11.01.27; Mon, 19 Dec 2022 11:01:50 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752670153788714711?= X-GMAIL-MSGID: =?utf-8?q?1752670153788714711?= 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) From patchwork Mon Dec 19 18:58:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 34699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2563877wrn; Mon, 19 Dec 2022 11:02:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf79Hwn8RcJ8GJuBQqh/xRtvxRXv/CJAyOtRwpHXuxn6eHYBq3nopGu+YG6fQeScuBr08J4H X-Received: by 2002:a17:906:804b:b0:7c1:67ca:56f5 with SMTP id x11-20020a170906804b00b007c167ca56f5mr27001067ejw.15.1671476569171; Mon, 19 Dec 2022 11:02:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671476569; cv=none; d=google.com; s=arc-20160816; b=xL36iJQjT4YZb6Ge0eCUuNEPOWE65HJZna+pkYlz63xk4Ze1cWdKt+ASDVwZ8fYxnD b3JzYuuU4AXcfF32CEziyFjckz3AEwHKzL3gTY9Chz8ZXJneIQzcAzwG+O/k9cZFy/gD mIe3cgMkA0jAdgEZZDWEeBdzKg2VY63m3+YXijWFmzWSejft6hDe5+PHF65TB/MkuyA8 ly6eBqIej/1qEKraGQCe0Q4b8t7JQnkYhMmEK1eoFy2oWDhvsca1XG/5saN+P9d91mNP BgHB2LOCYt09Uq6Ogx3z8tjTeGVQXPrb0PED4Fx6sUcKoyiXHe+sRbT+I+ynsuaNgx2g 9F6Q== 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=e8B2I+4NRvgsSq6ExVIS5zUbrcMf1l4UJ5x1/qJc8cA=; b=zW6VBBxEUTleHkFqIMgFiCA/LlTij55fbEnHI9aK+P4EaG8AkJmGkpnT4QAuM9LFrU ZsMrDsyy/Sx8DmBpYvrEsVQH2HV84GUC7w4El4RWfg12GzauVopf1C9pOn3IHcC6bz91 XYRoWo+5+TE20OAr7sR2KfwiFV44ABTUTSRlpHdNzjuMhRLw8oS29dUtKQ5Ct1ic2V8N 3PISE5KC/t8AXYS2iktVEsgb5PNXAk6zzM38K1Bj3iYcxJQyi+ks3/1p45EZI4B1auHA 8Lq4xCJ40gmYN9ILF1VR3Z3J2CWEQNrnuDHtVx7tav2PlhMPYjWjLclas/DkEWJx4JhG qBrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eDZyM7UO; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v22-20020a17090690d600b007acf3aed468si8570490ejw.786.2022.12.19.11.02.26; Mon, 19 Dec 2022 11:02:49 -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=eDZyM7UO; 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 S231775AbiLSTAn (ORCPT + 99 others); Mon, 19 Dec 2022 14:00:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232725AbiLSTAC (ORCPT ); Mon, 19 Dec 2022 14:00:02 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 466DB25FA for ; Mon, 19 Dec 2022 10:59:29 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id v23so4802423pju.3 for ; Mon, 19 Dec 2022 10:59:29 -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=e8B2I+4NRvgsSq6ExVIS5zUbrcMf1l4UJ5x1/qJc8cA=; b=eDZyM7UOpN208tVAX+hBqxHyra/S+kQPzV2RhHjUpgkC9oo2h5Ktaz/fro6c2oe/PI AiE0zgUos7a8I423N7mG0KgJrZbDbZjAuWEzhLGcsc4EetSbBy1aMp8FeQIqHi1Hqxqn /mMWiYwsa4h1ySc2e1WYwy1U8XSH06HeDaI3chHznqgvFcCkUMVwJdUKuQPt2Pb1uiRc ZcO5tNFbF1z+vFDCInDRnW/UpVs4kNmOWUagDrXtr1sYk7b4I6IGW+5X49eK1ICfP6Yc 2Nt0p3JG5RSnqmvBmQNcIgP82uZ3RVr5b1D+Vl9i1cIFY/GPycw8aNT5PXlUOLbbE1in hFbQ== 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=e8B2I+4NRvgsSq6ExVIS5zUbrcMf1l4UJ5x1/qJc8cA=; b=Wk9xIU57GBjKJySnb8BqoiWIVD9vksdYkSwP4E3Y55ErakUugSTo1BTARpXCD3WWRt ZYLVwYnHIIEU9KxfUTEssKw79I0HVMsjaU82yoawPUaz5+En87oS0E6pL87aA0nDMW5Y LvD1FgMQDbQ9Sd3rrU0+XFgHN/keAisJhlvOAjBQPkLLVuUpm7ojpkZ6FAx7aXgYVeMJ fbBjb5y4Soi+P/sugrBNVvz/qO/4vnTAJGKf+G4z6TMUjdj9o8/vG7VXRugCQ4NfAwUz umoZliCZdUVntL7S7qg1qee15vDsrMP0vx6rBSCQZkmGiWqrcRtQuH59oJwREfG1u7li /ZQg== X-Gm-Message-State: ANoB5plG1PQdsWTgfoEhiNFy6D+8y7okP5jFBD19WsvEMc6roFNNxfQp s+dS0IiIsAAvednt++pSu7E= X-Received: by 2002:a17:903:2448:b0:189:f277:3830 with SMTP id l8-20020a170903244800b00189f2773830mr65253828pls.68.1671476368808; Mon, 19 Dec 2022 10:59:28 -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.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 19 Dec 2022 10:59:28 -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 3/4] swap: fold swap_ra_clamp_pfn into swap_ra_info Date: Tue, 20 Dec 2022 02:58:39 +0800 Message-Id: <20221219185840.25441-4-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-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752670215411718800?= X-GMAIL-MSGID: =?utf-8?q?1752670215411718800?= From: Kairui Song This make the code cleaner. This helper is made of only two line of self explanational code and not reused anywhere else. And this actually make the compiled object smaller by a bit. bloat-o-meter results on x86_64 of mm/swap_state.o: add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-35 (-35) Function old new delta swap_ra_info.constprop 512 477 -35 Total: Before=8388, After=8353, chg -0.42% Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- mm/swap_state.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index af8bc123b7c4..d8d171195a3a 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -693,28 +693,15 @@ void exit_swap_address_space(unsigned int type) swapper_spaces[type] = NULL; } -static inline void swap_ra_clamp_pfn(struct vm_area_struct *vma, - unsigned long faddr, - unsigned long lpfn, - unsigned long rpfn, - unsigned long *start, - unsigned long *end) -{ - *start = max3(lpfn, PFN_DOWN(vma->vm_start), - PFN_DOWN(faddr & PMD_MASK)); - *end = min3(rpfn, PFN_DOWN(vma->vm_end), - PFN_DOWN((faddr & PMD_MASK) + PMD_SIZE)); -} - static void swap_ra_info(struct vm_fault *vmf, - struct vma_swap_readahead *ra_info) + struct vma_swap_readahead *ra_info) { struct vm_area_struct *vma = vmf->vma; unsigned long ra_val; - unsigned long faddr, pfn, fpfn; + unsigned long faddr, pfn, fpfn, lpfn, rpfn; unsigned long start, end; pte_t *pte, *orig_pte; - unsigned int max_win, hits, prev_win, win, left; + unsigned int max_win, hits, prev_win, win; #ifndef CONFIG_64BIT pte_t *tpte; #endif @@ -742,16 +729,23 @@ static void swap_ra_info(struct vm_fault *vmf, /* 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) - swap_ra_clamp_pfn(vma, faddr, fpfn - win + 1, fpfn + 1, - &start, &end); - else { - left = (win - 1) / 2; - swap_ra_clamp_pfn(vma, faddr, fpfn - left, fpfn + win - left, - &start, &end); + if (fpfn == pfn + 1) { + lpfn = fpfn; + rpfn = fpfn + win; + } else if (pfn == fpfn + 1) { + lpfn = fpfn - win + 1; + rpfn = fpfn + 1; + } else { + unsigned int left = (win - 1) / 2; + + lpfn = fpfn - left; + rpfn = fpfn + win - left; } + start = max3(lpfn, PFN_DOWN(vma->vm_start), + PFN_DOWN(faddr & PMD_MASK)); + end = min3(rpfn, PFN_DOWN(vma->vm_end), + PFN_DOWN((faddr & PMD_MASK) + PMD_SIZE)); + ra_info->nr_pte = end - start; ra_info->offset = fpfn - start; pte -= ra_info->offset; From patchwork Mon Dec 19 18:58:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 34698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2563428wrn; Mon, 19 Dec 2022 11:02:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf4PUl5CdX973BKh/YVvY2HHKlYSdYm+GCdgIKzwv4c83drEsRJMd0ddMXOThPsSCDxhIAUv X-Received: by 2002:aa7:d48d:0:b0:46f:9fa5:ec14 with SMTP id b13-20020aa7d48d000000b0046f9fa5ec14mr32678747edr.35.1671476527700; Mon, 19 Dec 2022 11:02:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671476527; cv=none; d=google.com; s=arc-20160816; b=uWRQDOjdFHr8RSRwGs6TxQNBhaBgI58zBK/qgUPG7M/bih1NhpGTdsa/fCISsnCZtU uixC/ebdLpNXcVGtvRlEu1GfuUSY53arzeoO4U+RpntXn521pfHrmzZaeGsM5UXZTALn iO6xz8WkjKRIFYZQ5amWvttW4pxDWe6t6D99ht0I3lvJRpClHAE/6ymVNcD5aj8llatG oYgD9/9v0BV1A+4Sj9/OgQWdvB4eoKaM9nN2j1Vo13qiPYDD7DsTmcS9eD1BYuLLaB1g 9YQ3sE4RUtyVAZxQCwdzDxJdSVGm4KAs9mXDc+Bb9Wak4xW6LtQVw8xHy9LeGdbuaham penw== 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=YXfRuD0XfIija2Fu4Zh5yh7fZwHxF8sos3x+jWEicXs=; b=FF2dNaYWXFDhA8ktZp/ae+tadyKPmRvNJB2uUeL8kzQ3PKiz8pBNT4KIALb16R932h L1Y3dgmY4YnRZR7MUYAvpTk6I5xGpT643jUlPKIJ3TjAZvwXAkJiQGS3OqrueNkHp8mF MgT/IUKNgHni2Dk3oArfky2XHlchzlKOoYeT0hczpY3hW7Kasl+iAfHuwfFlmI//9jcp vuXrvDcgAMpLowbrqRrMg8PkAe/1QBcxViZ5lWlDebxWPrWB00Y8FYYa4rDOicQsKrKP Ov/dA0bLH5yofnKVDbvgP6Hat7lR5kBsCGZoiApZxvXbQDj6nC5tldqwepJpq0ppqyhe RI+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ODbh7AHI; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w10-20020a05640234ca00b0046b9715162csi10822323edc.21.2022.12.19.11.01.44; Mon, 19 Dec 2022 11:02:07 -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=ODbh7AHI; 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 S232444AbiLSTAh (ORCPT + 99 others); Mon, 19 Dec 2022 14:00:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232641AbiLSTAC (ORCPT ); Mon, 19 Dec 2022 14:00:02 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 746945F52 for ; Mon, 19 Dec 2022 10:59:35 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id x2so9897867plb.13 for ; Mon, 19 Dec 2022 10:59:35 -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=YXfRuD0XfIija2Fu4Zh5yh7fZwHxF8sos3x+jWEicXs=; b=ODbh7AHIyVlbnpVquiBqy8uEqHmm0QDGOQpUJwJz/fbNOgW3c0R/3yhPHQnjBkR/8r tnh0wWulPnf0Wj3awEx8ZPQPMrdKzjq7pV7sN2bCjtjdIQ/LcSbHqSmXvPDtBY+lnfir 7uJGSab0IG9Tx8xG9I7eas8PxE+cPMOmkqpBUFsyjEFMrvfNppiutfoNT7Z/HGBY3IkU alKfJUqOrRLJNjr4lKh3oxDJmmEo59BuF8lOFQlnhMTfyVNZzqAoC3bNX4b+p/FrF92G GWZVZNyfjzrwVX1w9NsKXgGt0W/3iz6L6SvXShaG9dlAeQjPraoMq6bGI2EO7PUtLLRc 4gDA== 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=YXfRuD0XfIija2Fu4Zh5yh7fZwHxF8sos3x+jWEicXs=; b=JfCe1NnS3nZWOk3LtUavjvpgQ4XJfosFIVAJjn0XMqC8pO3o+y3XlHjWLRPs4vjuun kEMYoVJFSQlgrFlIdQjWxJZOF9u8EKNUXJEAaK7ZzKb6D6YvEic3JCaMevZjyF6w2UhX XITgmcW2jbTl06aCxryjXlczu9Rd2NnVJeMho28nG5dHEOPmnVsHdpO0ScRz6kVFym+s qb+qU15AZkSN75eMEuIkDwFNe8mRTdCrbUPE2+b0wYh/vuRx29sLK+5WLERnEMkgy38i R2NvDKG9q+uTmmen9FsslgJwCVIyBlpV5lEn2FJ9fHOWSKszTb4bcnntqWhmRmDtbFHn tZhg== X-Gm-Message-State: AFqh2kpozQ4soJ2EK5Xa/7pYDz80dgEldOmk35b2tPvZkMLXUxqUoBT1 kZxgdIQoTMuUBzeX9fADNwM= X-Received: by 2002:a17:903:2154:b0:189:5a49:36c3 with SMTP id s20-20020a170903215400b001895a4936c3mr9539682ple.0.1671476374965; Mon, 19 Dec 2022 10:59:34 -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.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 19 Dec 2022 10:59:34 -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 4/4] swap: avoid holding swap reference in swap_cache_get_folio Date: Tue, 20 Dec 2022 02:58:40 +0800 Message-Id: <20221219185840.25441-5-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-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752670171876989077?= X-GMAIL-MSGID: =?utf-8?q?1752670171876989077?= From: Kairui Song All its callers either already hold a reference to, or lock the swap device while calling this function. There is only one exception in shmem_swapin_folio, just make this caller also hold a reference of the swap device, so this helper can be simplified and saves a few cycles. This also provides finer control of error handling in shmem_swapin_folio, on race (with swap off), it can just try again. For invalid swap entry, it can fail with a proper error code. Signed-off-by: Kairui Song --- mm/shmem.c | 11 +++++++++++ mm/swap_state.c | 8 ++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index c301487be5fb..5bdf7298d494 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1735,6 +1735,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); struct mm_struct *charge_mm = vma ? vma->vm_mm : NULL; + struct swap_info_struct *si; struct folio *folio = NULL; swp_entry_t swap; int error; @@ -1746,6 +1747,14 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, if (is_swapin_error_entry(swap)) return -EIO; + si = get_swap_device(swap); + if (!si) { + if (!shmem_confirm_swap(mapping, index, swap)) + return -EEXIST; + else + return -EINVAL; + } + /* Look it up and read it in.. */ folio = swap_cache_get_folio(swap, NULL, 0); if (!folio) { @@ -1806,6 +1815,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, delete_from_swap_cache(folio); folio_mark_dirty(folio); swap_free(swap); + put_swap_device(si); *foliop = folio; return 0; @@ -1819,6 +1829,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, folio_unlock(folio); folio_put(folio); } + put_swap_device(si); return error; } diff --git a/mm/swap_state.c b/mm/swap_state.c index d8d171195a3a..cb9aaa00951d 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -321,19 +321,15 @@ static inline bool swap_use_vma_readahead(void) * unlocked and with its refcount incremented - we rely on the kernel * lock getting page table operations atomic even if we drop the folio * lock before returning. + * + * Caller must lock the swap device or hold a reference to keep it valid. */ struct folio *swap_cache_get_folio(swp_entry_t entry, struct vm_area_struct *vma, unsigned long addr) { struct folio *folio; - struct swap_info_struct *si; - si = get_swap_device(entry); - if (!si) - return NULL; folio = filemap_get_folio(swap_address_space(entry), swp_offset(entry)); - put_swap_device(si); - if (folio) { bool vma_ra = swap_use_vma_readahead(); bool readahead;