From: Peter Zijlstra <peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
To: Josh Poimboeuf <jpoimboe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Jiri Slaby <jslaby-AlSwsSmVLrQ@public.gmane.org>,
Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>,
x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
live-patching-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Michal Marek <mmarek-AlSwsSmVLrQ@public.gmane.org>,
Andy Lutomirski <luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Borislav Petkov <bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org>,
Linus Torvalds
<torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
Andi Kleen <andi-Vw/NltI1exuRpAAqCnN02g@public.gmane.org>,
Pedro Alves <palves-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Namhyung Kim <namhyung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Bernd Petrovitsch
<bernd-JY8rjfDgnXcb9sJ47jD7nuTv7YV0F9Eg@public.gmane.org>,
Chris J Arges
<chris.j.arges-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
Arnaldo Carvalho de Melo
<acme-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
David Vrabel
<david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>,
Borislav Petkov <bp-l3A5Bk7waGM@public.gmane.org>,
Konrad Rzeszutek Wilk
<konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
Boris Ostrovsky
<boris.ostrovsky-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
Jeremy Fitzhardinge <jeremy-TSDbQ3PG+2Y@public.gmane.org>,
Chris Wright <chrisw-69jw2NvuJkxg9hUCZPvPmw@public.gmane.org>,
Subject: Re: [PATCH 00/33] Compile-time stack metadata validation
Date: Mon, 15 Feb 2016 17:49:52 +0100 [thread overview]
Message-ID: <20160215164952.GL6357@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20160215163134.GA20585-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
On Mon, Feb 15, 2016 at 10:31:34AM -0600, Josh Poimboeuf wrote:
> On Fri, Feb 12, 2016 at 09:10:11PM +0100, Peter Zijlstra wrote:
> > On Fri, Feb 12, 2016 at 12:32:06PM -0600, Josh Poimboeuf wrote:
> > > What I actually see in the listing is:
> > >
> > > decl __percpu_prefix:__preempt_count
> > > je 1f:
> > > ....
> > > 1:
> > > call ___preempt_schedule
> > >
> > > So it puts the "call ___preempt_schedule" in the slow path.
> >
> > Ah yes indeed. Same difference though.
> >
> > > I also don't see how that would be related to the use of the asm
> > > statement in the __preempt_schedule() macro. Doesn't the use of
> > > unlikely() in preempt_enable() put the call in the slow path?
> >
> > Sadly no, unlikely() and asm_goto don't work well together. But the slow
> > path or not isn't the reason we do the asm call thing.
> >
> > > #define preempt_enable() \
> > > do { \
> > > barrier(); \
> > > if (unlikely(preempt_count_dec_and_test())) \
> > > preempt_schedule(); \
> > > } while (0)
> > >
> > > Also, why is the thunk needed? Any reason why preempt_enable() can't be
> > > called directly from C?
> >
> > That would make the call-site save registers and increase the size of
> > every preempt_enable(). By using the thunk we can do callee saved
> > registers and avoid blowing up the call site.
>
> So is the goal to optimize for size?
General performance impact of preempt_enable().
> If I replace the calls to
> __preempt_schedule[_notrace]() with real C calls and remove the thunks,
> it only adds about 2k to vmlinux.
That's less than I had expected, but probably still worth it.
And is that added text purely in the slow path? We really want to avoid
putting any more register pressure on the preempt_enable() call sites.
The single memop and Jcc is about as fast we can get and we spend quite
a bit of effort getting there.
> There are two ways to fix the warnings:
>
> 1. get rid of the thunks and call the C functions directly; or
>
> 2. add the stack pointer to the asm() statement output operand list to
> ensure a stack frame gets created in the caller function before the
> call. (Note this still allows the thunks to do callee saved registers.)
>
> I like #1 better, but maybe I'm still missing the point of the thunks.
Ingo, Linus?
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-02-15 16:49 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-21 22:49 [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf
2016-01-21 22:49 ` [PATCH 25/33] x86/kvm: Set ELF function type for fastop functions Josh Poimboeuf
2016-01-22 10:05 ` Paolo Bonzini
2016-01-21 22:49 ` [PATCH 26/33] x86/kvm: Add stack frame dependency to test_cc() inline asm Josh Poimboeuf
2016-01-22 10:05 ` Paolo Bonzini
2016-01-22 16:02 ` Josh Poimboeuf
2016-01-22 16:16 ` [PATCH v16.1 26/33] x86/kvm: Make test_cc() always inline Josh Poimboeuf
2016-01-22 17:43 ` [PATCH 00/33] Compile-time stack metadata validation Chris J Arges
[not found] ` <20160122174348.GB29221-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2016-01-22 19:14 ` Josh Poimboeuf
[not found] ` <20160122191447.GH20502-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2016-01-22 20:40 ` Chris J Arges
[not found] ` <20160122204034.GA5826-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2016-01-22 20:47 ` Josh Poimboeuf
2016-01-22 21:44 ` [PATCH 0/2] A few stacktool warning fixes Chris J Arges
2016-01-22 21:44 ` [PATCH 1/2] tools/stacktool: Add __reiserfs_panic to global_noreturns list Chris J Arges
2016-01-25 15:04 ` Josh Poimboeuf
2016-01-22 21:44 ` [PATCH 2/2] x86/kvm: Add output operand in vmx_handle_external_intr inline asm Chris J Arges
2016-01-25 15:05 ` Josh Poimboeuf
2016-02-12 10:36 ` [PATCH 00/33] Compile-time stack metadata validation Jiri Slaby
2016-02-12 10:41 ` Jiri Slaby
2016-02-12 14:45 ` Josh Poimboeuf
2016-02-12 17:10 ` Peter Zijlstra
2016-02-12 18:32 ` Josh Poimboeuf
[not found] ` <20160212183206.GB29004-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2016-02-12 18:34 ` Josh Poimboeuf
2016-02-12 20:10 ` Peter Zijlstra
2016-02-15 16:31 ` Josh Poimboeuf
[not found] ` <20160215163134.GA20585-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2016-02-15 16:49 ` Peter Zijlstra [this message]
[not found] ` <CA+55aFzoPCd_LcSx1FUuEhSBYk2KrfzXGj-Vcn39W5bz=KuZhA@mail.gmail.com>
2016-02-15 20:01 ` Josh Poimboeuf
[not found] ` <CA+55aFzoPCd_LcSx1FUuEhSBYk2KrfzXGj-Vcn39W5bz=KuZhA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-15 20:02 ` Andi Kleen
2016-02-23 8:14 ` Ingo Molnar
[not found] ` <20160223081406.GA606-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-02-23 14:27 ` Arnaldo Carvalho de Melo
2016-02-23 15:07 ` Josh Poimboeuf
2016-02-23 15:28 ` Arnaldo Carvalho de Melo
2016-02-23 15:01 ` Josh Poimboeuf
2016-02-24 7:40 ` Ingo Molnar
[not found] ` <20160224074054.GA13199-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-02-24 16:32 ` Josh Poimboeuf
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=20160215164952.GL6357@twins.programming.kicks-ass.net \
--to=peterz-wegcikhe2lqwvfeawa7xhq@public.gmane.org \
--cc=acme-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=andi-Vw/NltI1exuRpAAqCnN02g@public.gmane.org \
--cc=bernd-JY8rjfDgnXcb9sJ47jD7nuTv7YV0F9Eg@public.gmane.org \
--cc=boris.ostrovsky-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org \
--cc=bp-l3A5Bk7waGM@public.gmane.org \
--cc=chris.j.arges-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
--cc=chrisw-69jw2NvuJkxg9hUCZPvPmw@public.gmane.org \
--cc=david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org \
--cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
--cc=jeremy-TSDbQ3PG+2Y@public.gmane.org \
--cc=jpoimboe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=jslaby-AlSwsSmVLrQ@public.gmane.org \
--cc=konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=live-patching-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=mmarek-AlSwsSmVLrQ@public.gmane.org \
--cc=namhyung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=palves-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
--cc=torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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).