Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5140285pxb; Wed, 26 Jan 2022 05:47:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgG1sqHbrw1L+eda0xaIQ3w44FDthalhDe2iW+XAVDY9FAlEQP4omrfzVQ8JCOPvLgNX0f X-Received: by 2002:a17:902:b083:b0:14a:f06c:aa6b with SMTP id p3-20020a170902b08300b0014af06caa6bmr23229389plr.147.1643204868646; Wed, 26 Jan 2022 05:47:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643204868; cv=none; d=google.com; s=arc-20160816; b=txeAWCV6g4Bvy85lHUOpLLb7C7I1Ax0YtZSMM4wiPmXbTOTQB7Vt1HoKWLoFaXaW5e uvEak9jvnojICEXORjoavScUvcXrsVBdSHHX5H7mBr4XYVdEvKeoGVT+gMULRrEkHDkB McToyo/nFmqU1P1BvRr/6YxA4x0X/qN7OqqF2RJDC4Q+DeXAheaNWIt5ggJlEtpjEdRk XQNm3jGDxjqLYar9Qo5dO55tBiDfwfjS5ht5IhIX56LGhpQ0V/tMdeuW15LngMteGOsv 1SJGrcsYiXzK25ATT+nJRGRsf+XpFz2isW7sSlRTbmdDT6bC3y44yw0u8HXKqtRa7zdU g31w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=z71P7Xp5dv6WjZqQ3zBgUE6e/dyCl8Gv6LZSgzhmEF0=; b=z1dfS+C6IMoR7DZ36JwW2dWXMSeqr/wxsDVjnrbazdzjGwYJj/SQQL3xDVSwFRqKcm 0nU/OZIjJvZBVP6cBmOBc3MevhJ95BD8fOhMb5ma6pfGeVtiOtIXlwz8Z2KusfWRyy+l y9tA0rIoCYsoMqLoDeqCaAF/RuWXQJox6ZDflJ5zP6wpcxCXXvOelWtPZVQOnsIQEJv8 Vu6g1KISvh7vcF75YvRmuIjC8WhCcnpj/4NG4itc225/96oVI3oqBWezaXDwSR6kbMlG KfBUWE117TrilR3AfoO8cbTNEmdI42OQ0DdZPUYbsBNBm3BCbCGAR1h/38gH28nU51sm b+ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YxkcuAon; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mw17si3275167pjb.168.2022.01.26.05.47.35; Wed, 26 Jan 2022 05:47:48 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20210112 header.b=YxkcuAon; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235480AbiAZA73 (ORCPT + 99 others); Tue, 25 Jan 2022 19:59:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235472AbiAZA71 (ORCPT ); Tue, 25 Jan 2022 19:59:27 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03A92C06173B for ; Tue, 25 Jan 2022 16:59:26 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id x7so59990711lfu.8 for ; Tue, 25 Jan 2022 16:59:26 -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=HaEt3lXQgjCXmUXO5NuBJ35hRFkBfjDTTjH66E4zCRSoO0elUg4VdpVLRCyP9DJvfY BuMEKUUFG38Wva1Kh0dCglkKwBQYm2n1uREP9Q0f5OhhXTv6StGgX1QMd5gOEUehA1WM IG4SYqh5DubuzsZJZk0SCakKV/H+zTjxLjVR9dq8kSgSVj67giLw5x6OFkcJEFXvEiWg mTwui1KTw0Bg00zFrEiytUJa1pPhpu5baPOj2lhG/ByG/3+t6XCnTJb7G95uDOnfZb+5 yOeT21wMPooNua2bOUTqHMoUF43P3Wl/e7JKRopG5P7SsgCqNMivx1aSc08Pdpsu04dW SI9w== X-Gm-Message-State: AOAM531D+tO8Mdkw7NrgxfyrlGp66cN6I2tvrGh+RCTxQ2n7Mh6OQ8N3 kIREqOAQQn4tt5ksy/oVP4MocKbcH7IAH3rK48s7DA== X-Received: by 2002:a05:6512:b0d:: with SMTP id w13mr18623372lfu.240.1643158765067; Tue, 25 Jan 2022 16:59:25 -0800 (PST) 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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