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 X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F050C433E0 for ; Thu, 2 Jul 2020 10:10:30 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C12620771 for ; Thu, 2 Jul 2020 10:10:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mCSYnMoC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C12620771 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PgX4s4eZXnB8RANsWS+oGqq+e9kSjMfib+lfqAnvpbM=; b=mCSYnMoC/o2q9hgb7NldedbTA 9i8us9fGUWAHvEtLhvXWUXoDsgImj2PsVzotpT4WFtxBpcpCtDWl/x1EM9If3uI1B/Aq8ikR1Ta7i x02giTRoOmY1UwijbZZEF1nU/eC/X5YtacCDk//sj0gIs06NXmN6xbbz/XE5eW5CTQXkR+Zk+wktn 2fHnZ7GHIUNK6pCIKhieH2jTcqcHFvIFxapQK2EdGzLKSmAhqL4TLL8hTApc60U07fA5OoUYcWRrs dEfwjvf23WzjpC0xS2qCyYzNmzTDKMIpLagMxltTkarNQ8uQbs5Nu/vHsKWwzvT9ikoL336RMNdMq drbDcKcew==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqw9T-0006Lt-2t; Thu, 02 Jul 2020 10:09:07 +0000 Received: from mout.kundenserver.de ([212.227.126.134]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqw9P-0006Kx-KA for linux-arm-kernel@lists.infradead.org; Thu, 02 Jul 2020 10:09:04 +0000 Received: from mail-qk1-f181.google.com ([209.85.222.181]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPSA (Nemesis) id 1M6lxe-1jjmTN3cly-008Jv4 for ; Thu, 02 Jul 2020 12:09:00 +0200 Received: by mail-qk1-f181.google.com with SMTP id 80so25055451qko.7 for ; Thu, 02 Jul 2020 03:08:58 -0700 (PDT) X-Gm-Message-State: AOAM532xVjmbV7H3EkQElOhskUvkyZZjtxTWnSMf1fD8pOxpEey+iUuv X2jjwOfqdZOnF7O/zmuVSsTtK/dJYbGTBqToBxs= X-Google-Smtp-Source: ABdhPJx5SOJMuDfQwJVKZB5+m6bRsdErAkrfs1PX1uiM9LM3hcJxJy3YrlJL+419fren+MgMc2n134OOOUrPQ10mHDg= X-Received: by 2002:a05:620a:1654:: with SMTP id c20mr22857877qko.138.1593684537553; Thu, 02 Jul 2020 03:08:57 -0700 (PDT) MIME-Version: 1.0 References: <20200630173734.14057-1-will@kernel.org> <20200630173734.14057-5-will@kernel.org> <20200702093239.GA15391@C02TD0UTHF1T.local> <20200702094833.GA16248@willie-the-truck> In-Reply-To: <20200702094833.GA16248@willie-the-truck> From: Arnd Bergmann Date: Thu, 2 Jul 2020 12:08:41 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 04/18] alpha: Override READ_ONCE() with barriered implementation To: Will Deacon X-Provags-ID: V03:K1:wiwkCbxiIr3bWj+B2ikJfr+D+gLoehJm2c59fnUS0GQ36P2LTFG PMXFanSNwACEdaLy6j8cjbP0ZhECY5O3wh6oDoNUMSDIm73YAXzm04z/DyqEc6s4bNf1XOs +falo0PRkIdzwTNk+w6NytWCSaIfh893entkP7uuSazxX//QC3w86W2i2dyUJRob8snIAzh VD3A7pEafxk1sFbB+AUMw== X-UI-Out-Filterresults: notjunk:1;V03:K0:+SReJDnK3tQ=:ocpjL8WCWUCm7olSXjyssm plL3vKu9qc1nS4FOYh9hwrO4Al0oUuINeWWs5hGzDEGYCZf5eFiKLt7HJ6RwvfS6VwlXtIa/x EhlXsLteLv/YuRCh4B8pTUBJQYHt2cujeLYMa7cr0+BdyQy1s/GnmJRO4eFFAx07wAnaricmW YsiwA9soI+6adWzC1qB60II3tjiZi7EdsLtEY52Z00BeNKD1ak/432izK87WgW6f6h2HFN0ob sRrz0KGz8tuHOMXaCNIYel6ROuwMNITReOjN9S9mIjnxG+em00XsjND1qQPFFClxa0Zk1zQ9/ kLE4+9+eEkGHwubZVpLYsNve2GvyFvmmFndO3DssqIyqDy2c0iNQcVwXcc0yPcob0UjsX/dKM EOsLw6hcPhd2gPD6QUPyorgxUjiDmU+h/7sGfMFgYZk4c4kTNLV8y9hGnLxmDz/BZkRGY4Bsf gV7AwCE2T05rNMOxb188PrgT4rYI7YCODuUKCgv6O9f4ucVWNTRhs4H4kQd+97OtZd1SesTRN cGCfhMnTO0fbOyDWsv9ywv8ZvNwRUe0Qd8L+Ya/6oiZyKShAMwAcVl77KJchMNI02DuvYGayC 3A9rWbME9yzWQmZybnULebfd40JQMuQ9EJv0CslFEi7aJQJuS9V+IInG0QbRMGoQDuC0YTrqe HEkaCtH4rrwJ98EhWqUCP7NGPe3/8Pce99S1+TtAncf067SnK4DjsM+qTKu2WWwqH8iAdHpGS IDLChYfxEj808Rv5AMKqlIxnUo3+Qy63Sy1KS4lpwT160udu9yfSvmjwySg3EZTa4UnXgmypS eVC02DgPLtelSq5DvZNWeCvOKZckzhp3aU1F49qaQ8ctUWfDoiBthhrAzKJU5YEGZ7gh9U+ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200702_060903_870078_8C6D5C41 X-CRM114-Status: GOOD ( 15.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Marco Elver , Kees Cook , "Paul E. McKenney" , "Michael S. Tsirkin" , Peter Zijlstra , Catalin Marinas , Jason Wang , Nick Desaulniers , "linux-kernel@vger.kernel.org" , Josh Triplett , Ivan Kokshaysky , Sami Tolvanen , alpha , Alan Stern , Matt Turner , virtualization@lists.linux-foundation.org, Android Kernel Team , Boqun Feng , Linux ARM , Richard Henderson Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jul 2, 2020 at 11:48 AM Will Deacon wrote: > On Thu, Jul 02, 2020 at 10:32:39AM +0100, Mark Rutland wrote: > > On Tue, Jun 30, 2020 at 06:37:20PM +0100, Will Deacon wrote: > > > -#define read_barrier_depends() __asm__ __volatile__("mb": : :"memory") > > > +#define __smp_load_acquire(p) \ > > > +({ \ > > > + __unqual_scalar_typeof(*p) ___p1 = \ > > > + (*(volatile typeof(___p1) *)(p)); \ > > > + compiletime_assert_atomic_type(*p); \ > > > + ___p1; \ > > > +}) > > > > Sorry if I'm being thick, but doesn't this need a barrier after the > > volatile access to provide the acquire semantic? > > > > IIUC prior to this commit alpha would have used the asm-generic > > __smp_load_acquire, i.e. > > > > | #ifndef __smp_load_acquire > > | #define __smp_load_acquire(p) \ > > | ({ \ > > | __unqual_scalar_typeof(*p) ___p1 = READ_ONCE(*p); \ > > | compiletime_assert_atomic_type(*p); \ > > | __smp_mb(); \ > > | (typeof(*p))___p1; \ > > | }) > > | #endif I also have a question that I didn't dare ask when the same code came up before (I guess it's also what's in the kernel today): With the cast to 'typeof(*p)' at the end, doesn't that mean we lose the effect of __unqual_scalar_typeof() again, so any "volatile" pointer passed into __READ_ONCE_SCALAR() or __smp_load_acquire() still leads to a volatile load of the original variable, plus another volatile access to ___p1 after spilling it to the stack as a non-volatile variable? I hope I'm missing something obvious here. Arnd _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel