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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5199EC636CC for ; Tue, 7 Feb 2023 18:49:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FF07280001; Tue, 7 Feb 2023 13:49:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AF36900002; Tue, 7 Feb 2023 13:49:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87752280001; Tue, 7 Feb 2023 13:49:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 793AC900002 for ; Tue, 7 Feb 2023 13:49:37 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 114D4AB0CB for ; Tue, 7 Feb 2023 18:49:37 +0000 (UTC) X-FDA: 80441384394.08.4F0C3F4 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) by imf04.hostedemail.com (Postfix) with ESMTP id D412940008 for ; Tue, 7 Feb 2023 18:49:34 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b="U2nW/kDH"; dmarc=none; spf=pass (imf04.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.177 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675795775; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bBmufrIpKjI+8mvdDvPBth0aa6lZWSixeneHNMXKRKo=; b=bJYvSTZT7UD1uI+arFfIgZNaP6vnHCLBWvkiQYBK5NTp+qs/79iNFoXJXAonxz56KqaJ9y t3+usPX1e6ZCU5ONXds1S/dMDVjaMWg8yE02FiVHrJUb5ytWULx37iWyuUXjIoQaw+Xz7i D2fjxA5xVsPW8zxZZF5/53iF2QSqsa8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b="U2nW/kDH"; dmarc=none; spf=pass (imf04.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.177 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675795775; a=rsa-sha256; cv=none; b=7ijQ9tVFh1n/iHB2nzquPVNA8Kw9UkHU0SypUgf2B91QFs526NDVsdCrFqt8e7+j+4fytf JEYqEZWmrU7ZGB5W8L8p4ZEjDyYKrzGjd43leuXbdJToUyhGq//2mYnlj2wJ79nwpgg2Rg XQp2z2J26Fs/opNGZ9lcP671nvPmcoE= Received: by mail-il1-f177.google.com with SMTP id w2so2718590ilg.8 for ; Tue, 07 Feb 2023 10:49:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bBmufrIpKjI+8mvdDvPBth0aa6lZWSixeneHNMXKRKo=; b=U2nW/kDHyjhF94YUCuaOOTrEUZ/r/LxWEAN0Rkyku8k9pghGOiQC9GB5Ajw8KBX/Zd oiE/P6iV7zENMWEHN5BIjUB6ZsTzIhbgyIxepZ0UpYViCZqLx7nTUeTEv4+yWGkM7Uxy FCmdoZ1C8kOjcGnwCuHp4Rm0t6FnclnPwbkT48MES5BmtU/QyJBUp8YCGE6i41yU/fmJ TVAe0zTK6uovFg2incYacWOlDH1hWk3qcNViESwSJqe4NeWD0kmtKI/7m49bFoYweQKw yNLmEoHVxL14TV9B4uAIC/8CRwkOGdzB1OYtWm/af4w3YGJVONeCuE/4K9kKmzugKMmN sq+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bBmufrIpKjI+8mvdDvPBth0aa6lZWSixeneHNMXKRKo=; b=ocul6csDD5dLxVovq0/vs1n7aSBt+RoAlNmLgBc6hFPmiATDR3CFm7cWDLSybD3Rm2 I2fr8Ac8TSfQHn6eNItucrWa7AMH7eipdTWtjaPg8cpBFHZb78UY1tvuJkd9BEkIPko0 JiJWme4JmwOo7FiL/rPcxOwC0jGo0WUuF3PRWmTCZQGdomRTlxtiGTV7FZHx+IXIM0Qs R9o/PJ5el6TFYPfbbusVcFDIqjufUZiPjrVdxp0yRbJFpnbnwJEWxahIx4d5iBTPF5P0 n66Atwq9yf8vyPLxn0M1FMzbqn5dJ5ujTyIN4Yy0x9Y+B9NiDbgfcwwTutF020/BVZ0E AgEA== X-Gm-Message-State: AO0yUKVluKXtd7lKuP4mgiCHnCLeojc9ZRN1U8mZtp99C5F3aCT664E3 G+/Jam1Ji/OFjTI6IJNnCgFqXQ== X-Google-Smtp-Source: AK7set/tAwL3lb3yurbCeVjSHYgxs8++6eMI/PGkEJvuzZ9KDObbhzYc4+Q7jZiXFnMbLg+UqBjBKg== X-Received: by 2002:a05:6e02:1b88:b0:313:c5a4:9888 with SMTP id h8-20020a056e021b8800b00313c5a49888mr4759540ili.0.1675795773811; Tue, 07 Feb 2023 10:49:33 -0800 (PST) Received: from [192.168.1.94] ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id f20-20020a056638119400b003a60da2bf58sm4559086jas.39.2023.02.07.10.49.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Feb 2023 10:49:33 -0800 (PST) Message-ID: <88fcfd5a-cf73-f417-cea6-eed5094d71ed@kernel.dk> Date: Tue, 7 Feb 2023 11:49:32 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v12 00/10] iov_iter: Improve page extraction (pin or just list) Content-Language: en-US To: David Howells , Al Viro , Christoph Hellwig Cc: Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230207171305.3716974-1-dhowells@redhat.com> From: Jens Axboe In-Reply-To: <20230207171305.3716974-1-dhowells@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D412940008 X-Stat-Signature: 9ysw4471g5ree1swtp5b1ebu3y3anx6j X-HE-Tag: 1675795774-741155 X-HE-Meta: U2FsdGVkX1/g7/pPPwU216iWxtIaFSG0MMDS9tHGyi1iegfleB+H1P4OkvqegeP31eR1meLwbto3Keo7MMM9AICPbE/gOFYGtYEXxLvx0y/xGdpwsUWzyLwNZVkN3YhOZW6vTd38yDE9LOKQg9TNrL9zJVVUqbSKKtZ7YsBmGWC1Qztczz+JUrFbJMbTfTJCBtF6wOPbvaPBnHCgjv4Dy+RsorDxeHzPU3mno7sA6VQbecDAPc6d/P97oyPykfh+Pc8eGldbkjIKUn5/uVVZ09tmqbiiQoCunNSKVGAxHpaj46Y+MIKo+FYk4I9NucQrTS5VgCtTtYIpFqk4c06tAvvjyaq8xa6nt+yM1KorAhvlMpPGtcnvhcarb6uTZFtZkiwKT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ilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2/7/23 10:12 AM, David Howells wrote: > Hi Jens, Al, Christoph, > > Here are patches to provide support for extracting pages from an iov_iter > and to use this in the extraction functions in the block layer bio code. > > The patches make the following changes: > > (1) Change generic_file_splice_read() to load up an ITER_BVEC iterator > with sufficient pages and use that rather than using an ITER_PIPE. > This avoids a problem[2] when __iomap_dio_rw() calls iov_iter_revert() > to shorten an iterator when it races with truncation. The reversion > causes the pipe iterator to prematurely release the pages it was > retaining - despite the read still being in progress. This caused > memory corruption. > > (2) Remove ITER_PIPE and its paraphernalia as generic_file_splice_read() > was the only user. > > (3) Add a function, iov_iter_extract_pages() to replace > iov_iter_get_pages*() that gets refs, pins or just lists the pages as > appropriate to the iterator type. > > Add a function, iov_iter_extract_will_pin() that will indicate from > the iterator type how the cleanup is to be performed, returning true > if the pages will need unpinning, false otherwise. > > (4) Make the bio struct carry a pair of flags to indicate the cleanup > mode. BIO_NO_PAGE_REF is replaced with BIO_PAGE_REFFED (indicating > FOLL_GET was used) and BIO_PAGE_PINNED (indicating FOLL_PIN was used) > is added. > > BIO_PAGE_REFFED will go away, but at the moment fs/direct-io.c sets it > and this series does not fully address that file. > > (5) Add a function, bio_release_page(), to release a page appropriately to > the cleanup mode indicated by the BIO_PAGE_* flags. > > (6) Make the iter-to-bio code use iov_iter_extract_pages() to retain the > pages appropriately and clean them up later. > > (7) Fix bio_flagged() so that it doesn't prevent a gcc optimisation. I've updated the for-6.3/iov-extract branch and the for-next branch. This isn't done to bypass any review, just so we can get some more testing on this (and because the old one is known broken). -- Jens Axboe