From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EC6D173 for ; Wed, 26 Jan 2022 00:59:27 +0000 (UTC) Received: by mail-lf1-f50.google.com with SMTP id u6so28326849lfm.10 for ; Tue, 25 Jan 2022 16:59:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=z71P7Xp5dv6WjZqQ3zBgUE6e/dyCl8Gv6LZSgzhmEF0=; b=YxkcuAon8bS+2bQjPPNAgxM2rDMFd6aoPVQ/fcKh0AkzpcJfXxuJ4rLkJlfnjnRB8f jeHfmu0k5gmyMY/n9jdN0eW2fAudKR/84WqEBH2x69Bzcicm6s3a6JsQMK6w8lHb1Lps ZxHzEpYXnARrogT72+tdrulFexJ0VbmbUZZJrSH10PQQ+t0/rka4hI0pksA5MwDYyDgj /hzjVQmpPB+HbOh4PC+WQdi+1bMfs8etFyRfSdt6hag3sGL8Ls1pIETUseevlo0mMyNb 7MM7CcMS9skmdB687IiPvJNhetJiCiKab2IxnqwgGL9/qONMIm8qYYbGKF5r3ZO1fZgq QiQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z71P7Xp5dv6WjZqQ3zBgUE6e/dyCl8Gv6LZSgzhmEF0=; b=sc04+DPBtT2p04q4kES4AMXQG5pTrZJw4ckVn7zuCT4KrUMz9BUVI/dAtV0VHXGcK4 2aBglYKjJTsKpF+XReUa83sqH1FNUzc+lLnijrDsdf8H6uM0yju1Bj1UTBxA0GDF0SIh /HF43DyHDCaOZNraZcg/U1z2QoZ6yn5P3610zz21T9rY0oyMN8BNrdCsl3jIEEE4Xp2Z BWDAn0/yqC+VS1/EhlUUaWvn+uY/9vA0xBSpZqwRcwDoO/YS4+mxab3Yxa8449FViS6/ VCSiwvMlxeEP0tME5bbSft3M1WwlMVK0P0lQGnNQk229uhBZvcuP+H1a/UDQcjxmgnvn Dt3A== X-Gm-Message-State: AOAM532EKVkc3HzttJbAxizf9TOx5ERsVQfKHmlP1ZwxFW2tBio68ydh N59m/W/NVBBDMWdSiG8OPuT6MDTE/1RlmczD/gJIXw== X-Google-Smtp-Source: ABdhPJwy4V88GdNrO9tRchz5OfI8p/bCHIpaK5dAlNpQA1JPyiTKreaA0cOPcwZEMFUN2L3ofZuzU/IpAj8pZtAGgN0= X-Received: by 2002:a05:6512:b0d:: with SMTP id w13mr18623372lfu.240.1643158765067; Tue, 25 Jan 2022 16:59:25 -0800 (PST) Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20220114010526.1776605-1-ndesaulniers@google.com> <20220118192256.jzk5dnceeusq7x7u@treble> <20220118230120.pivvson7qekfiqic@treble> <20220125233128.GT614@gate.crashing.org> In-Reply-To: <20220125233128.GT614@gate.crashing.org> From: Nick Desaulniers Date: Tue, 25 Jan 2022 16:59:12 -0800 Message-ID: Subject: Re: [PATCH] objtool: prefer memory clobber & %= to volatile & __COUNTER__ To: Segher Boessenkool Cc: Josh Poimboeuf , Borislav Petkov , Vasily Gorbik , Linus Torvalds , Ingo Molnar , Dave Hansen , Thomas Gleixner , Peter Zijlstra , Luc Van Oostenryck , x86@kernel.org, llvm@lists.linux.dev, linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot , Nathan Chancellor , linux-toolchains@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Tue, Jan 25, 2022 at 3:34 PM Segher Boessenkool wrote: > > Hi! > > On Mon, Jan 24, 2022 at 03:26:36PM -0800, Nick Desaulniers wrote: > > > If this is fixed in gcc-10, then we can probably add a comment with a > > FIXME link to the issue or commit to replace __COUNTER__ with %= one > > day. If not, then we can probably come up with a reduced test case > > for the GCC devs to take a look at, then add the FIXME comment to > > kernel sources. > > Please open a PR? https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104236 > > I'm more confident that we can remove the `volatile` keyword (I was > > thinking about adding a new diagnostic to clang to warn that volatile > > is redundate+implied for asm goto or inline asm that doesn't have > > outputs) though that's not the problem here and will probably generate > > some kernel wide cleanup before we could enable such a flag. > > Its main value is that it would discourage users from thinking volatile > is magic. Seriously worth some pain! Yeah, SGTM. > > > Perhaps > > there are known compiler versions that still require the keyword for > > those cases for some reason. > > It was removed from compiler-gcc.h in 3347acc6fcd4 (which changed the > minimum required GCC version to GCC 5). ``` diff --git a/include/linux/compiler.h b/include/linux/compiler.h index e512f5505dad..b8fe0c23cfff 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -80,11 +80,25 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, /* Optimization barrier */ #ifndef barrier -# define barrier() __memory_barrier() +/* The "volatile" is due to gcc bugs */ +# define barrier() __asm__ __volatile__("": : :"memory") ``` I definitely wish there was a comment with a link to what "gcc bugs" they were referring to; otherwise who knows if it's been fixed...if they have been... -- Thanks, ~Nick Desaulniers