Re: [PATCH v2 1/4] stacktrace: add interface based on shadow call stack

From: Andrey Konovalov
Date: Tue Apr 05 2022 - 16:18:39 EST


On Thu, Mar 31, 2022 at 11:19 AM Mark Rutland <mark.rutland@xxxxxxx> wrote:
>
> > Collecting stack traces this way is significantly faster: boot time
> > of a defconfig build with KASAN enabled gets descreased by ~30%.
>
> Hmm... just to check, do ou know if that's just because of hte linear copy, or
> because we're skipping other work we have to do in the regular stacktrace?

No, I haven't looked into this.

> > The implementation of the added interface is not meant to use
> > stack_trace_consume_fn to avoid making a function call for each
> > collected frame to further improve performance.
>
> ... because we could easily provide an inline-optimized stack copy *without*
> having to write a distinct unwinder, and I'd *really* like to avoid having a
> bunch of distinct unwinders for arm64, as it really hinders maintenance. We're
> working on fixing/improving the arm64 unwinder for things like
> RELIABLE_STACKTRACE, and I know that some of that work is non-trivial to make
> work with an SCS-based unwind rather than an FP-based unwind, and/or will
> undermine the saving anyway.

Responded on the cover letter wrt this.

> > +int stack_trace_save_shadow(unsigned long *store, unsigned int size,
> > + unsigned int skipnr)
> > +{
> > + /*
> > + * Do not use stack_trace_consume_fn to avoid making a function
> > + * call for each collected frame to improve performance.
> > + * Skip + 1 frame to skip stack_trace_save_shadow.
> > + */
> > + return arch_stack_walk_shadow(store, size, skipnr + 1);
> > +}
> > +#endif
>
> If we really need this, can we make it an __always_inline in a header so that
> we can avoid the skip? Generally the skipping is problematic due to
> inlining/outlining and LTO, and I'd like to avoid adding more of it
> unnecessarily.

Yes, I think this should work.

However, if we keep the implementation in mm/kasan, this integration
will not be required.

Thanks!