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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 065CEC54EBC for ; Thu, 12 Jan 2023 10:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237094AbjALKf0 (ORCPT ); Thu, 12 Jan 2023 05:35:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236265AbjALKev (ORCPT ); Thu, 12 Jan 2023 05:34:51 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A19223C for ; Thu, 12 Jan 2023 02:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673519330; 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=G1PS7mB2JtEkDjLUk4xftZvEMD5IXSfO99hn6l84qLI=; b=Bp6ZlAJAps7yXAYR8ujyRczPMb9pVG8ZWO8LvlUBUYYhi+Wq+m7GOo923ViA0K3g9lte3q YSIcsB82kluE3z9LtyJsmfHO3a28/+zP0izquuenFGPtqSu0XFE5dZnP8qm/zhVWKp8xsr GE20Nx2cSMhJlP2LNMVU+2/8+KrSZro= 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-454-gBYO1yzCOQS1GiMIxPZReQ-1; Thu, 12 Jan 2023 05:28:44 -0500 X-MC-Unique: gBYO1yzCOQS1GiMIxPZReQ-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 6339B101A521; Thu, 12 Jan 2023 10:28:43 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id B298AC15BA0; Thu, 12 Jan 2023 10:28:41 +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: <167344725490.2425628.13771289553670112965.stgit@warthog.procyon.org.uk> <167344731521.2425628.5403113335062567245.stgit@warthog.procyon.org.uk> To: Christoph Hellwig Cc: dhowells@redhat.com, Al Viro , Jens Axboe , Jan Kara , Christoph Hellwig , Matthew Wilcox , Logan Gunthorpe , linux-block@vger.kernel.org, Jeff Layton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 8/9] 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: <15236.1673519321.1@warthog.procyon.org.uk> Date: Thu, 12 Jan 2023 10:28:41 +0000 Message-ID: <15237.1673519321@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christoph Hellwig wrote: > if (cleanup_mode & FOLL_GET) { > WARN_ON_ONCE(bio_test_flag(bio, BIO_PAGE_PINNED)); > bio_set_flag(bio, BIO_PAGE_REFFED); > } > if (cleanup_mode & FOLL_PIN) { > WARN_ON_ONCE(bio_test_flag(bio, BIO_PAGE_REFFED)); > bio_set_flag(bio, BIO_PAGE_PINNED); > } That won't necessarily work as you might get back cleanup_mode == 0, in which case both flags are cleared - and neither warning will trip on the next addition. I could change it so that rather than using a pair of flags, it uses a four-state variable (which can be stored in bi_flags): BIO_PAGE_DEFAULT, BIO_PAGE_REFFED, BIO_PAGE_PINNED, BIO_PAGE_NO_CLEANUP, say. Or I could add an extra flag to say that the setting is locked. Or we could just live with the scenario I outlined possibly happening. David