Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp518249rwd; Sat, 20 May 2023 01:47:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5vWg0JcKDrXEwmvT7IZfDQtD+htBZUapEdVeC/SXUWOhG36IZXMzuUVUmTVVI9qarj42IH X-Received: by 2002:a17:90a:8682:b0:23b:3422:e78a with SMTP id p2-20020a17090a868200b0023b3422e78amr4397958pjn.6.1684572430480; Sat, 20 May 2023 01:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684572430; cv=none; d=google.com; s=arc-20160816; b=MwHhWL9TG3VfyO73IL8TET+KdpeHooCgASUhwKnEJgME1EQY/lERvIbxMnB1HmCiuH uQSKc6YhuhfvSa9idqf1pzKD0IemrzfvJ+Sr4ACvZkfsC9V7fkIWMRanAUfqR4L0rOm4 gqSKlLMISwZnw7BEoiOjxuUdRkMxuoDBa2p/ero/MRZxYrl4YBaJpEUH1tXGa/k8Gn8n 774Ju8k1/lpBwzN2TyHyqwoF35Pu1ZMbfKTVo4F+ljpWWJC238XO3t7CiQje08RDMQcG 98ECWwmbcUjT9HDJ8wI2fC6FP+LiOSrzsuZ8KRH7H/YmNFySooDbAV3MP59eJbQYcSMs Ny9w== 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=ZfsN9u3tZvTje8ugz3SqEzdJkX9NnPmdfbSTVEwM6F0=; b=nIFZJqwFj6PLa1b+Lg9VxeDVVIpE65Cd8F+OCa3bRhYz2kb9Na8VLsFNOEMZ2lqbcb TAbzAyWdpG9vlumsb1wSI8GEba9K3fol1d7e+1a/mMsVfeCMe8lduh6FLr3dLK3LWHYw ipwgCfG3lIa4tUsolblKtCuQhP5nI2l9G/bYqzYHz/a5C8CENyPldWZ7fLi7LajAyJTD qnbfhF37o/QXmWORCzlcrEj6hOEseTscP4XkWEZsItoKhaQDH9T7JS/pkVgihJqeW0M+ IWO/DOdjfdiCw+X5YcFAPbdGPChewCKPw5LqUCBE/gXPbZ+Jha+DTw94pGRTUSF4JBHy x/PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bdPXIxDP; 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 g1-20020a17090adb0100b0024dee3457b1si3250191pjv.49.2023.05.20.01.46.58; Sat, 20 May 2023 01:47:10 -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=@redhat.com header.s=mimecast20190719 header.b=bdPXIxDP; 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 S231201AbjETIly (ORCPT + 99 others); Sat, 20 May 2023 04:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbjETIlw (ORCPT ); Sat, 20 May 2023 04:41:52 -0400 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 584A0BD for ; Sat, 20 May 2023 01:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684572067; 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=ZfsN9u3tZvTje8ugz3SqEzdJkX9NnPmdfbSTVEwM6F0=; b=bdPXIxDPEL5m3cmpPtL2em96IjpApfrCdnXd9CX94wVE5GmCNJDqcP0pZ6c8SxTbEq3SGx I5ZEg5ytSpt9wy++aXMSi6PMnAY6QItsbgI2LzzpD89RNigW5jetJBJnc1Hrxpm+fIe9bx r6OVmQdrKCG3BuiieOr4V8ys3ktF5AM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-CYBqTh54MsOJt7lOdtj2Og-1; Sat, 20 May 2023 04:41:04 -0400 X-MC-Unique: CYBqTh54MsOJt7lOdtj2Og-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 180A7101A52C; Sat, 20 May 2023 08:41:03 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90E2DC53524; Sat, 20 May 2023 08:41:00 +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: References: <20230519074047.1739879-1-dhowells@redhat.com> <20230519074047.1739879-30-dhowells@redhat.com> To: Kent Overstreet Cc: dhowells@redhat.com, Jens Axboe , Al Viro , Christoph Hellwig , 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, Christoph Hellwig , John Hubbard Subject: Re: [PATCH v20 29/32] block: Replace BIO_NO_PAGE_REF with BIO_PAGE_REFFED with inverted logic MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2292307.1684572059.1@warthog.procyon.org.uk> Date: Sat, 20 May 2023 09:40:59 +0100 Message-ID: <2292308.1684572059@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Kent Overstreet wrote: > > Replace BIO_NO_PAGE_REF with a BIO_PAGE_REFFED flag that has the inverted > > meaning is only set when a page reference has been acquired that needs to > > be released by bio_release_pages(). > > What was the motivation for this patch? We need to move to using FOLL_PIN for buffers derived from direct I/O to avoid the fork vs async-DIO race. Further, we shouldn't be taking a ref or a pin on pages derived from internal kernel iterators such as KVEC or BVEC as the page refcount might not be a valid way to control the lifetime of the data/buffers in those pages (slab, for instance). Rather, for internal kernel I/O, we need to rely on the caller to hold onto the memory until we tell them we've finished. So we flip the polarity of the page-is-ref'd flag and then add a page-is-pinned flag. The intention is to ultimately drop the page-is-ref'd flag - but we still need to keep the page-is-pinned flag. This makes it easier to take a stepwise approach - and having both flags working the same way makes the logic easier to follow. See iov_iter_extract_pages() and iov_iter_extract_will_pin(). David