Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp913258pxb; Thu, 28 Jan 2021 03:35:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3wAT2dpNjlT8CV4d34/ukSz/aNq0ZMXTeF7i0gQQg1OSv8ofvrhzz2pC0oAez9t/MSbGN X-Received: by 2002:a17:906:eb46:: with SMTP id mc6mr10771093ejb.184.1611833720658; Thu, 28 Jan 2021 03:35:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611833720; cv=none; d=google.com; s=arc-20160816; b=MJUs25jIhRbsAz+HFs8ynJEloswIMUoaHtZWLtSyEavedY5pe6Vuk8cCoOfgI/wTlX VUn/W8HRfSEDk3X9IhJKK9WQlx/WGoTR6TZ39Ajvck2lZzm9cRHVYtM096cHFFi4wjQ7 Z7vZGg4WRBslpxyhdYcfXgsYplvz/gTfvT/ubUXmYiBEwcFjk3OI2/GOd1oY6TV2v3W8 PLTLNCGPEmtTj+002P2jOrrlMVLL5pXmefhp73CVAJ8/PiAlDhyk7neb0TSTegD2bAqx VtxL5HTJp2sWw3PSUnOigCDrkq5mlmxICafo3DEFpRL0vyAWcIZ+Xh+s9EfRJenGmd+4 whsg== 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=IUujPNoLJPhaulCTunLzVc+aMIY9llkn0PPsho9EbXg=; b=0D4tspPxfwdTFtnhT2JpQRJeOie90SmJnQiTFL/S4ekKpa41qSm8wlokZ7iOT3i6wJ atXAd8zirsBVNCeLIDd2Bbf5c6mIycMhDAwSMpN3sFj0eAl8hvz94u8Eg+EYTA0QSnme KAstV6uAEjzq2xCp0i4e1rkZqrhUaobQSvbhWH2IYzQOaoGUCca/nQd2xVKXwjtIjMHy 273gbtQYKT0SOu88rwB34lk0azCi3vnGqAN9Uz3itd5cFXCZpZGnWcEJLjUFUrInWy5G 44p/297hL/zG+D6Gyg0/XJnnDCRpkj9xXnBOgTTHk+CDtqM29r2zCKulIeS1N6w0VbzF cK6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=q3UUj0cF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i1si2928451edl.551.2021.01.28.03.34.54; Thu, 28 Jan 2021 03:35:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=q3UUj0cF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbhA1LeT (ORCPT + 99 others); Thu, 28 Jan 2021 06:34:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbhA1LeP (ORCPT ); Thu, 28 Jan 2021 06:34:15 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2D55C061573; Thu, 28 Jan 2021 03:33:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=IUujPNoLJPhaulCTunLzVc+aMIY9llkn0PPsho9EbXg=; b=q3UUj0cFxO4alOPCMS3cjAmR2u wKGu2iv+3Xuhu5QxISZ9ZZJOS0pQ2GtYBzM2WVMeV/OjggbcOPiwNYxDFIMtyPTaQQNEfDT3TiBRa T2jqi9yZtEYNpyo8eWXOLUxU7qpevo/JsbDXxfyfVkLMIGRwvjs2vWY/xyZ4uxlb5nBRtnoEeY/Vz fNXHgwNNCn0CkkC50pTDfRy/lp82nWMy/ehsqAnHAvFgetp5EfxO9fCtX3g4dO9VR1FE8nvUlZ7sr Bn2IZGGGDInHvCbndLjrJ6PQb82695qmeQv5WYiqTsI+D4GBDKWySAoA5Hwf+wgeENaCSuuQq68TP +CCtbJiQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1l55YF-0003Z2-KG; Thu, 28 Jan 2021 11:33:27 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1E9BF300B22; Thu, 28 Jan 2021 12:33:26 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id EF281200D4EEC; Thu, 28 Jan 2021 12:33:25 +0100 (CET) Date: Thu, 28 Jan 2021 12:33:25 +0100 From: Peter Zijlstra To: Alexander Sverdlin Cc: Paul Burton , linux-mips@vger.kernel.org, Thomas Bogendoerfer , Will Deacon , Boqun Feng , Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/6] MIPS: Octeon: Implement __smp_store_release() Message-ID: References: <20210127203627.47510-1-alexander.sverdlin@nokia.com> <20210127203627.47510-2-alexander.sverdlin@nokia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 28, 2021 at 08:27:29AM +0100, Alexander Sverdlin wrote: > >> +#define __smp_store_release(p, v) \ > >> +do { \ > >> + compiletime_assert_atomic_type(*p); \ > >> + __smp_wmb(); \ > >> + __smp_rmb(); \ > >> + WRITE_ONCE(*p, v); \ > >> +} while (0) > > This is wrong in general since smp_rmb() will only provide order between > > two loads and smp_store_release() is a store. > > > > If this is correct for all MIPS, this needs a giant comment on exactly > > how that smp_rmb() makes sense here. > > ... the macro is provided for Octeon only, and __smp_rmb() is actually a NOP > there, but I thought to "document" the flow of thoughts from the discussion > above by including it anyway. Random discussions on the internet do not absolve you from having to write coherent comments. Especially so where memory ordering is concerned. This, from commit 6b07d38aaa52 ("MIPS: Octeon: Use optimized memory barrier primitives."): #define smp_mb__before_llsc() smp_wmb() #define __smp_mb__before_llsc() __smp_wmb() is also dodgy as hell and really wants a comment too. I'm not buying the Changelog of that commit either, __smp_mb__before_llsc should also ensure the LL cannot happen earlier, but SYNCW has no effect on loads. So what stops the load from being speculated?