Re: [PATCH 1/3] sched: add sched_task_call()

Jiri Kosina
2015-02-20T07:46:56Z

On Thu, 19 Feb 2015, Josh Poimboeuf wrote:

> So I've looked at kgr_needs_lazy_migration(), but I still have no idea
> how it works.
>
> First of all, I think reading the stack while its being written to could
> give you some garbage values, and a completely wrong nr_entries value
> from save_stack_trace_tsk().

I believe we've already been discussing this some time ago ...

I agree that this is a very crude optimization that should probably be
either removed (which would only cause slower convergence in the presence
of CPU-bound tasks), or rewritten to perform IPI-based stack dumping
(probably on a voluntarily-configurable basis).

Reading garbage values could only happen if the task would be running in
kernelspace. nr_entries would then be at least 2.

But I agree that relying on this very specific behavior is not really
safe in general in case someone changes the stack dumping implementation
in the future in an unpredictable way.

> But also, how would you walk a stack without knowing its stack pointer?
> That function relies on the saved stack pointer in
> task_struct.thread.sp, which, AFAICT, was last saved during the last
> call to schedule(). Since then, the stack could have been completely
> rewritten, with different size stack frames, before the task exited the
> kernel.

Same argument holds here as well, I believe.

Thanks,

--
Jiri Kosina
SUSE Labs