Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp4278728rwn; Sun, 11 Sep 2022 08:36:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR5hmeGLKCKcLsyOAlHO40eIbOUSdHaFkuRnnUMQo3/nHvopnCF2EgqWopoqllXeHlLcVEMw X-Received: by 2002:a17:907:70b:b0:740:ef93:2ffb with SMTP id xb11-20020a170907070b00b00740ef932ffbmr15578862ejb.93.1662910612784; Sun, 11 Sep 2022 08:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662910612; cv=none; d=google.com; s=arc-20160816; b=dQhfb1wWus+M9CYOvwsjjk0V5+C0emAiZmWL2EC1fZ2l7MLZ8EKI8aBB9RihyfsQiw 4dCSNDKJuKwK6vfFisa1IvLe2T/EGWbt+b3+s4NoteTqisGxx9OTBjc6yjzlFjPWKBjL XQ7+iAnNANEUptk0kqp4X5pVaXeWY5/o5moWQmceE8/vdHny5ivacQg8crA+7iIDZe5J eqQR669llPkGIad3ulHVM2kI0dESDGXsBH4zAf0d/a2bPfJsrsLWcnWicRr/6gX20wQ/ 72GcgwEarEO0aCv4OIR6rCL+vsmf3cuXiiRjBS3dkkVLmHSwwzJ3GkG2+f/b5PHehu34 N6fw== 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=uypL6+Xj/GKvVxDwG8c8USvO49xWLjhIva5vwnPAO2Q=; b=ZdX9QM8KZn26NoRambeSL1bUM034rDrGfvBrLjMwPwlXZjCUHe+b/cIKeeXS+h0AZ+ HwYfcOQrVnqSr4Gjx8fYiOWnvv8fC65avPoS3yLrYxNC62tMNdWg1Z68u/xCJNwO6EYN sx/z3j/nu9G+VpuwhC1K8HpYm192yMQUCtK7jzPiMQOG/Tf/MtzjGYKjpvztyJmk4Gr/ HSgMA4Afyy7tji1p3/kwBhxOTvfeXHQPOOKh5N7rg+tA6Ld6rmrNfMoPIuC2Tpik+hSr ENWBegJ4JM9uqPqJ30ZKKnI1zvEyfkjM7Ajyf1GNjigjAamlD41bA/HtA/GY0R9ti/QM FAlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ofg2adC2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id by12-20020a0564021b0c00b00450ba83d4c2si4776712edb.344.2022.09.11.08.36.27; Sun, 11 Sep 2022 08:36:52 -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=@gmail.com header.s=20210112 header.b=ofg2adC2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229658AbiIKOyB (ORCPT + 99 others); Sun, 11 Sep 2022 10:54:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbiIKOx7 (ORCPT ); Sun, 11 Sep 2022 10:53:59 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2F702CDD3; Sun, 11 Sep 2022 07:53:58 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id bj14so11414361wrb.12; Sun, 11 Sep 2022 07:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=uypL6+Xj/GKvVxDwG8c8USvO49xWLjhIva5vwnPAO2Q=; b=ofg2adC2oN11oXhZUzmHj9ISfTGifL1qcHk34kuEZW0WSO9bZMO7EjBAk/OhdDQgi6 uDrVjstKqPIMjU7SU5okbBzJnBWu9Wu5AK0kQIaP5dfYQgkVuSPnpKU2K8D60zdba1Yd dhZXM2ZhhjOgedN6fuz7TSj0cACkAT8wCfDoJoGPNWRlWeAyQwubQqsRhmbIQ3udJoTU ftwsGZ4YSqaG6OnpPKZBp6oOQVw9atI8FS2c3YfJHJFOxAG2X/BphoMfWxwQxFO/FxB1 iMdBeoIxlNlroTHxZfkxJ1S7HTZ+J3r2MFbjYfzajoScm3vSDkL9HU/ktk4rop4JreOP 4gDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=uypL6+Xj/GKvVxDwG8c8USvO49xWLjhIva5vwnPAO2Q=; b=ajXV7yo7VWPICD37ITepUMfyLClk1FdLa1Ae1eHxRcsicIdBeFWIb8sfgiVGTESiPQ hYT2TETmslj7teNoANvqRld6Be2azg4S3MK/VMqTnEAS7YH3xAskmcRRLoU+3rVqQfyY 0WRXm0y2Z3aTEoSyaE0UFl4l9TcFiIp4ZKtJV4x7ssMzYmDRE3SRjbC3q3F9Jc5aEMw4 CSdukPkZZpWPB0qEyEz8p87w7QwWfajC+7ExID9btGPfag537uvrcx/gjxF0BNmSTCb9 l+nkezZoSD4ZvBTOmLOE4Ie9E4b3bGSnZwcFMfNPkqDtT9cVR6kvWdedpQEffZRyGAIq asQw== X-Gm-Message-State: ACgBeo1ajwN+95EBVEM6aINhhBWtWVonheljbOsfZzAk/DQWszg+TLw+ 4whA5s5zmc3D56Q+cGo2LJo= X-Received: by 2002:a05:6000:136b:b0:22a:3b92:4c05 with SMTP id q11-20020a056000136b00b0022a3b924c05mr6716973wrz.183.1662908037225; Sun, 11 Sep 2022 07:53:57 -0700 (PDT) Received: from anparri ([185.122.133.20]) by smtp.gmail.com with ESMTPSA id n16-20020a05600c4f9000b003a5c7a942edsm7011166wmq.28.2022.09.11.07.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 07:53:56 -0700 (PDT) Date: Sun, 11 Sep 2022 16:53:51 +0200 From: Andrea Parri To: Hernan Luis Ponce de Leon Cc: Alan Stern , Jonas Oberhauser , Boqun Feng , Peter Zijlstra , "Paul E. McKenney" , "will@kernel.org" , "npiggin@gmail.com" , "dhowells@redhat.com" , "j.alglave@ucl.ac.uk" , "luc.maranget@inria.fr" , "akiyks@gmail.com" , "dlustig@nvidia.com" , "joel@joelfernandes.org" , "linux-kernel@vger.kernel.org" , "linux-arch@vger.kernel.org" Subject: Re: "Verifying and Optimizing Compact NUMA-Aware Locks on Weak Memory Models" Message-ID: References: <20220826124812.GA3007435@paulmck-ThinkPad-P17-Gen-1> <674d0fda790d4650899e2fcf43894053@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 > Here is a litmus test showing the problem (I hope the comment are enough to relate it back to qspinlock) > > C Liveness > { > atomic_t x = ATOMIC_INIT(0); > atomic_t y = ATOMIC_INIT(0); > } > > P0(atomic_t *x) { > // clear_pending_set_locked > int r0 = atomic_fetch_add(2,x) ; > } > > P1(atomic_t *x, int *z) { > // queued_spin_trylock > int r0 = atomic_read(x); > // barrier after the initialization of nodes > smp_wmb(); > // xchg_tail > int r1 = atomic_cmpxchg_relaxed(x,r0,42); > // link node into the waitqueue > WRITE_ONCE(*z, 1); > } > > P2(atomic_t *x,atomic_t *z) { > // node initialization > WRITE_ONCE(*z, 2); > // queued_spin_trylock > int r0 = atomic_read(x); > // barrier after the initialization of nodes > smp_wmb(); > // xchg_tail > int r1 = atomic_cmpxchg_relaxed(x,r0,24); > } > > exists (0:r0 = 24 /\ 1:r0 = 26 /\ z=2) > > herd7 says that the behavior is observable. > However if you change wmb by mb, it is not observable anymore. Indeed. For more context, this is a 3-threads extension of the 2+2W test/behavior, cf. https://github.com/paulmckrcu/litmus/blob/master/manual/lwn573436/C-2+2w+o-wb-o+o-wb-o.litmus which is also allowed by the LKMM. The basic rationale for allowing such behaviors was that we "don't think we need to care" (cf. the comment in the link above), except that it seems the developers of the code at stake disagreed. ;-) So this does look like a good time to review that design choice/code. Andrea