Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1604697imn; Sun, 31 Jul 2022 13:59:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1updOO8rhOehbYQd8kfvHenr0BJjHfus4O7Lfm73roZMFyMyWZET7LxQi8m44bZ3wajGdZx X-Received: by 2002:a05:6a00:1a0f:b0:52b:13f0:6ab1 with SMTP id g15-20020a056a001a0f00b0052b13f06ab1mr13342184pfv.60.1659301176253; Sun, 31 Jul 2022 13:59:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659301176; cv=none; d=google.com; s=arc-20160816; b=dY/2ORMaN7cswlCA7rB/AhAa/n+blDojnBGpzPgIBUq8YdKfog4fzoQnleaPBpiNP1 rbTrd+Cd2fWL0MUu+W586iAoGorJVZZWP5+QVk8JvYSN5JeQdZh0lrqxF3phhjsTjNOP z14QKFX4Sdah1bO2njkM0jhyXVh3aIWbkUUMuL8bRAtNIuxK1L/50tXAzTLPW9xemYzt zS6i5dyvWyFbL2f2oz/YNWq4j0ts4zqqBwjFE0x491k9UIExicR8d8pQZDY45kbwywNQ ald8kn5BOve6QyL/x4RxNTeEgNjf9vlN6pqEyWM6OdRjNt/ZFAbvx2vZN0qu6LB+xAkV mTpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=D1fnuTWJXlc2dukCsRsC5YQz2zD6ofMDDxPYK2SWWv4=; b=OEmFwPFOsUe+CVjDXrXgEaRX4/u0TzQ5LRzEfV8mUk7EiEFLvVV9WOw6fvmR0opAAx B89nqvSA8WekNAuH2kK+ohZCDWAgmnMVq58OIGdfrlKrTUGPEcnAZfEDEDgTzQ6Ch2f6 cGf0licE23qk9Qch1s8aQJnKvUHGa6q1w6udMf0TTRw0R+2zD6ZoI3tpWr+VhCnyD+HM GyH5AvnKN2XPBwoJlJjdlwyIFz14vKOvv2ehHLd90KL6yqnjFLCkJWWaPvSSjuZDUmCz ZXiU78JXO6TO9vnrXKHsYYXnaUoOANnm3Zfv5OVQEzuG80Al8G5M5gWfxWUf+ytM1cZ3 JFiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=d4o7e56v; 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 p38-20020a056a000a2600b0052ab890ce2fsi11811846pfh.302.2022.07.31.13.59.21; Sun, 31 Jul 2022 13:59:36 -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=@linux-foundation.org header.s=google header.b=d4o7e56v; 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 S238044AbiGaU5J (ORCPT + 99 others); Sun, 31 Jul 2022 16:57:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbiGaU5H (ORCPT ); Sun, 31 Jul 2022 16:57:07 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED51DEAA for ; Sun, 31 Jul 2022 13:57:06 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id b96so1185803edf.0 for ; Sun, 31 Jul 2022 13:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=D1fnuTWJXlc2dukCsRsC5YQz2zD6ofMDDxPYK2SWWv4=; b=d4o7e56v6jaT/H39UmhsDACmb3MPAMvJJPhLDSCiN2LHVwivDQ648MIwKHekYwgCeK yNYv4J6/pOe8JmTVWy1w2wnXmQagkxahHOq+/eIYdSbqC1T6I7bBJiwyd+hqGrvUgq4Q pLQG2n9c3fDKVgK0znE3hVIfiq3PTKLVMybfI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=D1fnuTWJXlc2dukCsRsC5YQz2zD6ofMDDxPYK2SWWv4=; b=v4H4SMbUHQncg8PxpASnTMp8ykItS9iN1irpk+NwWUOYoVYf49XBy2D21kqqTV7aNO 9jNLSsc+psw6kztkDJkXxim4JvtsI34V9i13uoNA6j8IsvneapLiAwl2DqYurKz3h6Lw 5oghPJDU8gEfZTcZby9ucMT9UDMm7oBQWJ3/EHlls0rwQg3ppKk0FoKdwZ2NN5jjiOEp IjYCrz9PPH/WgKDq0a6R4+h1UgoBn4fQWCIbx+FOibFp5VKg+2fkgwRHgkEtti4bb0v0 aozsbfP8F+TN77Z+UKPad0ajG8IhJFqPg8WJ3soUwPmGUkWCwPVk1A0ibnGKu/uhxtWz URzw== X-Gm-Message-State: AJIora9ufJQ7+SHYQQZYqJ1UWZlI9WcsR4spW7oOb52mZhGdwsCct+b5 UsowojVL10WVPcBdEfwFneE0XBHJIasSZAbKMfA= X-Received: by 2002:a05:6402:5202:b0:43a:a238:61c with SMTP id s2-20020a056402520200b0043aa238061cmr13046655edd.186.1659301025205; Sun, 31 Jul 2022 13:57:05 -0700 (PDT) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com. [209.85.128.43]) by smtp.gmail.com with ESMTPSA id p3-20020a17090653c300b00730223dc5c0sm3897998ejo.206.2022.07.31.13.57.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 31 Jul 2022 13:57:05 -0700 (PDT) Received: by mail-wm1-f43.google.com with SMTP id v131-20020a1cac89000000b003a4bb3f786bso804007wme.0 for ; Sun, 31 Jul 2022 13:57:04 -0700 (PDT) X-Received: by 2002:a05:600c:4ed0:b0:3a3:3ef3:c8d1 with SMTP id g16-20020a05600c4ed000b003a33ef3c8d1mr9272114wmq.154.1659300698214; Sun, 31 Jul 2022 13:51:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Sun, 31 Jul 2022 13:51:21 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 2/2] make buffer_locked provide an acquire semantics To: Mikulas Patocka Cc: Will Deacon , "Paul E. McKenney" , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 1:43 PM Mikulas Patocka wrote: > > + > +static __always_inline int buffer_locked(const struct buffer_head *bh) > +{ > + unsigned long state = smp_load_acquire(&bh->b_state); > + return test_bit(BH_Lock, &state); This should not use 'test_bit()'. I suspect that generates horrendous code, because it's a volatile access, so now you'll load it into a register, and I suspect it will generate s pointless spill just to do a volatile load. I didn't check. So once you've loaded b_state, just test the bit directly with return (state & (1u << BH_Lock)) != 0; or whatever. Linus