Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4317378ybl; Mon, 13 Jan 2020 11:33:29 -0800 (PST) X-Google-Smtp-Source: APXvYqylw8llQWh3GDXlpqpTUyJXKzTGDiqqsyJCIGyRR7DQEtlWS2TI7SYsYSONs5whGkC4uCUQ X-Received: by 2002:aca:c551:: with SMTP id v78mr14217991oif.161.1578944009346; Mon, 13 Jan 2020 11:33:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578944009; cv=none; d=google.com; s=arc-20160816; b=UsCSRF+7Uj28abZ9VPcBbZ2+g5VN9uGESihKwjPy1REHoa98FM9BZIE+YssVQMwiLI kqZBEs3R9HwcS240xIA72FV3yQzYyJEs/Qwvb5QEkRJkgaT5TK7v5CjqGpdKSDzQIqMO XigbkJr37wE6Xga2eGrsrU2stCVFbpzUCsIErIGBOoFHC9DLoL4OjPRIZwZHa5HJfr58 RdqGUazc60GqBt0L0DqFMI/Mh/1os1Z35RX5sdTgX57FMm3iwNdlR8Kp3IB9steqq+W3 bQrZBNx3yKj+4uhOurV9ym+1SgYCAVBTGfLYlAL67p5qol1dzQhEJsNyBbUbfaku6Z5i IPAw== 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:dkim-signature; bh=Ae/+DIZn8QK4Eu0S9kiQGO5TqvMJzTIQ/bcHyd6r6aQ=; b=TQVodNwqjmGJ+Z7blnbsGwmo0g0uopzgZYfIAqTRCCFR1c2j3H6YDGYXfQ4ojz1k32 LXHcrh4NdtiflsHzcWOxzv2H4cNI38kljsEeTTQGdRkCeAFnSFvtIXMSvMB2HN4XIyHM ES1Qc9DzKBXBtDoOVK3hDVhNXPPLFJXIMG9MNquqQIwBQnojtMh4+cob2RBRaWdnIDgR 11jOG6JDiso2OoVEiWbA3qt8IPYFfFjNAg3H0HXlIq8x7ZM20uTLvWk59Yy4N2BUGukH xva5f0YBT6Ji7VIWR8CSOz0hjN3NvRmOtmRVP+K4lpQfPG2aRo4WS/lgC0F3k1ZgMM2X /U1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=dsTuRrPn; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si6877349oth.182.2020.01.13.11.33.17; Mon, 13 Jan 2020 11:33:29 -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=@linux-foundation.org header.s=google header.b=dsTuRrPn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728682AbgAMTcS (ORCPT + 99 others); Mon, 13 Jan 2020 14:32:18 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44111 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728641AbgAMTcR (ORCPT ); Mon, 13 Jan 2020 14:32:17 -0500 Received: by mail-lf1-f65.google.com with SMTP id v201so7766859lfa.11 for ; Mon, 13 Jan 2020 11:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ae/+DIZn8QK4Eu0S9kiQGO5TqvMJzTIQ/bcHyd6r6aQ=; b=dsTuRrPnmRxjK6yre9iMf8gYcDE0hjJkuaJ2eT9ghACf2vMogI+i+ZMgu9tiR3PjxB uzQhEdyjiSlebYb6SLrus5AR2u6J5fDcOnswpR5Vfnatgy1xjOGHGAsOhngu0riP6Xcw 2ZfyA9EtBicLF7bVKr8HK+hd9gJ6oiCIwVO50= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ae/+DIZn8QK4Eu0S9kiQGO5TqvMJzTIQ/bcHyd6r6aQ=; b=AZNSENZIzBX4/sFzdHTeSGRYwYQo6SkPyJ+5mbkAEuwGkBeWz/25LRY5UYQtrWqI5+ cS3nA9/4egu1p0TxLQ2mrTDWVkW1lZgnWxr+vNDQbsm0T7KXqOEqX7kG30heZCFjaiVi zq2UW+CljqYI8HPONfqPKhbh2YCfC13xRlEtv74oCXHt/Fb5rwA7ab1b3alQe0b8XLXi tIdg4I5JW6pk7A2swCsuora/3rrfrOwYVsF+AW2pLp8613q4eLSg9Tv7S+BBvH1Id7iz VgDei+ctZdA1WiXbTXhXjgwlx5TT2Ku0XpIUFz5djog1tvau7/ZJLCG/SDeHjPjjp+aX PTlA== X-Gm-Message-State: APjAAAXUkzUOI+sfS/GaOKQz/F4M8BJRvuk/JlX1hoCxen/LMXPpX2Ad vkJUDVFn3bu0Sv+qG/hmua3bZHZoWgc= X-Received: by 2002:a19:c205:: with SMTP id l5mr9770364lfc.159.1578943934607; Mon, 13 Jan 2020 11:32:14 -0800 (PST) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com. [209.85.208.170]) by smtp.gmail.com with ESMTPSA id x23sm6110478lff.24.2020.01.13.11.32.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2020 11:32:13 -0800 (PST) Received: by mail-lj1-f170.google.com with SMTP id w1so11461323ljh.5 for ; Mon, 13 Jan 2020 11:32:13 -0800 (PST) X-Received: by 2002:a05:651c:282:: with SMTP id b2mr12034973ljo.41.1578943932792; Mon, 13 Jan 2020 11:32:12 -0800 (PST) MIME-Version: 1.0 References: <20200110165636.28035-1-will@kernel.org> <20200110165636.28035-7-will@kernel.org> <20200113145954.GB4458@willie-the-truck> In-Reply-To: <20200113145954.GB4458@willie-the-truck> From: Linus Torvalds Date: Mon, 13 Jan 2020 11:31:56 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 6/8] READ_ONCE: Drop pointer qualifiers when reading from scalar types To: Will Deacon Cc: Linux Kernel Mailing List , linux-arch , Android Kernel Team , Michael Ellerman , Peter Zijlstra , Segher Boessenkool , Christian Borntraeger , Luc Van Oostenryck , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 13, 2020 at 7:00 AM Will Deacon wrote: > > I can't disagree with that, but the only option we've come up with so far > that solves this in the READ_ONCE() macro itself is the thing from PeterZ: > > // Insert big fat comment here > #define unqual_typeof(x) typeof(({_Atomic typeof(x) ___x __maybe_unused; ___x; })) I'm with Luc on this - that not only looks gcc-specific, it looks fragile too, in that it's not obvious that "_Atomic typeof(x)" really is guaranteed to do what we want. > So I suppose my question is: how ill does this code really make you feel? I wish the code was more obvious. One way to do that might be to do your approach, but just write it as a series of macros that makes it a bit more understandable what it does. Maybe it's just because of a "pee in the snow" effect, but I think this is easier to explain: #define __pick_scalar_type(x,type,otherwise) \ __builtin_choose_expr(__same_type(x,type), (type)0, otherwise) #define __pick_integer_type(x, type, otherwise) \ __pick_scalar_type(x, unsigned type, \ __pick_scalar_type(x, signed type, otherwise)) #define __unqual_scalar_typeof(x) typeof( \ __pick_integer_type(x, char, \ __pick_integer_type(x, short, \ __pick_integer_type(x, int, \ __pick_integer_type(x, long, \ __pick_integer_type(x, long long, x)))))) just because you there's less repeated noise, and the repetition there is is simpler. So still "Eww", but maybe not quite _as_ "Eww". Linus