Re: [PATCH v3 0/3] kasan, arm64, scs: collect stack traces from Shadow Call Stack

From: Mark Rutland
Date: Thu Apr 14 2022 - 10:56:38 EST


On Thu, Apr 14, 2022 at 01:36:59PM +0100, Mark Rutland wrote:
> As I suspected, you're hitting a known performance oddity with QEMU TCG
> mode where pointer authentication is *incredibly* slow when using the
> architected QARMA5 algorithm (enabled by default with `-cpu max`).

> This overhead has nothing to do with the *nature* of the unwinder, and
> is an artifact of the *platform* and the *structure* of the code.
> There's plenty that can be done to avoid that overhead

FWIW, from a quick look, disabling KASAN instrumentation for the
stacktrace object alone (with no other changes) has a significant impact
(compounded by the TCG QARMA5 slowdown), and I note that x86 doesn't
both instrumenting its stacktrace code anyway, so we could consider
doing likewise.

Atop that, replacing set_bit() with __set_bit() brings the regular
unwinder *really* close to the earlier SCS unwinder figures. I know that
the on_accessible_stack() calculations and checks could be ammortized
with some refactoring (which I'd planned to do anyway), so I think it's
plausible that with some changes to the existing unwinder we can bring
the difference into the noise.

> generic kasan w/ `-cpu max`
> ---------------------------
>
> master-no-stack-traces: 12.66
> master: 18.39 (+45.2%)
> master-no-stack-depot: 17.85 (+40.1%)
> up-scs-stacks-v3: 13.54 (+7.0%)

master-noasan: 15.67 (+23.8%)
master-noasan-__set_bit: 14.61 (+15.5%)

> Generic KASAN w/ `-cpu max,pauth-impdef=true`
> ---------------------------------------------
>
> master-no-stack-traces: 2.69
> master: 3.35 (+24.5%)
> master-no-stack-depot: 3.54 (+31.5%)
> up-scs-stacks-v3: 2.80 (+4.1%)

master-noasan: 3.05 (+13.0%)
master-noasan-__set_bit: 2.96 (+10.0%)

> Generic KASAN w/ `-cpu max,pauth=false`
> ---------------------------------------
>
> master-no-stack-traces: 1.92
> master: 2.27 (+18.2%)
> master-no-stack-depot: 2.22 (+15.6%)
> up-scs-stacks-v3: 2.06 (+7.3%)

master-noasan: 2.14 (+11.4%)
master-noasan-__set_bit: 2.10 (+9.4%)

Thanks,
Mark.