From patchwork Thu May 25 22:39:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13255747 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 C9DA5C7EE29 for ; Thu, 25 May 2023 22:40:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46711900003; Thu, 25 May 2023 18:40:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 416DD900002; Thu, 25 May 2023 18:40:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30588900003; Thu, 25 May 2023 18:40:08 -0400 (EDT) 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 1E1E9900002 for ; Thu, 25 May 2023 18:40:08 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E29551408A8 for ; Thu, 25 May 2023 22:40:07 +0000 (UTC) X-FDA: 80830246854.16.2C9CE53 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id EEC44A0004 for ; Thu, 25 May 2023 22:40:05 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dfsqT4QS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685054406; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=XfXqmZRZyewS7hbeld3Fb741MiT0i4I4BJ+K3KWmVSM=; b=BRQY6DlQDNteZ4YQks5TZhwcDrjgAiGBnRqtIqoOXlHpgOpi2/F+Sia/v3W02P38pBEM73 Lji95wh0r0wz6JOcZqM69pwSCKL8LJcBgUvceVPDNbzBKgkd09HXy9EGUzw+CgOO3M0ZbX DzQ85ez2ld0I1ikeSswIPI5NZZgzXCE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dfsqT4QS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685054406; a=rsa-sha256; cv=none; b=S30hrqcjzoVfpxSjVhZtBvTMkCyMWzOiDszzd60DHyKkZ4+sVXTwodqfTfYd0dWVtlRAUW 3+4IyZhQxJ/P4L/KiWEmMSr7TyrF/JbH+X2AvbigmSy2KmMyoUZHYTY6ChGa2abnRX7Han IBYnzGctrbMN0WIfpDoIb8QBvqEaA2E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685054405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XfXqmZRZyewS7hbeld3Fb741MiT0i4I4BJ+K3KWmVSM=; b=dfsqT4QSuec5c0yMGCxz5SCVRzl2fXGuySUhsoPy+Ro9G9jG9E42/IaX9BQst+ATFYwI7x tfAEIFPlbDCumwtcrfKaUZYVKRstsJiLeCID2LcAMaFmLol80yYvkOSltdFU8Y1eVdvbTU gvWCWtNFTkT27tssOFJ9e16+36FeQ0k= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-632-uSF_FvTSNk6_plfteQwiVw-1; Thu, 25 May 2023 18:39:59 -0400 X-MC-Unique: uSF_FvTSNk6_plfteQwiVw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A406D29AA39B; Thu, 25 May 2023 22:39:58 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC8D7C154D1; Thu, 25 May 2023 22:39:55 +0000 (UTC) From: David Howells To: Christoph Hellwig , David Hildenbrand Cc: David Howells , Jens Axboe , Al Viro , Matthew Wilcox , Jan Kara , Jeff Layton , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 0/3] block: Make old dio use iov_iter_extract_pages() and page pinning Date: Thu, 25 May 2023 23:39:50 +0100 Message-Id: <20230525223953.225496-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EEC44A0004 X-Stat-Signature: 6idsbde4taoxkezs58ubhfeo9dqzhu5a X-HE-Tag: 1685054405-535223 X-HE-Meta: U2FsdGVkX1/uD0DAw853B5VAVYlE/7K8gH3cj66VwGrQBTfAq1WXa0WBTVX7ReCajfUlFfIOSIftEQ95HSMQG2+I5g2MSyGEDognatLiP8VZyOHXU1YOi8D4xqUuekOba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aWUKd9yO3t+o50L3tl3PwB8+JipOwhatlgUe8+1AzMjk7V5h0KaeE1egzHmjoh6qH2ZfAVzL9M9TovDeXGgAl4nZYuaQP0leAbrw34rfu6v60HK0qqBTO9en4astvo8tAg== 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: Hi Christoph, David, Since Christoph asked nicely[1] ;-), here are three patches that go on top of the similar patches for bio structs now in the block tree that make the old block direct-IO code use iov_iter_extract_pages() and page pinning. There are three patches: (1) Make page pinning not add or remove a pin to/from a ZERO_PAGE, thereby allowing the dio code to insert zero pages in the middle of dealing with pinned pages. A pair of functions are provided to wrap the testing of a page or folio to see if it is a zero page. (2) Provide a function to allow an additional pin to be taken on a page we already have pinned (and do nothing for a zero page). (3) Switch direct-io.c over to using page pinning and to use iov_iter_extract_pages() so that pages from non-user-backed iterators aren't pinned. I've pushed the patches here also: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=iov-old-dio David Changes ======= ver #2) - Fix use of ZERO_PAGE(). - Add wrappers for testing if a page is a zero page. - Return the zero page obtained, not ZERO_PAGE(0) unconditionally. - Need to set BIO_PAGE_PINNED conditionally, and not BIO_PAGE_REFFED. Link: https://lore.kernel.org/r/ZGxfrOLZ4aN9/MvE@infradead.org/ [1] Link: https://lore.kernel.org/r/20230525155102.87353-1-dhowells@redhat.com/ # v1 David Howells (3): mm: Don't pin ZERO_PAGE in pin_user_pages() mm: Provide a function to get an additional pin on a page block: Use iov_iter_extract_pages() and page pinning in direct-io.c fs/direct-io.c | 72 ++++++++++++++++++++++++----------------- include/linux/mm.h | 1 + include/linux/pgtable.h | 10 ++++++ mm/gup.c | 54 ++++++++++++++++++++++++++++++- 4 files changed, 107 insertions(+), 30 deletions(-)