From patchwork Tue Sep 22 02:01:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rik van Riel X-Patchwork-Id: 11791339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85B8B112C for ; Tue, 22 Sep 2020 02:11:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4491523A7A for ; Tue, 22 Sep 2020 02:11:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4491523A7A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3650790001A; Mon, 21 Sep 2020 22:11:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 315AA900012; Mon, 21 Sep 2020 22:11:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2058590001A; Mon, 21 Sep 2020 22:11:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id 08051900012 for ; Mon, 21 Sep 2020 22:11:45 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C35DF181AEF09 for ; Tue, 22 Sep 2020 02:11:44 +0000 (UTC) X-FDA: 77289071328.14.wire94_3f03ca22714a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id A323918229818 for ; Tue, 22 Sep 2020 02:11:44 +0000 (UTC) X-Spam-Summary: 1,0,0,010f9a75b5168dae,d41d8cd98f00b204,riel@shelob.surriel.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1542:1711:1730:1747:1777:1792:2393:2559:2562:2898:3138:3139:3140:3141:3142:3354:3865:3866:3867:3870:4321:4605:5007:6261:7875:8957:10004:11026:11232:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12683:12895:13161:13229:13894:14096:14110:14181:14394:14721:21080:21627:21990:30003:30054:30070,0,RBL:96.67.55.147:@shelob.surriel.com:.lbl8.mailshell.net-64.201.201.201 62.8.0.100;04y8ykiajmf5da7wna4geqt861gh1opsh9rb4xr6hcffgw61xf6k6kaqnrzaszt.8hx5pbtxjhajskq1tmxfe3t5jsrybbztuuu5ej4ff5gpp9kw689crbr79hztzzk.k-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: wire94_3f03ca22714a X-Filterd-Recvd-Size: 3675 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 02:11:44 +0000 (UTC) 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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);