From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03DFAC4320A for ; Thu, 12 Aug 2021 15:42:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D29E60FBF for ; Thu, 12 Aug 2021 15:42:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9D29E60FBF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id F022F8D0002; Thu, 12 Aug 2021 11:42:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB2618D0001; Thu, 12 Aug 2021 11:42:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA1328D0002; Thu, 12 Aug 2021 11:42:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id BE1358D0001 for ; Thu, 12 Aug 2021 11:42:05 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 46900243B6 for ; Thu, 12 Aug 2021 15:42:05 +0000 (UTC) X-FDA: 78466844610.35.F359089 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id B53BC9006A22 for ; Thu, 12 Aug 2021 15:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=rRRInWTXt88iInQrUMslw6/dDmJVHBRbB2u0EULf5Hg=; b=Yw+Dh/oM1oO5pq6qyI7FNo3t6Q gx5MdI+3AKoBLfLsXvV7hSsdpymjB+4rVyaoCBxbggUtS1dXiiIkxKYLtAzpxHz8ozQU6o15snaU3 g/YPrBRrNCj6lMSLi+nqago1irdlmXakhi+FcbIoG42INTBaWENjp2LHhYlaIr7Egfk91IAfElT/m 5KgDUhy2mv3CYLXkudaTbyYYA0sCBDGG6jWyRU3proN98MFmItee6ftH3yAeDixXfgHs7lNhanbBc 7KCjjcQwDIXgN+JXH8G+s0MayKXCVykM0HIw3mPAtULVEOvTqJaOSTNd4ke1enrddQTaShxQ/SagD EvIXleCQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mECo0-00EikE-Vo; Thu, 12 Aug 2021 15:39:47 +0000 Date: Thu, 12 Aug 2021 16:39:40 +0100 From: Matthew Wilcox To: David Howells Cc: Christoph Hellwig , trond.myklebust@primarydata.com, darrick.wong@oracle.com, jlayton@kernel.org, sfrench@samba.org, torvalds@linux-foundation.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mm: Make swap_readpage() for SWP_FS_OPS use ->direct_IO() not ->readpage() Message-ID: References: <20210812122104.GB18532@lst.de> <162876946134.3068428.15475611190876694695.stgit@warthog.procyon.org.uk> <162876947840.3068428.12591293664586646085.stgit@warthog.procyon.org.uk> <3085432.1628773025@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3085432.1628773025@warthog.procyon.org.uk> X-Rspamd-Queue-Id: B53BC9006A22 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="Yw+Dh/oM"; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam01 X-Stat-Signature: ixz4ooeks68k18ow96ccce7c8j6yaefs X-HE-Tag: 1628782924-30732 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: On Thu, Aug 12, 2021 at 01:57:05PM +0100, David Howells wrote: > Christoph Hellwig wrote: > > > On Thu, Aug 12, 2021 at 12:57:58PM +0100, David Howells wrote: > > > Make swap_readpage(), when accessing a swap file (SWP_FS_OPS) use > > > the ->direct_IO() method on the filesystem rather then ->readpage(). > > > > ->direct_IO is just a helper for ->read_iter and ->write_iter, so please > > don't call it directly. It actually is slowly on its way out, with at > > at least all of the iomap implementations not using it, as well as various > > other file systems. > > [Note that __swap_writepage() uses ->direct_IO().] > > Calling ->write_iter is probably a bad idea here. Imagine that it goes > through, say, generic_file_write_iter(), then __generic_file_write_iter() and > then generic_file_direct_write(). It adds a number of delays into the system, > including: > > - Taking the inode lock > - Removing file privs > - Cranking mtime, ctime, file version > - Doing mnt_want_write > - Setting the inode dirty > - Waiting on pages in the range that are being written > - Walking over the pagecache to invalidate the range > - Redoing the invalidation (can't be skipped since page 0 is pinned) > > that we might want to skip as they'll end up being done for every page swapped > out. I agree with David; we want something lower-level for swap to call into. I'd suggest aops->swap_rw and an implementation might well look something like: static ssize_t ext4_swap_rw(struct kiocb *iocb, struct iov_iter *iter) { return iomap_dio_rw(iocb, iter, &ext4_iomap_ops, NULL, 0); }