Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp399019ybg; Sun, 26 Jul 2020 08:07:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo5vqkDYUCSVcQL8Wn1KVib4AYDiz/r3fS6zx055cts6kbQp0E6/7Jx4XYxCih497izDDP X-Received: by 2002:a05:6402:1c10:: with SMTP id ck16mr17812688edb.72.1595776053808; Sun, 26 Jul 2020 08:07:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595776053; cv=none; d=google.com; s=arc-20160816; b=YIRV9GhBka6ZVe9xxHDczXkIYuTtHYO01TjQt2wIVg3zZVHDareGBiIpaYOPg9+ZSy LSrEyhGK+/8RAiog7hG4UqQ9/0SbGxe+o9dEZdGw+SOWBEh0aKL3vh+IlcMbsNRqP2+6 5DcXIY0bF7Wa+puutZXZ27loeR40U9iPzjN1g3YrOd17aPF0lUqhSIzv79ZDIVO7ezat UI0jo8CXH/JF/+oApMI19UZJMgnBqPeQtJszNOwJpUVPBAIY9xLa/R8LA+61WGCmdRXS XpVEwvKfChw6C7vG6OwK2Ola+iIAdhVBBuAYyZJgN6vZlV/KuJlyliaE3qHPSHV00GtZ ltyw== 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 :dkim-signature; bh=r6GVNDpJ00GIAfQlV8fGdOFlOngs4z7GOfztVZ4Wopg=; b=iP/yUyKEZZ/Mnij4Co0jNDG3EiajNtbSpWaQZXvWyy6W3uDGf0TfHHRLW/5kNrOsBV CfSzo5EW2hJ0nqV2tN4zSQmFFNQH/lch2tNCVwuYNGeGjj4qVaFMIwUsJ2+pXp081ob3 78L3tufaq+Z/dbeD9VMgcuAgpjgL5LiDHHGUklM5DOqO4mKvsQksqV1G8zXFlI8IkSpC m7IMYNYXaSjEJTRjBTt/7Aiv9Yv3CeE2gl3mMrxY3bTA5lkrcjDuoY0GTfGUSQVAWzMV LEVSEHhZmjdqn/GRjQHLN1kZioguwMbYDX3W4hKhCGsFVrja65GbGxxnFxdq7yy47QTm e2eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=BMbowpfs; 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 g88si4143678edd.117.2020.07.26.08.07.12; Sun, 26 Jul 2020 08:07:33 -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; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=BMbowpfs; 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 S1727769AbgGZPEa (ORCPT + 99 others); Sun, 26 Jul 2020 11:04:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727038AbgGZPEC (ORCPT ); Sun, 26 Jul 2020 11:04:02 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92831C0619D2; Sun, 26 Jul 2020 08:04:02 -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=r6GVNDpJ00GIAfQlV8fGdOFlOngs4z7GOfztVZ4Wopg=; b=BMbowpfsbZEhpuMJ8DYPQ7Qin5 AQuz9qHcP4FRJQj2XTlZO4ZJZx1UC+VJvW+Ph/39TKP9n8Is8IGlvVsOTzfXXgANJdguMqd+hGm5Z M+6y+HiO58GP+VgVYJN11mhXPVXUFPXLPtg+vqYwR0Nt+DxfuFk83F7EoiDDyfkwScfRwUfnQUSdN m3Mu2ERK2RvQl9TqCDSVmRz6jSPUp7884WN9UfeF94qr8Z4g73m+CpUECQm//TVDG4AS/BOCsUuiJ U3+PYA/qQFsx+yMFY83SOHqYESyyEvZ2qTRk2fIf1WglhphPGqsbwP9/96Ys182lD//JWKo5tJFLb dq1KpQzg==; Received: from [2001:4bb8:18c:2acc:2375:88ff:9f84:118d] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jziBt-0005hx-76; Sun, 26 Jul 2020 15:03:53 +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: Sun, 26 Jul 2020 17:03:30 +0200 Message-Id: <20200726150333.305527-12-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200726150333.305527-1-hch@lst.de> References: <20200726150333.305527-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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; -- 2.27.0