Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1345403ybt; Thu, 2 Jul 2020 03:09:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygoU2lmGiqGBCEmrsR/oIQ4qtR1JGsdj34cVxF8TaP037y3CgUwXNzQ1yfV8F1bNGeUwq1 X-Received: by 2002:a17:907:4003:: with SMTP id nj3mr25090406ejb.278.1593684577117; Thu, 02 Jul 2020 03:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593684577; cv=none; d=google.com; s=arc-20160816; b=IkeL7H5uj70rQkt0SEepCfQQwqSZTDQzfGuV8vkN3hfHWSz3vxrfXTmK+tGPRjcut9 xe+9dh88SCtuDkNxyrQOrIEDDC1Ay7nDj7eVJ2Mf+U91Cswofo6AtgpH+y85wvb8G+Eq dPWgiIXV/Ou4aExAzTe5zjeXJx2h70uZUT2Mop5lBo/8oo9SGSaIFu5eWGLvwUZgcBDw FioJ5Msug+e48UDt5+K1LhQhdmz1GjBp9NWYaH8H8lmpxq0HAiffk0hAlTptWeyJ59Pv I2O59X8VvVaaF143LBHRPLbs9PVCvltz4e0qOMr+kVjFuUII/qHDFAEZ+7Ev5q6o3BJY fOFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=ggAhl6q07VFVl7F+zXXT7VpzFzImCojbAl9MSX5kTXc=; b=aR0Ez1I/M0aWa1vr5pVYCxurHOIPEhWiCcBkVQk5GO35wfKReZm3+DCgqTRpJhO280 8GEH6sVlFrXSVBtg0Mgibu3rFBOX1tYCjEoCFqqNTHY/i6zNa1ozRzdqrtVVIM7BshRw /3XCzdFtwWmIHzZyJkCfioVBRcZ1QnlQxgs3Qh4T/hbFVs4b0bn8cmJXwP5unFeymHvD dYD4px/qxVhQbDIqDZK/o+rV7OI+FI83enZEBpAG0rCxGdqtcdnZvbjUW5ET/d4LwUcj uWN9yH5wLNvmVrhi+4OP5FmAeH/a/vf3exDjzkvyOk7hEEyizr52q7vhqa1XgTxU45PG 1oYg== ARC-Authentication-Results: i=1; mx.google.com; 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 t13si5674931edj.100.2020.07.02.03.09.13; Thu, 02 Jul 2020 03:09:37 -0700 (PDT) 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; 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 S1727921AbgGBKJA (ORCPT + 99 others); Thu, 2 Jul 2020 06:09:00 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:54637 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727057AbgGBKJA (ORCPT ); Thu, 2 Jul 2020 06:09:00 -0400 Received: from mail-qk1-f180.google.com ([209.85.222.180]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPSA (Nemesis) id 1MW9zm-1jKVqS3CQM-00XYGX; Thu, 02 Jul 2020 12:08:58 +0200 Received: by mail-qk1-f180.google.com with SMTP id 80so25055449qko.7; Thu, 02 Jul 2020 03:08:58 -0700 (PDT) X-Gm-Message-State: AOAM531PkRDYUMsbMGZyVS7rRI1yUby9/+mxlfVN/Tpre4DVwxWWZpaK BJ2BXm+ESDFTHm29CjFdKBGv57qrQhJ1UAd3e1I= 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 Cc: Mark Rutland , "linux-kernel@vger.kernel.org" , Sami Tolvanen , Nick Desaulniers , Kees Cook , Marco Elver , "Paul E. McKenney" , Josh Triplett , Matt Turner , Ivan Kokshaysky , Richard Henderson , Peter Zijlstra , Alan Stern , "Michael S. Tsirkin" , Jason Wang , Boqun Feng , Catalin Marinas , Linux ARM , alpha , virtualization@lists.linux-foundation.org, Android Kernel Team Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:mak3dDZGE897vFH26+b5q7gq+C9l0V+pMqglMWHu/Q3+hoWWsQL xPZsW2vJLjdnX0ffEaN+PZA5LvLOVs3+tb35xMqpgv7Uu57I/nY/ocnByKIJ0KVUghpM9sn iqdQHunTum1PIsvRdRJtHU5arZEvkrIIet19DkYGTwksXPgcyoa4jr67S9xe6Ak0a1e66vS Trp6IMhJR7WwpddXYowLA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:7+KeRQCHiCM=:yeMFSuZ4NMCzmVlkyLf4eP V1i9z4kDSFbhrvkjg3nEvwolq9WxGBAMZBOmhWxv2zS/uhU1r+w7YsTvSbx8R9A93vzHmPiWp PD1DyGCHL3oQZ6gpaTgLMRJ2bi2e6LQqi5ryq+mTA1jOY0+Br6P5MdIeYdJfm8dQg1H65MTXQ ehwy5QEtN/FWWd/ILZfki1w7i8APiy8x7zZSi7x2bFqKy/C+2aN0ALldLuntBKWAGWZef3UcX Y3W4EKHp5lUurDgRi6HtR6MsnfMykmovV+PHa0t1WBot0SEhFgVjdCG/RpIpChW+nQYf2QJZf g4tVY5uG0AvU3dOicuCBZlDlN++6Ct49N81rFX+nojmEbUTf6Jz00j/qs4T90b7hGPavxve9P WpmURyeuMqZW4o0sa2r+ImUQG7Vh/z2ivJneyKUgShBIPO5sbGnUtWUjR4b0zq6+r51TezSw3 qTQT0Cn30sPcQcLjISuoY6Vl4do7qNoI8nEShFwj3liWRJuETYrWQpzVuIJTshsN1jviKFkZ9 uo3jl0yZKMsr9YknI2LAnlA0SPgGRUiGamDMtePsFy3KPtdXN9oNnap9IR7x2ixmhgzcz+ibj BBmPfO5vAhh0yFqCcxOBKfMsubG1FWUrXod1cHEnmnwwT0gM3IzaXFmB96uP0J7LYl7FRMha0 XIqyUqhfmpcDL3ijIGWqBzuHZNnKiotti3pG0Bh1jzNhnBvq5bHdS6TfPYR0D7/Vk2W0h6Sug Ya4RpMI4FiakX2NWROb+I8Po4vnwhEfsOOvsRA90DSlMDH5i1l7EiiOf0sderst9S7EDwzqrb KHeGoOVEiNQa5gBB3+WeFZm4nQWoWnf3qiXrbUKgxrW/3Oad7I= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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