Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6871324rwl; Mon, 9 Jan 2023 14:20:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXsDcwxYEV+sgZ0LhIHyuAYqfYeH09GXdoMw16FXFJFagP7A+6pMhMdN/box/RHq8+5+4Xwd X-Received: by 2002:a17:906:2a10:b0:854:956:1438 with SMTP id j16-20020a1709062a1000b0085409561438mr1163180eje.25.1673302841477; Mon, 09 Jan 2023 14:20:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673302841; cv=none; d=google.com; s=arc-20160816; b=wVff/mEjHURAEdLcLhUzUoC+t16iFf0+ZLuonXNxH0TG1/y+dBRRzNUi09MmMXTLyz X2VL/mX82+37iZk4hO8y6XbLvbF369/viwFIE7kxE+p/Xb8rdoF5Yqccx2d9C9SEgI7J qBnUymdAd7wTLT7zmxDNMgry7HH9zn9To702+PkrXi7YygZlu9WO1vFg94nP4BUpz6ct Zx/Rzd5FQqog2yX1Nz79ms9y5bpTt0IKz+xePDpFDVdRovP5YLI2RLDa1Uccgap3BqG1 NTeRDG8MZjhVukVeuLGVbu0nqB0q2DPDE/HwMSgQN0Sqwq7Rxs+tA8rsoAt9NSkKMtt2 B2yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=a63DA35gJAAxc0zkeF1e3iqtqNPsmNmAAW3yG6Igeec=; b=Y48i4uoBe9mzk/uk8dFb61p9oEOC0zZpERNyHLEMJyXGg2o88M+QNe+vxnsqz2NVzb 93+GXhQKsgBWnplqTKK4wW6KpZ9CXLCmIVwz/wF3hFkBneNhO/KBsilb07/ZfWhs1JdK VmSixYQyhNF/86YLNWuTbjm+xR3IMBLVd9tAUyitdwsc3t5nXJklB/6NpgbM9e6U1Dbl d6MxbR2w35F0iVEfnQICRRH1j95uxPmyAUmSlQM6FWkDF+aXIbD+1SJjYprRnRID5/wi ClNf+A6V/EAen/Qd066b8HgE+CTwDMTGv0/3xsUxI1OITkkbxAw12hXV0apDyf2enqGv dVOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=F0LGdYgN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wy10-20020a170906fe0a00b007c17f750b75si10381572ejb.796.2023.01.09.14.20.28; Mon, 09 Jan 2023 14:20:41 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=F0LGdYgN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238175AbjAIVkf (ORCPT + 54 others); Mon, 9 Jan 2023 16:40:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238223AbjAIVj6 (ORCPT ); Mon, 9 Jan 2023 16:39:58 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EB2E164AA for ; Mon, 9 Jan 2023 13:37:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673300261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=a63DA35gJAAxc0zkeF1e3iqtqNPsmNmAAW3yG6Igeec=; b=F0LGdYgNyxRCsiwT8jbt3E1xtOhfWCfqQMOZ1Jzwn6wf9jwylteeU/Hw5buy6LgxIdqctc i0ucIZntpO9l51jAecFeSd7BlsRFnco4szwFBEr368T/woRjkEnADdn/thnisPsAeScR24 BM0ZI9xTFG3bfsKy/MzHBT568ygd15w= 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-1-FYzDasRJMNu5P2dWnJSLYw-1; Mon, 09 Jan 2023 16:37:38 -0500 X-MC-Unique: FYzDasRJMNu5P2dWnJSLYw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7CDAC29AA3B4; Mon, 9 Jan 2023 21:37:37 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BEEF40C2064; Mon, 9 Jan 2023 21:37:36 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20230109173513.htfqbkrtqm52pnye@quack3> References: <20230109173513.htfqbkrtqm52pnye@quack3> <167305160937.1521586.133299343565358971.stgit@warthog.procyon.org.uk> <167305166150.1521586.10220949115402059720.stgit@warthog.procyon.org.uk> To: Jan Kara Cc: dhowells@redhat.com, Al Viro , Jens Axboe , Christoph Hellwig , Matthew Wilcox , Logan Gunthorpe , Christoph Hellwig , Jeff Layton , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 7/7] iov_iter, block: Make bio structs pin pages rather than ref'ing if appropriate MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2008443.1673300255.1@warthog.procyon.org.uk> Date: Mon, 09 Jan 2023 21:37:35 +0000 Message-ID: <2008444.1673300255@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Jan Kara wrote: > So currently we already have BIO_NO_PAGE_REF flag and what you do in this > patch partially duplicates that. So either I'd drop that flag or instead of > bi_cleanup_mode variable (which honestly looks a bit wasteful given how we > microoptimize struct bio) just add another BIO_ flag... I'm fine with translating the FOLL_* flags to the BIO_* flags. I could add a BIO_PAGE_PINNED and translate: FOLL_GET => 0 FOLL_PIN => BIO_PAGE_PINNED 0 => BIO_NO_PAGE_REF It would seem that BIO_NO_PAGE_REF can't be set for BIO_PAGE_PINNED because BIO_NO_PAGE_REF governs whether bio_release_pages() calls __bio_release_pages() - which would be necessary. However, bio_release_page() can do one or the other on the basis of BIO_PAGE_PINNED being specified. So in my patch I would end up with: static void bio_release_page(struct bio *bio, struct page *page) { if (bio->bi_flags & BIO_NO_PAGE_REF) ; else if (bio->bi_flags & BIO_PAGE_PINNED) unpin_user_page(page); else put_page(page); } (This is called from four places, so it has to handle BIO_NO_PAGE_REF). It might make sense flip the logic of BIO_NO_PAGE_REF so that we have, say: FOLL_GET => BIO_PAGE_REFFED FOLL_PIN => BIO_PAGE_PINNED 0 => 0 Set BIO_PAGE_REFFED by default and clear it in bio_iov_bvec_set(). Note that one reason I was thinking of saving the returned FOLL_* flags is that I don't know if, at some point, the VM will acquire yet more different cleanup modes - or even if a page could at some point be both ref'd *and* pinned. Also, I could change the interface to return something other than FOLL_* - it just seems that they're appropriate given the underlying VM interface. David