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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 627BFC678D4 for ; Thu, 19 Jan 2023 00:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229570AbjASAP5 (ORCPT ); Wed, 18 Jan 2023 19:15:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbjASAP4 (ORCPT ); Wed, 18 Jan 2023 19:15:56 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03CEE5355F; Wed, 18 Jan 2023 16:15:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=B4JKTopwf+ah1JzO+o8lKdNMaw0A3fc5NXU+YNHQFBU=; b=RQ+fXNP99ggIbZtBXxqO4wTlTl 5hJSTT5zs8PR1I7e3wiqq5aC8sq0ARV3Xp7QGdkSLljcjiLdfklaz5WAs6eCPn49gFu0N9VQqFXDM oM05bDhNraV2tKr1XSZfPIazui4XxePY0SFJyITfItPI/5d9a59kxoo7qCK/suhZiDtunkbg3fHJC SOF8gaSn70LL+c97Xei2fWI03cNHSqga8PhaRRmTeyEEgPjx28qXC+1IlM9o5WaX9P4BcmAZ2F6+5 uOzCs5+WZFkgTV3bBj65ecJsnymTxkrNBXqvxxZxMbo8mcEB45B2nqHOLJFr5A93nMKWKbnKG/2uo UyOdFPkA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pIIam-002dwf-2G; Thu, 19 Jan 2023 00:15:44 +0000 Date: Thu, 19 Jan 2023 00:15:44 +0000 From: Al Viro To: Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jens Axboe , Jan Kara , Jeff Layton , Logan Gunthorpe , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , David Hildenbrand Subject: Re: [PATCH v6 03/34] iov_iter: Pass I/O direction into iov_iter_get_pages*() Message-ID: References: <167391047703.2311931.8115712773222260073.stgit@warthog.procyon.org.uk> <167391050409.2311931.7103784292954267373.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Wed, Jan 18, 2023 at 11:03:52PM +0000, Al Viro wrote: > On Mon, Jan 16, 2023 at 11:57:08PM -0800, Christoph Hellwig wrote: > > On Mon, Jan 16, 2023 at 11:08:24PM +0000, David Howells wrote: > > > Define FOLL_SOURCE_BUF and FOLL_DEST_BUF to indicate to get_user_pages*() > > > and iov_iter_get_pages*() how the buffer is intended to be used in an I/O > > > operation. Don't use READ and WRITE as a read I/O writes to memory and > > > vice versa - which causes confusion. > > > > > > The direction is checked against the iterator's data_source. > > > > Why can't we use the existing FOLL_WRITE? > > I'm really not fond of passing FOLL_... stuff into iov_iter > primitives. That space contains things like FOLL_PIN, which makes > no sense whatsoever for non-user-backed iterators; having the > callers pass it in makes them automatically dependent upon the > iov_iter flavour. Actually, looking at that thing... Currently we use it only for FOLL_PCI_P2PDMA. It alters behaviour of get_user_pages_fast(), but... it is completely ignored for ITER_BVEC or ITER_PIPE. So how the hell is it supposed to work? And ITER_BVEC *can* get there. blkdev_direct_IO() can get anything ->write_iter() can get, and io_uring will feed stuff to it. For that matter, ->read_iter() can lead to it as well, so generic_file_splice_read() can end up passing ITER_PIPE to that sucker. Could somebody give a braindump on that thing? It looks like we have pages that should not be DMA'd to/from unless driver takes some precautions and we want to make sure they won't be fed to drivers that don't take such. With checks done in a very odd place...