From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F317D33989 for ; Mon, 28 Oct 2024 14:10:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1DAD6B0082; Mon, 28 Oct 2024 10:10:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCDAE6B0088; Mon, 28 Oct 2024 10:10:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6EA86B0089; Mon, 28 Oct 2024 10:10:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9B6636B0082 for ; Mon, 28 Oct 2024 10:10:46 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 436788048D for ; Mon, 28 Oct 2024 14:10:46 +0000 (UTC) X-FDA: 82723195716.07.5B405F7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id ED8CAC0002 for ; Mon, 28 Oct 2024 14:10:33 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=letOBCsL; spf=pass (imf10.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730124485; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=L5Wb81OCWchBd8SPc092S/wRHWxzD42JXfq1wj683YE=; b=6VMEhcWK2I+AyWzrJEVs/krIKbymuR4ALTS0Dj4iM20ELa6QIWVlWREFCw6Xo13f2A/yL/ Py4XHBK3YCzMv41eQA/r+ZiSYOad2VwJfzEHrotwGcvrQNC+nPu6KGgttlZ4WK8pPWD2/2 S3O1xPAko4Ykha2iC3pVN4KlpjmeKs4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730124485; a=rsa-sha256; cv=none; b=SruRP0RSdJaLTpJLnEhlK45AQHqedmv1UDiPprBc+zfJo4gb3TXVDsM4gVpJiIc3UZSDNF rxrsL0fkqDiw9xncDOobH/m9Wx/v1vWK8QZ5KmVz0I4Aa3L6dZWN2pe2EeCIO5YKuU4eS9 JTuykaUCz1IuGfU1Amu+N42efRxmbjY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=letOBCsL; spf=pass (imf10.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 471335C4251; Mon, 28 Oct 2024 14:09:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D67F6C4CEC3; Mon, 28 Oct 2024 14:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730124643; bh=UOyycE1D7kC/7syiC7gLva+nUvimfyrJhVci/Klvmwk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=letOBCsLztxv7UCD3XJKGDi7cTdMqeJTGtS+t30wGG7u2sNrOjFZIozVUe3TPE6nh ADe77XWlYc/slaPb1vm9mNmMbrF+rcEgTE0uOLVlu+7chTisdoWdZXDY72nJXWrdlQ KfLaFHJhrUO5VDtj85QZR85bXz+NNwqAIDf76mVTdnPylLZf0z8c6DCQi9/7A+6KX+ uyau4g2alEkwFItib62BUjyvzk8hNt5DL05ZiDRnlX/+8cNoVbzKA7oCLHU5TLjQ00 VBd2TOQrwFySRiWneU5P/pw4VG6DkVE2R9A2Be4y1AysQS4rgdCbwxU7uZYaOgMrIm +gVR9X0EBVplA== Date: Mon, 28 Oct 2024 14:10:37 +0000 From: Will Deacon To: Linus Torvalds Cc: Peter Zijlstra , "Christoph Lameter (Ampere)" , Thomas Gleixner , Catalin Marinas , Ingo Molnar , Waiman Long , Boqun Feng , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org Subject: Re: [PATCH v3] Avoid memory barrier in read_seqcount() through load acquire Message-ID: <20241028141036.GA2008@willie-the-truck> References: <20240912-seq_optimize-v3-1-8ee25e04dffa@gentwo.org> <20240917071246.GA27290@willie-the-truck> <4b546151-d5e1-22a3-a6d5-167a82c5724d@gentwo.org> <20241023194543.GD11151@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Stat-Signature: 3srmmbih8d4pojp794p5xon5b4on6o6n X-Rspamd-Queue-Id: ED8CAC0002 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1730124633-772717 X-HE-Meta: U2FsdGVkX1+ksIg9cyjH0uP6SjoW8asC1Z6ZxLyVBxguw8m8R6krrGnwPvRdLAzYlqnx0PRQBIbCxV9NIRMAX8ztb13FeVeektMPyPj5JUI5/oz7J+pGhoEVFfdvaMhI3F77kmSkrxrKWaz2EzKLzaIgEycih1d1ZumRIqkwkasETy0JUx1UunopyD75f3Exj3a4ePXpBXHcvpylUpagrhLHkGQq31MW8/YgyzwPclMxtVzZx/IaLndXNpnxo1kLYfrBNkVY2UaxMEvF8zgBtZx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dm48r5Ywabjfnzs0ArwgkPqwedKTStQF1lw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Oct 23, 2024 at 01:34:16PM -0700, Linus Torvalds wrote: > On Wed, 23 Oct 2024 at 12:45, Peter Zijlstra wrote: > > > > Do we want to do the complementing patch and make write_seqcount_end() > > use smp_store_release() ? > > > > I think at least ARM (the 32bit thing) has wmb but uses mb for > > store_release. But I also think I don't really care about that. > > So unlike the "acquire vs rmb", there are architectures where "wmb" is > noticeably cheaper than a "store release". > > Just as an example, on alpha, a "store release" is a full memory > barrier followed by the store, because it needs to serialize previous > loads too. But wmp_wmb() is lightweight. > > Typically in traditional (pre acquire/release) architectures "wmb" > only ordered the CPU write queues, so "wmb" has always been cheap > pretty much everywhere. > > And I *suspect* that alpha isn't the outlier in having a much cheaper > wmb than store-release. > > But yeah, it's kind of ugly how we now have three completely different > orderings for seqcounts: > > - the initial load is done with the smp_read_acquire > > - the final load (the "retry") is done with a smp_rmb (because an > acquire orders _subsequent_ loads, not the ones inside the lock: we'd > actually want a "smp_load_release()", but such a thing doesn't exist) > > - the writer side uses smp_wmb > > (and arguably there's a fourth pattern: the latching cases uses double > smp_wmb, because it orders the sequence count wrt both preceding and > subsequent stores) > > Anyway, obviously on x86 (and s390) none of this matters. > > On arm64, I _suspect_ they are mostly the same, but it's going to be > very microarchitecture-dependent. Neither should be expensive, but wmb > really is a fundamentally lightweight operation. I agree here. An STLR additionally orders PO-prior loads on arm64, so I'd stick with the wmb(). Will