Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp559831lqo; Wed, 8 May 2024 08:04:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHCGEECH+NOCJrcv0PYmq8dg+U//QW2tA46paA8W3FAe631dfjqWsKVURaacWpy8k6v93hrq8EXDgTokih+PdMSBmXSGwSlDQJzEatmg== X-Google-Smtp-Source: AGHT+IE6aNo7j9WAFtuHARB7EORSHxiIvoohgqrOtKourXe5s7sCLRW6gUJZleFCMxCuo8FI2L2H X-Received: by 2002:a17:906:3452:b0:a59:ab57:741e with SMTP id a640c23a62f3a-a59fb9dca0emr200091766b.76.1715180694900; Wed, 08 May 2024 08:04:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715180694; cv=pass; d=google.com; s=arc-20160816; b=QxtL3XEE17glli6vSAYJ3coENZO95JccvYeG9UjWnMsWY2R3xuQFPiRPZi7S0o/NWv qyQ5TK2S3qVrijJw9c4Rku83PSbe981X8cSeqDyhZVpnqT8fejOLGEoykx6w9NkbM0sH cUqq1Nx+dEfdlA1Dn8Y7M/L8G8nBma8nmQYgR42JmouR2jdFG/rvtBzJ2nFrlFt1XQ3O yLTmpbytj04tQkHzVnNLYldKAs+5JfzmkNJ0yLsdmNUAjzPiZLWegoM3kohuLVIuVSSL TT28hf1QzMZBSGV8RqSE6jeNcPSIdEQnLNCM9jRSUk+U1txlWF2pCdG4YWRQ33cRTxXz esoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tJrWu9Whp0wr1T9bbbciMuTI/AD/aYy1LnPMSROlLEk=; fh=V1hp9x37s9PzEltpA1SK8VjTicr7X1PR9uXDfADQuKg=; b=QEDF0bYT2LcgRYwG84iW2r1GdSCc8mXp8axDqI0e+LWXgTN6txWmwELElRL0pgrEJf YIrEclMT/fz1D24WItDM8pqLNHBPmezpCWdaqeUELaR6fSo2YcoieTgCpD6snngm1EFY NG486JWqtXivlqPCxSXaRM/zJjhmnMasOyg/usMPLZ9NAoef3Fwwlcs1lWG4Aklyz/zG /gSWqMF/EWCzD2UPif6cwsDAA10CETuqmbkm0AUWxV01/pKBf9F8CTW8xRTF57vA62jr KZVYh8LFHOwZbor+yJqYuchutcdI4TUHUeHO01lVXSdg5Rn34r4E5TAqTMYW+HsB3j+t zJ5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PFtY2cY4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-173451-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173451-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k7-20020a1709061c0700b00a599ae84db8si6029160ejg.31.2024.05.08.08.04.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 08:04:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173451-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; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PFtY2cY4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-173451-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173451-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 9FC561F25F11 for ; Wed, 8 May 2024 15:04:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A64286AFC; Wed, 8 May 2024 15:04:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PFtY2cY4" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEF9A86AD6 for ; Wed, 8 May 2024 15:04:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715180688; cv=none; b=t+ZZGEKedSbU3ODX24nHOtNVz1iLuMw/LkZPnqm9c9Xxs6wIyX7CGhlCfidIrrZTa4JG7rg/DbaS3Bd1irhjwYNn+/bSdwoJvwWSu/1Xq2l/udl81yA98ynx5ZJdIIi+0HHxyzC3ldFUjL0afFwvG0q1ZHfL0PEi7o3lb5npHZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715180688; c=relaxed/simple; bh=BFo75onZvI2N70WEzRUssW0gemvLlk4fluFVMaEeEes=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qo+uDrLU01x1115WBKUiVHqu/vJznd5cqAGcEPQ6HM4CQLP/q6ZbhvYRdRgS+sNWi3FEfLYfHZjWRzZdIeKbOVvenRghK806/EqXUv226bw0r4dohwvvVQ8Yar3Qusl3445dxxXMW3UgtAZqkWr6flIX32ofUR54BjglRhjrXQw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PFtY2cY4; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a59b097b202so898138066b.0 for ; Wed, 08 May 2024 08:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715180685; x=1715785485; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tJrWu9Whp0wr1T9bbbciMuTI/AD/aYy1LnPMSROlLEk=; b=PFtY2cY4WY5+m6TysOFGwRr4nCucHf/2QIMF0l2CPjsDoeZzXi/vfAM+xyBo1qsCqL PVc242DEJ3saAmIsV2fleC77zm76FIbkPyv6wKq4H/LSHizUgnUrCC37jqx3X9k9zpbH pnncs7JTVA2etJ7Bagx/tLUcREXdrtAGjtaFCcb60cycKfVT7/wpswxNwxX6kPS0qepW JpEPQ5LP+zVXmNTKJkTPMTYx9iUPOa2X5At2RLgQqc6w6NXchZcyGU2HIK2I1d8xtsfM Gr49WBu1dpSTOST+Z9qx8pOdnlcxYGTi4ws2VI1rCWxFkhpYcRVIu5XHmDpoeXdcCCqL aBjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715180685; x=1715785485; 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 :message-id:reply-to; bh=tJrWu9Whp0wr1T9bbbciMuTI/AD/aYy1LnPMSROlLEk=; b=AIFvRIo+CCCfId8p3AjJgFP2rh3JdIjCzJEaaheTviE+UuGzT2SA/ATviUl/d8VZfU XQysnIPMJgkX6rbDh+JwvUXn8VJeJEejSR34QNqgo0TXwMnOB+iQVQ8w+hN+gjuj8DG8 /KJHjU6/VbueCgnjgDoiWjfV+v4a6o64ejwt0vIXSnPR1JVjNTggQ0SgYw58jsgWtVaE fIJRJFmXhrG7OV5I/AvPwlHm/DTLM6T5FvwIR7uNsYV0a8jElvfjlb8jcs6loH1kyFGo 5m3JtPyLvAgDu7RrNYq8u9CFdtzJOG/gf9wZ3sYIpYN6rG/W5IpeGsdTqx0rxAT3cTDV 7uPA== X-Forwarded-Encrypted: i=1; AJvYcCVEro9zbKZNm9OfbxAg8+OocJr1FKTv44pmA9zBYK6ZJxyU5t20ohNp1pIoB4QVgGKJWlYRjLYE9Qx0AM/LZC5pGdU8DM2tSYmr5uQK X-Gm-Message-State: AOJu0YxYdsucZCaGS//xLxjH87f7IE2SJoXz5nqQAo3pgnXz/WPTsx0v 4GC54HyFfPWmCEAkm81LRl2BP6RvXnA6wrQx9W9PyR8sorXZ85O+ X-Received: by 2002:a50:f616:0:b0:572:93fa:d6fa with SMTP id 4fb4d7f45d1cf-5731d923f4emr2148830a12.0.1715180684954; Wed, 08 May 2024 08:04:44 -0700 (PDT) Received: from andrea ([31.189.114.81]) by smtp.gmail.com with ESMTPSA id es26-20020a056402381a00b00572e2879500sm5484449edb.53.2024.05.08.08.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 08:04:44 -0700 (PDT) Date: Wed, 8 May 2024 17:04:40 +0200 From: Andrea Parri To: Puranjay Mohan Cc: Daniel Lustig , Will Deacon , Peter Zijlstra , Boqun Feng , Mark Rutland , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH] riscv/atomic.h: optimize ops with acquire/release ordering Message-ID: References: <20240505123340.38495-1-puranjay@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: > From my understanding of the current version of the RV memory model: > > .aq provides .aq -> all ordering > .rl provides all -> .rl ordering > and because this is RCsc variant of release consistency > .rl -> .aq > > which means > > R/W > amoswap.w.rl > amoswap.w.aq > R/W > > Should act as a full fence? R/W -> rl -> aq -> R/W Yes, hence the RCsc ("sc" for "sequential consistent") qualification. > So, I will do the following now: > > 1. Do some benchmarking on real hardware and find out how much overhead > these weak fences add. > 2. Study the LKMM and the RVWMO for the next few weeks/months or however > much time it takes me to confidently reason about things written in > these two models. > 3. Study the locking / related code of RISC-V to see what could break if > we change all these operations in accordance with "Code Porting and > Mapping Guidelines" of RISCV ISA. > 4. I will use the herd7 models of LKMM and RVWMO and see if everything > works as expected after these changes. > > > And If I am convinced after all this, I will send a patch to implement > "Code Porting and Mapping Guidelines" + provide performance numbers from > real hardware. > > Thanks for the detailed explainations and especially regarding how the > LKMM evolved. Sounds good! Thanks. Andrea