Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1609309imn; Sun, 31 Jul 2022 14:10:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR6K+ZD22Egreq2Wl1t1uHYH6egcpROHw0ud3Ilu3EKNxgLI0TAY4sU4eDq2hJLi8mPzpGRa X-Received: by 2002:a17:90a:f481:b0:1f2:43c:a61 with SMTP id bx1-20020a17090af48100b001f2043c0a61mr16823569pjb.134.1659301853212; Sun, 31 Jul 2022 14:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659301853; cv=none; d=google.com; s=arc-20160816; b=MlBlWq3xQIAI8j3r4+YInDulU26HuIaKq+KFDn6UDrVrh6C1BU8Wnlpji4El/WCPlU BHBQZMH/f3RnKYfyRjxq4fk6Y1RsOGmDgwlr2g59f0NAhEo2G5gJ9wt/li1XjJlAhYTn BUn8jiAhzPNwCLxZwVXFzpUeq62IPBPNWwYHjmH10ld3fUCDNOYyaC19YPD+DwW8bKXU i7tEZcSvoUPdspNXVppLMaEvHA+Cizycz5RG8AQgLOjI646pId3cMo2UJN5yEcJIsput CG6355PYGD0Wpz7UiilFVxX17xe5m9UnYxHoG2v70UhBH72g7JBZn/yizmABzMjgP3T1 onEg== 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=zHs5DigNbmFfl4ihweOFjtJBnI+LejnSW9zgoAc00WA=; b=yRp94EynDbYUQb9WYfCshFNJg8nMaUkNESLP69jbIQgxyG1bItq5JGY1DX6xeRi7fg +digxfP+hCVQt10imuDKpRZVI0GMDgKaEWAcitl6wwxjMbNRd6bUhsCcQZvvstZ0D8d4 vKuS6X7HhUt5YEbX9qqwNvJehJr5CiZRUD734/7kX8zuW7ADzTqKjeLbRTTvV91EAI3H TGOyWtXkmGtyJYj0UhFByQVlAcwAIGpEZeuG9ZnS+tGyGRNEWDAGQ76pBPhuHLQoj0sX /5X9jIlVLa87FyTavkQ8zm+3DDuFpHC5r/jj7Sd/GnuR4Fz88T7dKOMHqj/TKPcuVLpJ fDKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=grBcAk81; 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 e8-20020a656888000000b0041c14304fcbsi1475801pgt.20.2022.07.31.14.10.38; Sun, 31 Jul 2022 14:10:53 -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=grBcAk81; 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 S238441AbiGaU5i (ORCPT + 99 others); Sun, 31 Jul 2022 16:57:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbiGaU5g (ORCPT ); Sun, 31 Jul 2022 16:57:36 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E10CDED5 for ; Sun, 31 Jul 2022 13:57:36 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id k26so1340264ejx.5 for ; Sun, 31 Jul 2022 13:57:36 -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=zHs5DigNbmFfl4ihweOFjtJBnI+LejnSW9zgoAc00WA=; b=grBcAk81NHh6FjeHlS8R3QpHWx7ucYh4v1m/OXvCC8U7iTniplzdCcxOs0x/e14jiL xeMflycY8QiWP7C8N/JDKeNRpyoi5hnaSrSRbYm7nGI/ojO3nfDPmmzYeNKm2TVagBaO xElrzy3VYeqvTBcPCBiYL9ZqykMuqvJwZstMY= 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=zHs5DigNbmFfl4ihweOFjtJBnI+LejnSW9zgoAc00WA=; b=RMDLAC0F+hP7R+kSJEQILJI/ACbUpt8+ftg5DrRaVLwSRlrtvs8lQ29flUhKBUXvYz vByJmG0c9KeVDMhn7wyATnD3wYa23Wxn2/YTOunxiw7u5glMvxeE5zNYnKp9mCj9wwUd nWvaQNBJT0Ppa1lEHlF1bH1yBPKwhJcjgSt7SalQFn42wcPSLdu4LDemEPf9g2gr57oX +UONvrNw6rGnakrJWMale95IFo3URfhTg4UrRj4asZFcFPC8Pi2R9R4J4pAP6Khs9nFl vzatFeq08bymRGES15e6+mF6/s1IgyipwTfo/Q3iz14eZNljoawQ/wbzgGKt+lRPwF95 HhmQ== X-Gm-Message-State: ACgBeo1g4+J+aBA5pK3bzEJj7UZkDyG8yvBYjRgMVk5H6+CmrnIcxO21 Zcc3w/ooycpsol9bWe4CPgXxALq3BW4w3zXiQqA= X-Received: by 2002:a17:906:478e:b0:730:49f7:f78d with SMTP id cw14-20020a170906478e00b0073049f7f78dmr5865444ejc.42.1659301054476; Sun, 31 Jul 2022 13:57:34 -0700 (PDT) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com. [209.85.128.41]) by smtp.gmail.com with ESMTPSA id e6-20020aa7d7c6000000b0043a61f6c389sm5785379eds.4.2022.07.31.13.57.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 31 Jul 2022 13:57:33 -0700 (PDT) Received: by mail-wm1-f41.google.com with SMTP id h205-20020a1c21d6000000b003a34ac64bdfso3435037wmh.1 for ; Sun, 31 Jul 2022 13:57:33 -0700 (PDT) X-Received: by 2002:a05:600c:3553:b0:3a3:2b65:299e with SMTP id i19-20020a05600c355300b003a32b65299emr9035672wmq.145.1659301052865; Sun, 31 Jul 2022 13:57:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Sun, 31 Jul 2022 13:57:16 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/2] wait_bit: do read barrier after testing a bit 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:41 PM Mikulas Patocka wrote: > > - if (!test_bit(bit, word)) > + if (!test_bit(bit, word)) { > + smp_rmb(); Logically, I don't think that makes sense. Maybe you're checking the buffer being up-to-date before you *write* to it? So smp_rmb() seems entirely wrong. I think it should consistently aim for just doing unsigned long state = smp_read_acquire(word); if (!(state & (1 << bit))) return 0; or whatever. We should strive to *not* add new uses of the legacy memory barriers. They are garbage from last century when people didn't know better. Then people learnt to use acquire and release, and things improved. Let's live in that improved world. Linus