Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3615750pxk; Mon, 21 Sep 2020 20:08:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOp3iTGgaxMx06pNSUtxgcAed706IL0sWZc3Yyoej89C3A36/fCQ44OQCzhKme1e3gw5sw X-Received: by 2002:a17:906:6682:: with SMTP id z2mr2757078ejo.434.1600744128760; Mon, 21 Sep 2020 20:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600744128; cv=none; d=google.com; s=arc-20160816; b=dXIK4yd4E1j3d0Ofqn/YhHbRc8YTMxt3ntcq2f0rM3yPeG696t3fWs8gyDaeJoupMD y2PMlow0AkPqthZGRuz5oSUrr6ZalAeMRQVr0CPRbWBHzYlcho0bHtlXDGLgSDQKf65O 6USmR5+tC4hZ0NB4v115r1daljoh0bWvq7EwM5SO3n3dX1lqdztnHKpoD1qCF7licLgl L+kyi91n7TDftgs+vK2o6FWo/fqKfVVl9mTEuw44VS/1VWz84EhOizasvRtU4+4P+S2N SpSD45TDIr1pPINOsvZuaj1lzk6lIbsVEM+qsaZ82gbTCIEI4RaV6ZHNW5UA4cZPiGux 4AiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jjwyccVd4kktKvy+rguSAGqq5OZOlw3eLfbLlzsvx5E=; b=hXaG1wExXUoGkXszV3U+x9N1Xp8ERYdBY4gJKrcifM9oyC2ounPEZBrnli1oTItJQL FSaaAldARPlvrLaocLJKOPm+LHE5L8yTSzKpIuxQezLUuDwplOLZQyocQPfw8ge5KZgc Dnnw9CmTrYrqC01LFmVigCLwvM86fbE7tXk2Xf10Alr+26lmYutMXmr6Pv/5DLiVWHlO KBjNWD6H3b33oQz7T17Pe694PPnHkkfuCDhwmm6H2YA90bUbk3Z9OZse2O2a8bgjQiGR 0fUQuY7Bt9+1qq2i5o6O5DLjnMKUlnd1aQJLGedX/0GqljSCTEKnTBnDN4sCJTbDxAzb mQtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g20si11491701ejz.452.2020.09.21.20.08.24; Mon, 21 Sep 2020 20:08:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729386AbgIVCCE (ORCPT + 99 others); Mon, 21 Sep 2020 22:02:04 -0400 Received: from shelob.surriel.com ([96.67.55.147]:45652 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729307AbgIVCCD (ORCPT ); Mon, 21 Sep 2020 22:02:03 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kKXcv-0003Cm-DM; Mon, 21 Sep 2020 22:01:53 -0400 From: Rik van Riel To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, kernel-team@fb.com, niketa@fb.com, akpm@linux-foundation.org, sjenning@redhat.com, ddstreet@ieee.org, konrad.wilk@oracle.com, hannes@cmpxchg.org, Rik van Riel Subject: [PATCH 1/2] mm,swap: extract swap single page readahead into its own function Date: Mon, 21 Sep 2020 22:01:47 -0400 Message-Id: <20200922020148.3261797-2-riel@surriel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200922020148.3261797-1-riel@surriel.com> References: <20200922020148.3261797-1-riel@surriel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: riel@shelob.surriel.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Split swap single page readahead into its own function, to make the next patch easier to read. No functional changes. Signed-off-by: Rik van Riel --- mm/swap_state.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index c16eebb81d8b..aacb9ba53f63 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -594,6 +594,28 @@ static unsigned long swapin_nr_pages(unsigned long offset) return pages; } +static struct page *swap_cluster_read_one(swp_entry_t entry, + unsigned long offset, gfp_t gfp_mask, + struct vm_area_struct *vma, unsigned long addr, bool readahead) +{ + bool page_allocated; + struct page *page; + + page =__read_swap_cache_async(swp_entry(swp_type(entry), offset), + gfp_mask, vma, addr, &page_allocated); + if (!page) + return NULL; + if (page_allocated) { + swap_readpage(page, false); + if (readahead) { + SetPageReadahead(page); + count_vm_event(SWAP_RA); + } + } + put_page(page); + return page; +} + /** * swap_cluster_readahead - swap in pages in hope we need them soon * @entry: swap entry of this memory @@ -615,14 +637,13 @@ static unsigned long swapin_nr_pages(unsigned long offset) struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask, struct vm_fault *vmf) { - struct page *page; unsigned long entry_offset = swp_offset(entry); unsigned long offset = entry_offset; unsigned long start_offset, end_offset; unsigned long mask; struct swap_info_struct *si = swp_swap_info(entry); struct blk_plug plug; - bool do_poll = true, page_allocated; + bool do_poll = true; struct vm_area_struct *vma = vmf->vma; unsigned long addr = vmf->address; @@ -649,19 +670,8 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask, blk_start_plug(&plug); for (offset = start_offset; offset <= end_offset ; offset++) { /* Ok, do the async read-ahead now */ - page = __read_swap_cache_async( - swp_entry(swp_type(entry), offset), - gfp_mask, vma, addr, &page_allocated); - if (!page) - continue; - if (page_allocated) { - swap_readpage(page, false); - if (offset != entry_offset) { - SetPageReadahead(page); - count_vm_event(SWAP_RA); - } - } - put_page(page); + swap_cluster_read_one(entry, offset, gfp_mask, vma, addr, + offset != entry_offset); } blk_finish_plug(&plug); -- 2.25.4