Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp729412rwd; Thu, 25 May 2023 03:08:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7JmQslXr1PWBriQpkz0ijjy9TK3yeUZuhlth3+YRWeq8u4oJiX6yvWqjzcLYc5ZYKt1MuX X-Received: by 2002:a05:6a20:a590:b0:ff:ed6b:4c9e with SMTP id bc16-20020a056a20a59000b000ffed6b4c9emr23110908pzb.36.1685009309897; Thu, 25 May 2023 03:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685009309; cv=none; d=google.com; s=arc-20160816; b=VKwHyZatIm0CLN6tBKDTCKbakU/yfa68IS7xhJsq/e6q/lr7NL4DJ16Wib0/ulvca4 aMp5TNdFoki9vVcwhXrmzsJoZJJlHZYgPVjNjwTZQLfMV22a/xoinzkxNPR/RB1v7v0E 45LLM0tINYIfr3te/ABq1wb7UE2wpgJ0/4QRIRB2u0hQNbUWKeDjaorjnJJnuR1KGnxS 0HrgTouTuvEQ8soc07bzQG9gUoozgJXnZNNuXIE/7AiCXHjSl49ouhLnthD3bneMp086 iWCquSvvPSaoLYIBza31PueDVlloqYHfI2JyGhCBKGETsOqVMFB8pJgbAdk4+6iJWqae 8i7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nTS/g9fJs1n3cdqbVQhwwN534SXRQ6PP71rBH26gs+o=; b=O/HM767dXSWWZYkmyfR29z7B9b4/NMCyFXN5RTjTgBijslcS259Jc8hZJ41xP5TODu SFrh0dYd7BvzTSw+TdViwB+6yzjjtujRJC1n1gmLunPfK08zocnYD5zQSvHKOCMoWWq5 8YQkx6XwPsGwTx5F21ACLMNeVkAZIZlgDWyvQLI/wcoVf9XbWQ8UsM8oRr6PfA25uZgh nIqP4znXNWQzUBxMB4oQthbrORM7cpN209bfirZyd56mcWE42nvzsW6rSP9ponHEgOHu q+Dlyr1yoEw9U2xGy8yGgz5XBk5svNHRJ7NDYPAPdWSlyG0/Qfi68hL2MtoanXMJgl0s LF7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=p6e1VERz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k123-20020a628481000000b0064d675fc97csi1177391pfd.27.2023.05.25.03.08.16; Thu, 25 May 2023 03:08:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=p6e1VERz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240617AbjEYJwX (ORCPT + 99 others); Thu, 25 May 2023 05:52:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240596AbjEYJwV (ORCPT ); Thu, 25 May 2023 05:52:21 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7204F12E; Thu, 25 May 2023 02:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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=nTS/g9fJs1n3cdqbVQhwwN534SXRQ6PP71rBH26gs+o=; b=p6e1VERz8010nQ39lyNEHKlZBJ u9uCZI7CPHvLK/QvHgpdsWDLzUhplfc6m6cEzj55zPcPok5rXriocAueZ1L7Ki/vq26U2hpg5MZsm 1yfwE4fnYycZ5TFY4ZKPWVnReI263wRCmC4HazkrJ0eux7gIHW/BqfQmLKEN3i+9iCWObA//GMWYP dCXg2ypvVErRh3xsgKvmYz4gsBD7MxC0PSkssl7fofWrUTvacF23jY8czbQSQYguj0z6jHHWEfCTO OxCsTp8QjVVMEcONNlV88MyIBTwC+QiOz3MHJU7cNVzxST4eLSM0aeP+cJeKSPlOHdZ4uQgr72pKp 1+4+U46Q==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q27dX-00GC8e-19; Thu, 25 May 2023 09:51:59 +0000 Date: Thu, 25 May 2023 02:51:59 -0700 From: Christoph Hellwig To: David Howells Cc: Christoph Hellwig , Jens Axboe , Al Viro , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , 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: Re: Extending page pinning into fs/direct-io.c Message-ID: References: <20230522205744.2825689-1-dhowells@redhat.com> <3068545.1684872971@warthog.procyon.org.uk> <3215177.1684918030@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3215177.1684918030@warthog.procyon.org.uk> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 24, 2023 at 09:47:10AM +0100, David Howells wrote: > True - but I was thinking of just treating the zero_page specially and never > hold a pin or a ref on it. It can be checked by address, e.g.: > > static inline void bio_release_page(struct bio *bio, struct page *page) > { > if (page == ZERO_PAGE(0)) > return; > if (bio_flagged(bio, BIO_PAGE_PINNED)) > unpin_user_page(page); > else if (bio_flagged(bio, BIO_PAGE_REFFED)) > put_page(page); > } That does sound good as well to me. > I was looking at this: > > static inline void dio_bio_submit(struct dio *dio, struct dio_submit *sdio) > { > ... > if (dio->is_async && dio_op == REQ_OP_READ && dio->should_dirty) > bio_set_pages_dirty(bio); > ... > } > > but looking again, the lock is taken briefly and the dirty bit is set - which > is reasonable. However, should we be doing it before starting the I/O? It is done before starting the I/O - the submit_bio is just below this.