Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1287163lqh; Mon, 6 May 2024 03:06:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUS6rZN1WR59/yzL1EsUrnmvBJAcWYG9QzW3mvLw4gVtO7LdNCsHzZUqKJXulq37aQGGK8yEVm11R3cS+vT4S4VJB1zx8OoOrPQ+FU36w== X-Google-Smtp-Source: AGHT+IF9R46Vh6Rep+oSipwR7X1Czpu1CbubHrftSqWtQ/guHgK+x9YA5FfBq9lJKvEqV3sXixCL X-Received: by 2002:a17:907:7da6:b0:a59:aa9d:3142 with SMTP id oz38-20020a1709077da600b00a59aa9d3142mr4221951ejc.37.1714989995916; Mon, 06 May 2024 03:06:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714989995; cv=pass; d=google.com; s=arc-20160816; b=ffE8J3/hhxNxj8KpPDmxuC0xxpKMULZcZMYyuFu82WQ16HjHWiMZ4ojsJumKrWPiAz +YpbBP5qem0z1dT4/x5WRRiCEBFrp0c0bxVadkqgSiuqTbk570joQeEVCj7cNX74c4l4 Hmrg/sJIbA5Tpi4sM5vIQdYn/PxFcq7ERRVFtNXjrrUrCCDTSs9ObhM0418AKo1w+kzg HatxuNQ3jIQju6nSVzaSTbEvWPUcnHiQVUXs1ZcLYDHrubjWBSXP/BSy3oIaRzcV6+5F 4tcgadeteqJDSJKjjoRhorqg8x7QRVzm0XwaV+xVp2gthA8e5nBpbGqVwKIko2lyBlsZ oEsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=jEgu9XerE9ID40Gx9kARmvhaYXLIoDNEXCF7reKNK68=; fh=KssM8PRYlzWzbtpYA/+OeQ/pgblRcls1YT7HESXh64I=; b=xZTC9RsnyPRttWzqE0aYUlH5nuTNd8J6luzsacPNszvfD/p8jY15eXIqY8ybbzoC5d NFPpA5Lrs4LaO7B2cMBNtess0c15GTpg17818cGq6WN2drU/dkYZCNEEmoNLjau37Fq5 0vW1ax/9WQ51+Mt9MicztGL08JgyBN/Aj6hNbepIn8isc+R8ua5S2QZmYlix5SOO+zlB kA4U6Ig9SGnNMLnW6wMGYkIRN7LrPi6Gbj+0MkmfNz7mL2F9/csoqYEPCUf55YQoMt3N Bs78DGU5VLGWdnuZoEDHIj3wZTUkWDJJfvibeacJNwP+/l3ON8NVgT85XYVfoYUrq8dj 1w+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-169641-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169641-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gs30-20020a1709072d1e00b00a59c408700asi1700975ejc.923.2024.05.06.03.06.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 03:06:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169641-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-169641-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169641-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A4E761F2348D for ; Mon, 6 May 2024 10:06:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD28614290E; Mon, 6 May 2024 10:06:11 +0000 (UTC) Received: from frasgout12.his.huawei.com (frasgout12.his.huawei.com [14.137.139.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4A16140366; Mon, 6 May 2024 10:06:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=14.137.139.154 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714989971; cv=none; b=oSc2SL65hgtGAgJywtl/0ZwYyQRPFJHQag/+O089fchNx0b1pZ/gDuIe7CwGWAuL86bTscziK4g1QrazzkK8yQKMgti5SKWIrCwQx7d7ukJZLOqnE0jZF/9DzaJWPCmO+JSUDx/GF7mbQrE2KEu/zbosXz8u2PjalTlWorgD0Rg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714989971; c=relaxed/simple; bh=3bKywxWdwXQJn9t7WE5tCeMMFA6vA0dUvFi3njX5doo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Yx99Cws+Mn02v9a28WeNX/Uw9MyZfPlp4znWlE7U9Q+QQb6cFhLf8Yu7G+Pw0x03Kh5rTtPs3sAlHkepPF8y1NA2ejgYbVwU1OagdFpU/gJspPA/3P91YfYKyTu+RPOOQwzWP0wFCObGhIViGNyejBLhfDOXCcW7XSSEwPw1wFQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=14.137.139.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.18.186.51]) by frasgout12.his.huawei.com (SkyGuard) with ESMTP id 4VXxMR3twyz9xGXN; Mon, 6 May 2024 17:44:35 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.47]) by mail.maildlp.com (Postfix) with ESMTP id 6DCB91404D9; Mon, 6 May 2024 18:05:58 +0800 (CST) Received: from [10.81.216.243] (unknown [10.81.216.243]) by APP1 (Coremail) with SMTP id LxC2BwCHexR2qzhmIrWjBw--.20188S2; Mon, 06 May 2024 11:05:57 +0100 (CET) Message-ID: Date: Mon, 6 May 2024 12:05:39 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH memory-model 2/4] Documentation/litmus-tests: Demonstrate unordered failing cmpxchg To: "Paul E. McKenney" , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-team@meta.com, mingo@kernel.org Cc: stern@rowland.harvard.edu, parri.andrea@gmail.com, will@kernel.org, peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com, Frederic Weisbecker , Daniel Lustig , Joel Fernandes , Mark Rutland , Jonathan Corbet , linux-doc@vger.kernel.org References: <42a43181-a431-44bd-8aff-6b305f8111ba@paulmck-laptop> <20240501232132.1785861-2-paulmck@kernel.org> From: Jonas Oberhauser In-Reply-To: <20240501232132.1785861-2-paulmck@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID:LxC2BwCHexR2qzhmIrWjBw--.20188S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr45urWDKw47Ary5Kw1Dtrb_yoW8Gw17pF WUKF43Kry7J39Ykwn5Za43X348uayftan5Gry3GrWqv3Z8CFyjvFyrtFWSgFy3Jrsaka1j vr1a934xZrWUAaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1l42xK82IYc2Ij 64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x 8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0xvE 2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42 xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv 6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUFDGOUUUUU X-CM-SenderInfo: 5mrqt2oorev25kdx2v3u6k3tpzhluzxrxghudrp/ Am 5/2/2024 um 1:21 AM schrieb Paul E. McKenney: > This commit adds four litmus tests showing that a failing cmpxchg() > operation is unordered unless followed by an smp_mb__after_atomic() > operation. So far, my understanding was that all RMW operations without suffix (xchg(), cmpxchg(), ...) will be interpreted as F[Mb];...;F[Mb]. I guess this shows again how important it is to model these full barriers explicitly inside the cat model, instead of relying on implicit conversions internal to herd. I'd like to propose a patch to this effect. What is the intended behavior of a failed cmpxchg()? Is it the same as a relaxed one? My suggestion would be in the direction of marking read and write events of these operations as Mb, and then defining (* full barrier events that appear in non-failing RMW *) let RMW_MB = Mb & (dom(rmw) | range(rmw)) let mb = [M] ; fencerel(Mb) ; [M] | [M] ; (po \ si ; rmw) ; [RMW_MB] ; po^? ; [M] | [M] ; po^? ; [RMW_MB] ; (po \ rmw ; si) ; [M] | ... The po \ si;rmw is because ordering is not provided internally of the rmw, although I suspect that after we added release sequences it could perhaps be simplified to let mb = [M] ; fencerel(Mb) ; [M] | [M] ; po ; [RMW_MB] ; po^? ; [M] | [M] ; po^? ; [RMW_MB] ; po ; [M] | ... or let mb = [M] ; fencerel(Mb) ; [M] | [M] ; po & (po^? ; [RMW_MB] ; po^?) ; [M] | ... (the po & is necessary to avoid trivial hb cycles of an RMW event happening before itself) Any interest? Have fun, jonas