From: "H. Peter Anvin" <hpa@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
LKML <linux-kernel@vger.kernel.org>, gcc <gcc@gcc.gnu.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Thomas Gleixner <tglx@linutronix.de>,
David Daney <ddaney.cavm@gmail.com>,
Behan Webster <behanw@converseincode.com>
Subject: Re: [RFC] gcc feature request: Moving blocks into sections
Date: Mon, 12 Aug 2013 07:56:10 -0700 [thread overview]
Message-ID: <5208F78A.3000708@linux.intel.com> (raw)
In-Reply-To: <20130812091707.GB27162@twins.programming.kicks-ass.net>
On 08/12/2013 02:17 AM, Peter Zijlstra wrote:
>
> I've been wanting to 'abuse' static_key/asm-goto to sort-of JIT
> if-forest functions like perf_prepare_sample() and perf_output_sample().
>
> They are of the form:
>
> void func(obj, args..)
> {
> unsigned long f = ...;
>
> if (f & F1)
> do_f1();
>
> if (f & F2)
> do_f2();
>
> ...
>
> if (f & FN)
> do_fn();
> }
>
Am I reading this right that f can be a combination of any of these?
> Where f is constant for the entire lifetime of the particular object.
>
> So I was thinking of having these functions use static_key/asm-goto;
> then write the proper static key values unsafe so as to avoid all
> trickery (as these functions would never actually be used) and copy the
> end result into object private memory. The object will then use indirect
> calls into these functions.
I'm really not following what you are proposing here, especially not
"copy the end result into object private memory."
With asm goto you end up with at minimum a jump or NOP for each of these
function entries, whereas an actual JIT can elide that as well.
On the majority of architectures, including x86, you cannot simply copy
a piece of code elsewhere and have it still work. You end up doing a
bunch of the work that a JIT would do anyway, and would end up with
considerably higher complexity and worse results than a true JIT. You
also say "the object will then use indirect calls into these
functions"... you mean the JIT or pseudo-JIT generated functions, or the
calls inside them?
> I suppose the question is, do people strenuously object to creativity
> like that and or is there something GCC can do to make this
> easier/better still?
I think it would be much easier to just write a minimal JIT for this,
even though it is per architecture. However, I would really like to
understand what the value is.
-hpa
next prev parent reply other threads:[~2013-08-12 14:56 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-05 16:55 [RFC] gcc feature request: Moving blocks into sections Steven Rostedt
2013-08-05 17:02 ` H. Peter Anvin
2013-08-05 17:24 ` Steven Rostedt
2013-08-05 17:12 ` Linus Torvalds
2013-08-05 17:15 ` Linus Torvalds
2013-08-05 17:55 ` Steven Rostedt
2013-08-05 18:11 ` Steven Rostedt
2013-08-05 18:17 ` H. Peter Anvin
2013-08-05 18:23 ` Steven Rostedt
2013-08-05 18:29 ` H. Peter Anvin
2013-08-05 18:49 ` Steven Rostedt
2013-08-05 18:51 ` H. Peter Anvin
2013-08-05 19:01 ` Linus Torvalds
2013-08-05 19:54 ` Mathieu Desnoyers
2013-08-05 19:57 ` Linus Torvalds
2013-08-05 20:02 ` Steven Rostedt
2013-08-05 21:28 ` Mathieu Desnoyers
2013-08-05 21:43 ` H. Peter Anvin
2013-08-06 4:14 ` Mathieu Desnoyers
2013-08-06 4:28 ` H. Peter Anvin
2013-08-06 16:15 ` Steven Rostedt
2013-08-06 16:19 ` H. Peter Anvin
2013-08-06 16:26 ` Steven Rostedt
2013-08-06 16:29 ` H. Peter Anvin
2013-08-05 21:44 ` Steven Rostedt
2013-08-05 22:08 ` Mathieu Desnoyers
2013-08-05 19:09 ` Steven Rostedt
2013-08-05 18:20 ` Linus Torvalds
2013-08-05 18:24 ` Linus Torvalds
2013-08-05 18:34 ` Linus Torvalds
2013-08-05 18:38 ` H. Peter Anvin
2013-08-05 19:04 ` Steven Rostedt
2013-08-05 19:40 ` Marek Polacek
2013-08-05 19:56 ` Linus Torvalds
2013-08-05 19:57 ` Jason Baron
2013-08-05 20:35 ` Richard Henderson
2013-08-06 2:26 ` Jason Baron
2013-08-06 3:03 ` Steven Rostedt
2013-08-05 18:33 ` H. Peter Anvin
2013-08-05 18:39 ` Steven Rostedt
2013-08-05 18:49 ` Linus Torvalds
2013-08-05 19:39 ` Steven Rostedt
2013-08-06 14:19 ` Steven Rostedt
2013-08-06 17:48 ` Linus Torvalds
2013-08-06 17:58 ` Steven Rostedt
2013-08-06 20:33 ` Mathieu Desnoyers
2013-08-06 20:43 ` Steven Rostedt
2013-08-07 0:45 ` Steven Rostedt
2013-08-07 0:56 ` Steven Rostedt
2013-08-07 5:06 ` Ondřej Bílka
2013-08-07 15:02 ` Steven Rostedt
2013-08-07 16:03 ` Mathieu Desnoyers
2013-08-07 16:11 ` Steven Rostedt
2013-08-07 23:22 ` Mathieu Desnoyers
2013-08-05 20:06 ` Jason Baron
2013-08-05 19:04 ` Andi Kleen
2013-08-05 19:16 ` Steven Rostedt
2013-08-05 19:30 ` Xinliang David Li
2013-08-05 19:25 ` Linus Torvalds
2013-08-12 9:17 ` Peter Zijlstra
2013-08-12 14:56 ` H. Peter Anvin [this message]
2013-08-12 16:02 ` Andi Kleen
2013-08-12 16:11 ` Peter Zijlstra
2013-08-12 16:09 ` Peter Zijlstra
2013-08-12 17:47 ` H. Peter Anvin
2013-08-13 7:50 ` Peter Zijlstra
2013-08-13 14:46 ` H. Peter Anvin
2013-08-13 14:52 ` Steven Rostedt
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=5208F78A.3000708@linux.intel.com \
--to=hpa@linux.intel.com \
--cc=behanw@converseincode.com \
--cc=ddaney.cavm@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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).