From patchwork Tue Sep 15 15:18:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 1364478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=uTIKeduQ; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=A0MI27dF; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BrSBX5pvHz9sT6 for ; Wed, 16 Sep 2020 01:41:24 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HgDrPKY6Pq8kgxgapD48VXGZRACx6tSvmO0mpXgFMPI=; b=uTIKeduQspfjfsD4RpAxdKCz3 GxvktyQs1tIzlGoZGnXktqjs5sYsJPVjHg7+NYyqNi8jHeebmwDYKKpR1BxYyqyHexMC2WiEqZy5s WOEevW5K8zAxTOTnuYZ2uuIFDFitBFh2BZRkayM8yX2A1EZMlAOUg7s7ThE875PR7Xs4eIGTCPkhw LQTALaA653jByxctLNvUFwgXyFiGIdmj/RWKlqZSv7ZIGdPuJWwqo7A8OpEMLLkiL/N3XSdWjnZJF f/2uVF+DRdFvIDOM6OgJL0VHPkKgWQt36PbsrscX1hZ3eOr2iaLVLxp9bPP+7s4RSGfmLW348n3s1 EDepLYP+Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kID4F-0004Mk-AG; Tue, 15 Sep 2020 15:40:27 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kID4C-0004MX-VY for linux-mtd@merlin.infradead.org; Tue, 15 Sep 2020 15:40:25 +0000 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=SWfBAr2q6gY7hJAHtmrHC8T+mpjUJ4BFFjN6mCzC9F4=; b=A0MI27dFFVL58VRTuqRZjJkdvl /pWyLqarwFYX864vR2apZk4SlJ9tAxGrIij8FrG2fZNDBzRjKeqDAFOfFNGLu4n+MKLsCUiHsJ77U /BMNeCLZuYiACYtSRVaFiRaELz9NViTaahsbjL4ANqRo8+1u75m/9o+y4AuwWfZlltmqEwXbZsySI hBCumlwC/wSJHTIpZUkHxFEOvJzpR4p//olvUakeuKY8fxeySVQCi50YCcI2VxuvPBMws7w3KwcV5 IbBn24FDXk6RGoFqB3yedHDKLNb/jV7y+zF/5ig3VmtOQMTP7eqpPxZpkoOW4GcF8HPqlZjvyk2f4 1egTQdwQ==; Received: from 089144214092.atnat0023.highway.a1.net ([89.144.214.92] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kID4B-0002OA-Cc; Tue, 15 Sep 2020 15:40:23 +0000 From: Christoph Hellwig To: Jens Axboe Subject: [PATCH 09/12] mm: use SWP_SYNCHRONOUS_IO more intelligently Date: Tue, 15 Sep 2020 17:18:26 +0200 Message-Id: <20200915151829.1767176-10-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915151829.1767176-1-hch@lst.de> References: <20200915151829.1767176-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-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-raid@vger.kernel.org, Hans de Goede , Minchan Kim , Johannes Thumshirn , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Song Liu , dm-devel@redhat.com, linux-mtd@lists.infradead.org, Richard Weinberger , linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, drbd-dev@lists.linbit.com Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 e485a6e8a6cddb..b199b87e0aa92b 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;