Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1334587

Re: [PATCH 00/33] Compile-time stack metadata validation

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 00/33] Compile-time stack metadata validation
Date 2016-02-15 17:40 +0100
Message-ID <r2ulR-3v3-27@gated-at.bofh.it> (permalink)
References (1 earlier) <r1jiO-5IA-19@gated-at.bofh.it> <r1ncL-8iz-17@gated-at.bofh.it> <r1pxW-1vA-49@gated-at.bofh.it> <r1qNl-2ew-27@gated-at.bofh.it> <r1sm5-3kI-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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?  If I replace the calls to
__preempt_schedule[_notrace]() with real C calls and remove the thunks,
it only adds about 2k to vmlinux.

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.

-- 
Josh

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 00/33] Compile-time stack metadata validation Jiri Slaby <jslaby@suse.cz> - 2016-02-12 11:40 +0100
  Re: [PATCH 00/33] Compile-time stack metadata validation Jiri Slaby <jslaby@suse.cz> - 2016-02-12 11:50 +0100
  Re: [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-12 15:50 +0100
    Re: [PATCH 00/33] Compile-time stack metadata validation Peter Zijlstra <peterz@infradead.org> - 2016-02-12 18:20 +0100
      Re: [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-12 19:40 +0100
      Re: [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-12 19:40 +0100
        Re: [PATCH 00/33] Compile-time stack metadata validation Peter Zijlstra <peterz@infradead.org> - 2016-02-12 21:20 +0100
          Re: [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-15 17:40 +0100
            Re: [PATCH 00/33] Compile-time stack metadata validation Peter Zijlstra <peterz@infradead.org> - 2016-02-15 18:00 +0100
            Re: [PATCH 00/33] Compile-time stack metadata validation Andi Kleen <andi@firstfloor.org> - 2016-02-15 21:10 +0100
            Re: [PATCH 00/33] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-15 21:10 +0100
              [PATCH] sched/x86: Add stack frame dependency to  __preempt_schedule[_notrace] Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-18 18:50 +0100
                Re: [PATCH] sched/x86: Add stack frame dependency to  __preempt_schedule[_notrace] Jiri Slaby <jslaby@suse.cz> - 2016-02-19 13:10 +0100

csiph-web