linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: David Malcolm <dmalcolm@redhat.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	linux-toolchains@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Jason Baron <jbaron@akamai.com>,
	"Steven Rostedt (VMware)" <rostedt@goodmis.org>,
	yuanzhaoxiong@baidu.com
Subject: Re: static_branch/jump_label vs branch merging
Date: Thu, 22 Apr 2021 13:31:51 -0500	[thread overview]
Message-ID: <20210422183151.GD27473@gate.crashing.org> (raw)
In-Reply-To: <YIG3I+ojW+bc+o4l@hirez.programming.kicks-ass.net>

On Thu, Apr 22, 2021 at 07:49:23PM +0200, Peter Zijlstra wrote:
> On Thu, Apr 22, 2021 at 12:08:20PM -0500, Segher Boessenkool wrote:
> > On Thu, Apr 22, 2021 at 01:48:39PM +0200, Peter Zijlstra wrote:
> > > Can we please have a __pure__ attribute that is prescriptive and not a
> > > hint the compiler is free to ignore for $raisins ?
> > 
> > What does that mean?  What actual semantics do you want it to have?
> 
> I want a function marked as pure to be treated as such, unconditionally.
> 
> > The "pure" attribute means the compiler can assume this function does
> > not have side effects.  But in general (and in practice in many cases)
> > there is no way the compiler can actually check that, if that is what
> > you were asking for.
> 
> Right, so currently the pure attribute gets ignored by the compiler
> because of various reasons, one of them being an asm volatile ("") being
> present somewhere inside it (AFAIU).

In general, the compiler only sees the *declaration* of the function, so
it cannot do such a thing.

> Does this mean we can have invalid code generation when we faultily
> mark things pure? Yes, but then it's our own damn fault for sticking on
> pure in the first place.

Nope, you have undefined behaviour in that case, and you get to keep
all N pieces, the compiler cannot do anything wrong in such a case :-)

> In short; I want pure (or really_pure if you want a second attribute) to

You cannot make the meaning of "pure" different from what it has been
historically, because existing programs will no longer build (or worse,
start behaving differently).

> be a do-what-I-tell-you-already and not a
> only-if-you-think-you-can-prove-I-didn't-make-a-mistake kinda knob. A
> little bit like inline vs always_inline.

It sounds like you want it to behave like attribute((pure)) already is
documented as doing.  Please open a PR?  https://gcc.gnu.org/bugs.html
(We need buildable stand-alone example code, with what flags to use, and
something like what should happen and what did happen).

> > And any such checking will depend on optimisation level and related
> > flags, making that a no-go anyway.
> 
> Realistically I'm only bothered about -O2 and up since that's what we
> build the kernel with. Obviously one doesn't care about optimizations
> being lost when build with -O0.

GCC is used for other things as well, not just for building Linux ;-)


Segher

  reply	other threads:[~2021-04-22 18:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 16:52 static_branch/jump_label vs branch merging Peter Zijlstra
2021-04-09  9:57 ` Ard Biesheuvel
2021-04-09 10:55   ` Florian Weimer
2021-04-09 11:16     ` Peter Zijlstra
2021-04-09 19:33       ` Nick Desaulniers
2021-04-09 20:11         ` Peter Zijlstra
2021-04-10 17:02         ` Segher Boessenkool
2021-04-09 11:12   ` Peter Zijlstra
2021-04-09 11:55     ` David Malcolm
2021-04-09 12:03       ` Peter Zijlstra
2021-04-09 13:01         ` Peter Zijlstra
2021-04-09 13:13           ` Peter Zijlstra
2021-04-09 13:48             ` David Malcolm
2021-04-09 18:40               ` Peter Zijlstra
2021-04-09 19:21                 ` David Malcolm
2021-04-09 20:09                   ` Peter Zijlstra
2021-04-09 21:07                     ` David Malcolm
2021-04-09 21:39                       ` Peter Zijlstra
2021-04-22 11:48                         ` Peter Zijlstra
2021-04-22 17:08                           ` Segher Boessenkool
2021-04-22 17:49                             ` Peter Zijlstra
2021-04-22 18:31                               ` Segher Boessenkool [this message]
2021-04-26 17:13                                 ` Peter Zijlstra
2021-04-10 12:44               ` David Laight
2021-04-09 13:03 ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210422183151.GD27473@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=ardb@kernel.org \
    --cc=dmalcolm@redhat.com \
    --cc=jbaron@akamai.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=yuanzhaoxiong@baidu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).