Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp921556ybl; Fri, 10 Jan 2020 08:57:54 -0800 (PST) X-Google-Smtp-Source: APXvYqxuDv+1NawuaaoZSdHRARvlduZ9HoB24p5zwC9fKjy5GAt/sMfncDVk5Ss6aB106/Skobq2 X-Received: by 2002:a9d:600e:: with SMTP id h14mr3203152otj.113.1578675474764; Fri, 10 Jan 2020 08:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578675474; cv=none; d=google.com; s=arc-20160816; b=i6DFwWKuLgE5F9SBs5hFBU/eciDMTi8xo0kbGF5u3N5/56XfeWk+Hrd2Cuil2xXUpy MRc16Ym1E5ms61fqYeIUVkSV/m4wq+MGDuGZN0PijgCQC8q3QjP6szJf4wrR289Xwpnm VL9aPPwWfeCXZy41TkST0aJ+9ImZs2uZhSHN311FZdmLS/bEczTAOpEyqbXb33xLoMDl 7YTmVRp+eW30VRAtsrbUj7DYT2rN9+ZtbpFIsIvPjkEZcY7Bp/0vr2wN4PAwbnhTj2IB lTQQe3/aEAzydf4STeqzdn8iT1Djr/Jm9E/O3jILrQBdBI45DXYshG7reK+CTG0xVy/X J2ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Z/5m2wqgrwBuYpEVpLckopKsMVekxMrKKfDhnzTQino=; b=xKKf6kpBIySdLWxIBucgsiw6mR6osOHjITokiKwnj8HFv5M8ZRWWli7ku7MpTzHiob 1aVcm3Dv2NK3zNXSGtDSz95Bp+Vof/ltefs1iud1LGWUwP18Mvqnj8XeH0EIoNqmwDCw z1azjg6sLXZYU4LWbiO4nUMQiDeZGXCGqLktOe2YqlhLaMuv8c2d7Rw9zIE+WYLxOCSD tff0ty85Zi36XjWk0v5iTvs2IodPne8+4iculfHyV+jUXdKl5KgtNkIz19AdWuBoddz7 3L/N/xp+hRA7+MrUCUs4/vHe3tNySqk3Biznvn/YOFAvDbdGwDsyVLxmPITEy8h10u8G ku9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X4UT9RPA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q190si1494993oic.187.2020.01.10.08.57.43; Fri, 10 Jan 2020 08:57:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X4UT9RPA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728520AbgAJQ4n (ORCPT + 99 others); Fri, 10 Jan 2020 11:56:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:59760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728258AbgAJQ4n (ORCPT ); Fri, 10 Jan 2020 11:56:43 -0500 Received: from localhost.localdomain (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 607E420673; Fri, 10 Jan 2020 16:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578675402; bh=MQzjT+4UNkiT5W8ykZAsZf6C5Tt67H5NykUo1q89FP8=; h=From:To:Cc:Subject:Date:From; b=X4UT9RPAMeLriDGh6EfbNvW3/fjCjnbZPO/TDvhugb9w93o3OZcNwqU/nCwD0Geeu Fl5bLp6WG/Uiid4ppfGpYawoLgsEFQZ7IP1cfKCpGgFsu5QHCzmTYL47iGwJPM/5Cv ybumkMugp77TRn9eSdBpVsgoXSIFvKiM2HhRJ/0A= From: Will Deacon To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, kernel-team@android.com, Will Deacon , Michael Ellerman , Peter Zijlstra , Linus Torvalds , Segher Boessenkool , Christian Borntraeger , Luc Van Oostenryck , Arnd Bergmann Subject: [RFC PATCH 0/8] Rework READ_ONCE() to improve codegen Date: Fri, 10 Jan 2020 16:56:28 +0000 Message-Id: <20200110165636.28035-1-will@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, This is a follow-up RFC to the discussions we had on the mailing list at the end of last year: https://lore.kernel.org/lkml/875zimp0ay.fsf@mpe.ellerman.id.au Unfortunately, we didn't get a "silver bullet" solution out of that long thread, but I've tried to piece together some of the bits and pieces we discussed and I've ended up with this series, which does at least solve the pressing problem with the bitops for arm64. The rough summary of the series is: * Drop the GCC 4.8 workarounds, so that READ_ONCE() is a straightforward dereference of a cast-to-volatile pointer. * Require that the access is either 1, 2, 4 or 8 bytes in size (even 32-bit architectures tend to use 8-byte accesses here). * Introduce __READ_ONCE() for tearing operations with no size restriction. * Drop pointer qualifiers from scalar types, so that volatile scalars don't generate horrible stack-spilling mess. This is pretty ugly, but it's also mechanical and wrapped up in a macro. * Convert acquire/release accessors to perform the same qualifier stripping. I gave up trying to prevent READ_ONCE() on aggregates because it is pervasive, particularly within the mm/ layer on things like pmd_t. Thankfully, these don't tend to be volatile. I have more patches in this area because I'm trying to move all the read_barrier_depends() magic into arch/alpha/, but I'm holding off until we agree on this part first. Cheers, Will Cc: Michael Ellerman Cc: Peter Zijlstra Cc: Linus Torvalds Cc: Segher Boessenkool Cc: Christian Borntraeger Cc: Luc Van Oostenryck Cc: Arnd Bergmann --->8 Will Deacon (8): compiler/gcc: Emit build-time warning for GCC prior to version 4.8 netfilter: Avoid assigning 'const' pointer to non-const pointer fault_inject: Don't rely on "return value" from WRITE_ONCE() READ_ONCE: Simplify implementations of {READ,WRITE}_ONCE() READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses READ_ONCE: Drop pointer qualifiers when reading from scalar types locking/barriers: Use '__unqual_scalar_typeof' for load-acquire macros arm64: barrier: Use '__unqual_scalar_typeof' for acquire/release macros arch/arm64/include/asm/barrier.h | 16 ++-- drivers/xen/time.c | 2 +- include/asm-generic/barrier.h | 16 ++-- include/linux/compiler-gcc.h | 4 + include/linux/compiler.h | 129 +++++++++++++------------------ include/linux/compiler_types.h | 15 ++++ lib/fault-inject.c | 4 +- net/netfilter/core.c | 2 +- net/xdp/xsk_queue.h | 2 +- 9 files changed, 93 insertions(+), 97 deletions(-) -- 2.25.0.rc1.283.g88dfdc4193-goog