From patchwork Thu Sep 10 14:48:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11769207 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 B40B6618 for ; Thu, 10 Sep 2020 20:56:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85BEE21D7E for ; Thu, 10 Sep 2020 20:56:45 +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="gWXdSveh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727775AbgIJUzC (ORCPT ); Thu, 10 Sep 2020 16:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731197AbgIJOtk (ORCPT ); Thu, 10 Sep 2020 10:49:40 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 633F1C0617AA; Thu, 10 Sep 2020 07:48:57 -0700 (PDT) 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=Src/OqkjxQSdZ62Mh67bzsrUw3RijigPMK2ar4X7t2Y=; b=gWXdSvehOkowhVdpfH7VZCocig yCLRi9ERfOF5FIu+vkFBTfgi/Ds264r21uA1sYnnKRHsbndIIzWlUwXOIc/d8xLROAG94FPRv9U/l YdVHVVIZBRvmivfYFh2OvsuHWAr/CvB+AYT+L4hrsBozPgF0AywPU/qNWYgRO+fkYne9yR8LQKyCT p+OEsoCxOCl8CkYKajH+aXBU5tpDhlTvTSgfLixGvTKRUIArPswCyijGZpGPCOx2VPs6BW+dOmeV3 jvB9tBZEnbfTmR8tXDOf9OBOPPhG2cIyBweSYO8w7sKGMPb24r1j2auUllYxH/o4jBG8JpoEFkcHa 2eQjefKQ==; Received: from [2001:4bb8:184:af1:3ecc:ac5b:136f:434a] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGNsX-0006xO-0l; Thu, 10 Sep 2020 14:48:49 +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 09/12] mm: use SWP_SYNCHRONOUS_IO more intelligently Date: Thu, 10 Sep 2020 16:48:29 +0200 Message-Id: <20200910144833.742260-10-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200910144833.742260-1-hch@lst.de> References: <20200910144833.742260-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 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.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: Jan Kara --- 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;