Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1656186imn; Sun, 31 Jul 2022 16:28:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1smYsbba0c6kMkNDyLKmkNHyw2V1w9W5r8c12JxvBC8480LbVTN8kDtQpJ4PCpV0cYi2NHY X-Received: by 2002:a05:6402:3785:b0:435:5d0e:2a2e with SMTP id et5-20020a056402378500b004355d0e2a2emr13725430edb.307.1659310111787; Sun, 31 Jul 2022 16:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659310111; cv=none; d=google.com; s=arc-20160816; b=Sxwab6rxc4qVqQsHswZwNcIgalNIOiTBjUq+5O15yo7m/nxuuD+rURT4Zx2cUzwGoJ H1aa06eS0vgkA3hyIOOXz0J9Si8vBbuOv0jaUF6KBQianQd5QkCedJDg8rW2USDhXptJ XjTvvJB2/wzFReGlvUj2c31RxDMXg9ITegyqRDjtzer3f5Bevp0rJQlbxTmv5abccmPG COqqqymUEH3jq0gg3urI/H1pX+rL4QO8JHsWTT5hFgbk2V8H5HupiTLzo/css1fMrZT2 9aRolWuAYIA0YNGxCeOww07EZfrJz0a/D1zth/IOJ23GN8K+Fvv2jvz6ucdFAIeuCZd6 5OUA== 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=RI8A0xK5TJuBK1GyEsXxlodNADhnfabE70lKyHFKpiE=; b=mTAh0j3HhzH29XJ0dwtpIGwjf3R6CMhbCPlB1Fxl2N/Yv5ggcLmmCDgQAR5VpEwwxk J6o8osIFTdPy6uKPsCzK63m5x/WPGdqbNzduvX667lBtJSRHDfW2C2NfoB2JLm+EFL7l 63kzUE0pN3Z25jYidzWGPd+1sWWfvZOQgoDUisyXnHpIz9+8khevRI1rOiYHFGT2Zu5/ 5HPVA/ujoklddtNMEKjtw3LSLhrB3avRJYZjJrr1+fOMnKWvBbf8dbJKSP3QpFJKVLp/ LH6qWhAyI5B+vjIdq+W2qu2ZRvTpxK8fL146kHZ/eaIPjJTCtLysu9MIVhqvhG02cLwr jjvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ofmSXa53; 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 d17-20020a056402001100b0043bf53c97a3si7576595edu.39.2022.07.31.16.28.07; Sun, 31 Jul 2022 16:28:31 -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=casper.20170209 header.b=ofmSXa53; 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 S238609AbiGaWst (ORCPT + 99 others); Sun, 31 Jul 2022 18:48:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238581AbiGaWsr (ORCPT ); Sun, 31 Jul 2022 18:48:47 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A37BDEC4; Sun, 31 Jul 2022 15:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=RI8A0xK5TJuBK1GyEsXxlodNADhnfabE70lKyHFKpiE=; b=ofmSXa53JAMaNO/0HX8mkIc/qR S/MHwLTW6BVlg8mhfYTkrzddljWJhtYgzYtebeXrvUy/yyTxYZNbjROGgfCvXe2v0J496W4UVy+L2 nogBbZB5TBWXApI3HWLTsmlDn6cBkRtYdRa/Wo2jDwe5UN37JxYMG1z8UCXnHYHWxuG7UgeemsBKh l/nXfMW/SjsLQ9dI8AyK2NMIsmSjtO2bAs1/uDGEOyEsj87bq9+cU4SDdA/w/dOH381zBJ8hZrDUU q47cSGNPC1EBQepMAzuh7L4j4ArJhenUUXSms6lBgSTwX+wNPYqNi/r/wBbVF40pAvKBo/9wHP+Is 7DjrVcKA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oIHjc-006cww-Gr; Sun, 31 Jul 2022 22:48:32 +0000 Date: Sun, 31 Jul 2022 23:48:32 +0100 From: Matthew Wilcox To: "Paul E. McKenney" Cc: Linus Torvalds , Mikulas Patocka , Will Deacon , Ard Biesheuvel , Alexander Viro , Alan Stern , Andrea Parri , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Linux Kernel Mailing List , linux-arch , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2] make buffer_locked provide an acquire semantics Message-ID: References: <20220731173011.GX2860372@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220731173011.GX2860372@paulmck-ThinkPad-P17-Gen-1> 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 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 Sun, Jul 31, 2022 at 10:30:11AM -0700, Paul E. McKenney wrote: > That said, I confess that I am having a hard time finding the > buffer_locked() definition. So if buffer_locked() uses normal C-language > accesses to sample the BH_Lock bit of the ->b_state field, then yes, > there could be a problem. The compiler would then be free to reorder > calls to buffer_locked() because it could then assume that no other > thread was touching that ->b_state field. You're having a hard time finding it because it's constructed with the C preprocessor. I really wish we generated header files using CPP once and then included the generated/ file. That would make them greppable. You're looking for include/linux/buffer_head.h and it's done like this: enum bh_state_bits { ... BH_Lock, /* Is locked */ ... #define BUFFER_FNS(bit, name) \ ... static __always_inline int buffer_##name(const struct buffer_head *bh) \ { \ return test_bit(BH_##bit, &(bh)->b_state); \ } BUFFER_FNS(Lock, locked) (fwiw, the page/folio versions of these functions don't autogenerate the lock or uptodate ones because they need extra functions called)