Re: [PATCH v2 0/3] s390/livepatch: Implement reliable stack tracing for the consistency model

From: Heiko Carstens
Date: Thu Oct 31 2019 - 11:25:02 EST


On Wed, Oct 30, 2019 at 11:12:00AM +0100, Miroslav Benes wrote:
> On Tue, 29 Oct 2019, Heiko Carstens wrote:
>
> > On Tue, Oct 29, 2019 at 03:39:01PM +0100, Miroslav Benes wrote:
> > > - I tried to use the existing infrastructure as much as possible with
> > > one exception. I kept unwind_next_frame_reliable() next to the
> > > ordinary unwind_next_frame(). I did not come up with a nice solution
> > > how to integrate it. The reliable unwinding is executed on a task
> > > stack only, which leads to a nice simplification. My integration
> > > attempts only obfuscated the existing unwind_next_frame() which is
> > > already not easy to read. Ideas are definitely welcome.
> >
> > Ah, now I see. So patch 2 seems to be leftover(?). Could you just send
> > how the result would look like?
> >
> > I'd really like to have only one function, since some of the sanity
> > checks you added also make sense for what we already have - so code
> > would diverge from the beginning.
>
> Ok, that is understandable. I tried a bit harder and the outcome does not
> look as bad as my previous attempts (read, I gave up too early).
>
> I deliberately split unwind_reliable/!unwind_reliable case in "No
> back-chain, look for a pt_regs structure" branch, because the purpose is
> different there. In !unwind_reliable case we can continue on a different
> stack (if I understood the code correctly when I analyzed it in the past.
> I haven't found a good documentation unfortunately :(). While in
> unwind_realiable case we just check if there are pt_regs in the right
> place on a task stack and stop. If there are not, error out.
>
> It applies on top of the patch set. Only compile tested though. If it
> looks ok-ish to you, I'll work on it.

Yes, that looks much better. Note, from a coding style perspective the
80 characters per line limit is _not_ enforced on s390 kernel code; so
that might be a possibility to make the code a bit more readable.

Also it _might_ make sense to split the function into two or more
functions (without duplicating code). Not sure if that would really
increase readability though.

FWIW, I just applied your first patch, since it makes sense anyway.