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

Andrey Konovalov
2022-03-29T18:36:23Z

On Fri, Mar 25, 2022 at 9:46 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Wed, 23 Mar 2022 16:32:52 +0100 andrey.konovalov@linux.dev wrote:
>
> > From: Andrey Konovalov <andreyknvl@google.com>
> >
> > Add a new interface stack_trace_save_shadow() for collecting stack traces
> > by copying frames from the Shadow Call Stack.
> >
> > Collecting stack traces this way is significantly faster: boot time
> > of a defconfig build with KASAN enabled gets descreased by ~30%.
> >
> > The few patches following this one add an implementation of
> > stack_trace_save_shadow() for arm64.
> >
> > 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.
> >
> > ...
> >
> > @@ -108,4 +111,16 @@ static inline int stack_trace_save_tsk_reliable(struct task_struct *tsk,
> > }
> > #endif
> >
> > +#if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_SHADOW_STACKTRACE)
> > +int stack_trace_save_shadow(unsigned long *store, unsigned int size,
> > + unsigned int skipnr);
> > +#else
> > +static inline int stack_trace_save_shadow(unsigned long *store,
> > + unsigned int size,
> > + unsigned int skipnr)
> > +{
> > + return -ENOSYS;
> > +}
> > +#endif
>
> checkpatch sayeth "WARNING: ENOSYS means 'invalid syscall nr' and
> nothing else".

This is done deliberately to mimic stack_trace_save_tsk_reliable().
I'll mention this in the changelog.

> checkpatch also picked up a typo in a changelog. Useful thing to run,
> is checkpatch.

My bad, I ran it on diff instead of the patch. Will fix in v3. Thanks!