From patchwork Fri Jul 24 07:33:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11682257 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 2AEA9913 for ; Fri, 24 Jul 2020 07:34:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC0C020748 for ; Fri, 24 Jul 2020 07:34:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="H9chBPz8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC0C020748 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EF05C8D0025; Fri, 24 Jul 2020 03:33:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E51A68D0015; Fri, 24 Jul 2020 03:33:54 -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 D1C9E8D0025; Fri, 24 Jul 2020 03:33:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id B7D1F8D0015 for ; Fri, 24 Jul 2020 03:33:54 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 737628248047 for ; Fri, 24 Jul 2020 07:33:54 +0000 (UTC) X-FDA: 77072155188.19.lock43_181441526f45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 4E2A719776 for ; Fri, 24 Jul 2020 07:33:54 +0000 (UTC) X-Spam-Summary: 1,0,0,549fc09f9144be88,d41d8cd98f00b204,batv+134ff6dca6514692e18d+6179+infradead.org+hch@casper.srs.infradead.org,,RULES_HIT:41:355:379:541:800:960:966:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2199:2282:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3870:3871:3872:4321:4385:5007:6261:6653:6742:8660:10004:11026:11658:11914:12043:12160:12297:12438:12517:12519:12555:12895:12986:13069:13148:13161:13229:13230:13311:13357:13894:14096:14181:14384:14394:14721:14877:21080:21451:21627:21939:30054,0,RBL:90.155.50.34:@casper.srs.infradead.org:.lbl8.mailshell.net-64.201.201.201 62.8.15.100;04yfbwsi1kj83q8f5pa4zhzoa5765ypb8e5oajf7pw6tqwug65psmhkngs8z7xx.1fqe7hu4iyxtdqq9i47z7cpuq1bwpzs4qmzy56f1eymz7ou7g44wxu6c47g44jm.1-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:22,LUA_SUMMARY:none X-HE-Tag: lock43_181441526f45 X-Filterd-Recvd-Size: 3052 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Jul 2020 07:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=r6GVNDpJ00GIAfQlV8fGdOFlOngs4z7GOfztVZ4Wopg=; b=H9chBPz8VW3nrS8D/DH/sVlU/F qTE3kQJSkvGa29xlm3sAbuZDi82AskW2+7fjPxCRR3QbJ5YsVUt0Kj+m8PmTj83HPitCjtfgBFagh inT+4I3iJoCyCsHSTaIY4hPuGyKoQeZH4Fsyw/aa5PL9uBdYUAkMYnBp1k4e49Ul7v1pqEWn0UxsY XfablgUGRHFB9tB8aOnvgmsHzlderU2IxPDewd6CL5W8+uAmGEFj9vyCWe9GiPc0TNVvHCRXS+iuy Q2LFPaHq7JyKjuiOcqQ6wzIBvrK2CfwQ8vwUbz+CDh8leY7Wq2+X79x5o+SCC6EhkmwDHXTZLDR9y agi2Ht8Q==; Received: from [2001:4bb8:18c:2acc:8dfe:be3c:592c:efc5] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jysD6-0006Dz-GF; Fri, 24 Jul 2020 07:33:41 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Song Liu , Hans de Goede , Richard Weinberger , Minchan Kim , linux-mtd@lists.infradead.org, dm-devel@redhat.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, drbd-dev@lists.linbit.com, linux-raid@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org Subject: [PATCH 11/14] mm: use SWP_SYNCHRONOUS_IO more intelligently Date: Fri, 24 Jul 2020 09:33:10 +0200 Message-Id: <20200724073313.138789-12-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200724073313.138789-1-hch@lst.de> References: <20200724073313.138789-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Queue-Id: 4E2A719776 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: There is no point in trying to call bdev_read_page if SWP_SYNCHRONOUS_IO is not set, as the device won't support it. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- mm/page_io.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index ccda7679008851..7eef3c84766abc 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -403,15 +403,17 @@ int swap_readpage(struct page *page, bool synchronous) goto out; } - ret = bdev_read_page(sis->bdev, swap_page_sector(page), page); - if (!ret) { - if (trylock_page(page)) { - swap_slot_free_notify(page); - unlock_page(page); - } + if (sis->flags & SWP_SYNCHRONOUS_IO) { + ret = bdev_read_page(sis->bdev, swap_page_sector(page), page); + if (!ret) { + if (trylock_page(page)) { + swap_slot_free_notify(page); + unlock_page(page); + } - count_vm_event(PSWPIN); - goto out; + count_vm_event(PSWPIN); + goto out; + } } ret = 0;