Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2129369lqb; Mon, 27 May 2024 08:45:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWEc+Pvu4vKiKBNhJ++tNfvugq4/O2J3lk4cvA2axMDT64SF9dZztAHHOVXvMth8kMlayCo1p3+Rm8JuiCC3hDWqV3o990KhW6OGJ++1A== X-Google-Smtp-Source: AGHT+IHg49V9RJ0atofWtE3owVqs5OYx90jKGckk6R+SaXhMQYHBRxfSYn9h3q+1duiuIG26TjtZ X-Received: by 2002:a05:6a20:3208:b0:1b0:2826:9e2 with SMTP id adf61e73a8af0-1b212d49917mr9529465637.31.1716824712284; Mon, 27 May 2024 08:45:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716824712; cv=pass; d=google.com; s=arc-20160816; b=dnRMxBFFGGS3DsJgWskR6ugfY3aCXdxXaoSsFEKoOvzskbSDPMQnBHaXkPY7TkCT0T XhBFIcbPPK54T9+o9jg91U0KDh6REQQtFDwfJsfei8iabIMmLeSjlC0MYB3ifaferpv4 4h93k7fj5rwv8Ns3op5GKskqpdVy0TApWcay06rtq8uEKik6Z1h5HrPrhX2NQ5+4ObO5 dpDecLz0opxnrADPJ6kAUQbtbWMhd22YVdTUKN0tS0fRDYGQNkV6AfrimYlJ1nWlAaLl oSWfqOrmLp+LGpzUFJcxYlSh0qClIf2BFP1mQSCorMV6sAuMvlfEQ+4/Tm8OwvCYvl6X MFhg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Zp7ux+FLEJpySdQ3btw3g5b+nolQQX2Sr4WIckKYrXQ=; fh=799lbWnfQniCFstPM0ex7oUdixFdjunCmgTcfvfmKs0=; b=yG2C8nlP9tLuI7StoYyaNY1gJ4ZaUhwkhiBHsopdgfox690WVP7XB2hNk1ElKYdvDQ BcGGKwl+oyWzfboc0aBmsIhfl8H8AYk3O3g3HRXYmOyeNOOe2G3d+ckMqiPZlOMgHgZf OxOL47mv7OLnEonf2/G8LGdHs+Zmz1y+zHsEZy2QxaYuMLfaNmhVQiam5WHGFgb3xX9o IC78Zy++Tiv0FAvXxNFRJ/cqSNhpSP5S8nOjYO4NhvEcmx3a2xINje8oUKrkegm1XrvH SqMD87dOTvJdo2A+h024WscTmS8z8+l7HPrqrhtUSP0pE8a2sRoGd1YDf4aFjDdaivmQ DRbw==; 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-191064-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191064-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6a3d30b823csi1419584a12.850.2024.05.27.08.45.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 08:45:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191064-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-191064-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191064-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 43F77299042 for ; Mon, 27 May 2024 15:29:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13FE973463; Mon, 27 May 2024 15:24:03 +0000 (UTC) Received: from frasgout13.his.huawei.com (frasgout13.his.huawei.com [14.137.139.46]) (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 A1F7661FFB for ; Mon, 27 May 2024 15:24:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=14.137.139.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716823442; cv=none; b=rnCtg501sHCZCIScf8L6a9Ag+0HNnr0Hnc7XSP9peOazA2zSSakHpSbrYAEffU2Hvfpr8DvQwC2jEm0UV2ZR3b5r6pFx4LnpzLfu4AKqjH+YjdufPZRWlpUiagx+YC+esLm1YpUau8xLv4uzSGl291fszQA4rVDYml51kwNDiHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716823442; c=relaxed/simple; bh=zbu6nmCHUO93zt/7OgCtge0gcv5wVCjbKVEbJTIMhAo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ffBh8oKvTfZoCxj17htNeLOSI37v+5X02lbP1BQaEIuOMrc9OsHbYep4im7xYLAMAnQAi9GZCKJ5I5iFW1TEgTHDFfqYttBSrOubs7xsNfUxZcVhkGm0WluUuI+qN22NrP87Em5b1MmoyPnGX0JqZaguhE+L7dNKd6eLTTtFJGw= 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.46 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 frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4VnzWN54T0z9v7Hn for ; Mon, 27 May 2024 23:06:40 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.47]) by mail.maildlp.com (Postfix) with ESMTP id D495D140133 for ; Mon, 27 May 2024 23:23:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.206.133.88]) by APP1 (Coremail) with SMTP id LxC2BwAHshpgpVRmXLgGCQ--.41702S5; Mon, 27 May 2024 16:23:57 +0100 (CET) From: Jonas Oberhauser To: paulmck@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, dlustig@nvidia.com, joel@joelfernandes.org, urezki@gmail.com, quic_neeraju@quicinc.com, frederic@kernel.org, linux-kernel@vger.kernel.org, Jonas Oberhauser , Viktor Vafeiadis Subject: [RFC][PATCH 3/4] tools/memory-model: Define effect of Mb tags on RMWs in tools/... Date: Mon, 27 May 2024 17:22:52 +0200 Message-Id: <20240527152253.195956-4-jonas.oberhauser@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240527152253.195956-1-jonas.oberhauser@huaweicloud.com> References: <20240527152253.195956-1-jonas.oberhauser@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:LxC2BwAHshpgpVRmXLgGCQ--.41702S5 X-Coremail-Antispam: 1UD129KBjvJXoW7KFWUZry5tFWkCFW8JrWDurg_yoW8WFWkpr Z0g345GrWvgryj9as7ZanxZFyrWa1xKF13WFs7Cw1fZr43XrW7Z34rtanIqr9IqFsa9a45 Zr4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transforms successful RMW with Mb tags by inserting smp_mb() fences around them. We emulate this by considering imaginary po-edges before the RMW read and before the RMW write, and extending the smp_mb() ordering rule, which currently only applies to real po edges that would be found around a really inserted smp_mb(), also to cases of the only imagined po edges. Reported-by: Viktor Vafeiadis Suggested-by: Alan Stern Signed-off-by: Jonas Oberhauser --- tools/memory-model/linux-kernel.cat | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/memory-model/linux-kernel.cat b/tools/memory-model/linux-kernel.cat index adf3c4f41229..3a6e9677abe4 100644 --- a/tools/memory-model/linux-kernel.cat +++ b/tools/memory-model/linux-kernel.cat @@ -34,6 +34,15 @@ let R4rmb = R \ Noreturn (* Reads for which rmb works *) let rmb = [R4rmb] ; fencerel(Rmb) ; [R4rmb] let wmb = [W] ; fencerel(Wmb) ; [W] let mb = ([M] ; fencerel(Mb) ; [M]) | + (* full-barrier RMWs (successful cmpxchg(), xchg(), etc.) act as + * though there were enclosed by smp_mb(). + * The effect of these virtual smp_mb() is formalized by adding + * Mb tags to the read and write of the operation, and providing + * the same ordering as though there were additional po edges + * between the Mb tag and the read resp. write. + *) + ([M] ; po ; [Mb] ; (* po ; *) [R]) | + ([W] ; (* po ; *) [Mb] ; po ; [M]) | ([M] ; fencerel(Before-atomic) ; [RMW] ; po? ; [M]) | ([M] ; po? ; [RMW] ; fencerel(After-atomic) ; [M]) | ([M] ; po? ; [LKW] ; fencerel(After-spinlock) ; [M]) | -- 2.34.1