lkml.org 
[lkml]   [2015]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 12/21] sched: Add __schedule() to stackvalidate whitelist
On Fri, Jul 17, 2015 at 12:58:12PM -0700, Andy Lutomirski wrote:
> On Fri, Jul 17, 2015 at 12:46 PM, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Fri, Jul 17, 2015 at 11:47:28AM -0500, Josh Poimboeuf wrote:
> >> stackvalidate reports the following warnings for __schedule():
> >>
> >> stackvalidate: kernel/sched/core.o: __schedule()+0x3e7: duplicate frame pointer save
> >> stackvalidate: kernel/sched/core.o: __schedule()+0x424: sibling call from callable instruction with changed frame pointer
> >> stackvalidate: kernel/sched/core.o: __schedule()+0x431: call without frame pointer save/setup
> >> stackvalidate: kernel/sched/core.o: __schedule()+0x8b8: frame pointer state mismatch
> >> stackvalidate: kernel/sched/core.o: __schedule()+0x447: frame pointer state mismatch
> >>
> >> __schedule() is obviously a special case which is allowed to do unusual
> >> things with the frame pointer.
> >
> > Yes, but is the code actually correct? We can't dismiss the warnings
> > just on that basis alone.
>
> It's really only __switch_to that does weird things, right?

Yep, but context_switch() gets inlined and __switch_to() is a macro, so
it all ends up being __schedule().

> I kinda
> want to rework that thing anyway to have a well-defined saved state
> format anyway, which would have the nice benefit of letting us get rid
> of all the ret_from_fork crap.
>
> That is, we'd context switch like:
>
> static inline void __switch_to(...) {
> switch extra stuff;
> switch everything except gpregs;
> asm volatile ("call __switch_stack_and_ip" : [__sp thing goes here]
> : "S" (&prev->bottom_of_stack), "D" (&next->bottom_of_stack) :
> "basically all regs and flags");
> }
>
> Then the low level bit would be:
>
> __switch_stack_and_ip:
> pushq %rbp
> mov %rsp, (%rsi)
> mov (%rdi), %rsp
> popq %rbp
> ret
>
> Now, when we create a new task, we can set up its stack directly
> rather than setting some TI flag, because we actually know the layout.
>
> Hmm?

I've never really looked at the x86 details, but yes it would be good to
get rid of that fork special case.


\
 
 \ /
  Last update: 2015-07-17 23:21    [W:0.095 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site