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 DB0A6C77B7A for ; Sat, 20 May 2023 08:41:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13A43900005; Sat, 20 May 2023 04:41:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 11DBA900003; Sat, 20 May 2023 04:41:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F41C6900005; Sat, 20 May 2023 04:41:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E5C78900003 for ; Sat, 20 May 2023 04:41:14 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 86130140B25 for ; Sat, 20 May 2023 08:41:14 +0000 (UTC) X-FDA: 80809988868.29.EE31DA6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 964AF4000D for ; Sat, 20 May 2023 08:41:11 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IqefbiZ5; spf=pass (imf01.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684572072; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZfsN9u3tZvTje8ugz3SqEzdJkX9NnPmdfbSTVEwM6F0=; b=LyDUUVFcLHRVuoc/N7zitthH3TLYTJFxFK72AuXX/aHvdIlQqSJA/eIApVJvqo8wjBWsJF 4KjVbv/eiRzMe9LOTN9OyW55BtQGGY4hZCDLmrrwTlcNefplGwSecSCeXX5iBUtABnJNET 9cKijkAE+KkNDo3uZro2ca+5lj5RLWw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IqefbiZ5; spf=pass (imf01.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684572072; a=rsa-sha256; cv=none; b=uABCwrY47rFpV4bLFrTxCy1efClcDX92Xq6koXrbyvfEg6Jy/1hWQD9sRu4hYAQBCZY4kX uMnIVeDuYqzaxvDn12d7ILUu2bZ4iCf6/jQMvhEWtLnxfkWTH3Wos2UzouahJaStQXfbMD B5sNNa7ApKIGd/ZA8JeuX6mDW6jqLu0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684572070; 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=IqefbiZ5jdi9CPpfOVgUp+QQWA3G9IqQCFnGdXnugOqnv83uJXUjWVFh3lY9yVZVpAffRv VHNHGcUUQxJQAAhDtb8TLqwjOvitsXosDJJfrkHbYj2BLJPVXpBGT0c0wLoigm+C9cGt66 2lpFiJR52kqBIdGebr9vbhFlgmik2Ms= 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-Rspamd-Queue-Id: 964AF4000D X-Rspam-User: X-Stat-Signature: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Fkq1UPEbcz0USCNGnW3W4KuwNmxhZepoBdR+TZef5pggnM3Ja22DYEzRT54fgMxW9EosjMuQueCG+EcvjV7e1FAHKcYH+hIDQ2SoAwVZATL1iNsDXXzGDe+vR4noXTmQ8WWThHekyk7Jbl+wUdMz4aoFh7YCDsfVmqY0uxp3lGrIgLzJWgW5Wgmlyup+208KxQr4tNUEps= 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: 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