Re: [PATCH v2 0/6] Rework REFCOUNT_FULL using atomic_fetch_* operations
From: Kees Cook
Date: Wed Aug 28 2019 - 13:36:37 EST
On Tue, Aug 27, 2019 at 05:31:58PM +0100, Will Deacon wrote:
> Hi all,
>
> This is version two of the patches I previously posted here:
>
> https://lkml.kernel.org/r/20190802101000.12958-1-will@xxxxxxxxxx
>
> Changes since v1 include:
>
> * Avoid duplicate WARNs when incrementing from zero
> * Some crude lktdm perf results to motivate the change:
>
> # perf stat -r 3 -B -- echo {ATOMIC,REFCOUNT}_TIMING >/sys/kernel/debug/provoke-crash/DIRECT
>
> # arm64
> ATOMIC_TIMING: 46.50451 +- 0.00134 seconds time elapsed ( +- 0.00% )
> REFCOUNT_TIMING (REFCOUNT_FULL, mainline): 77.57522 +- 0.00982 seconds time elapsed ( +- 0.01% )
> REFCOUNT_TIMING (REFCOUNT_FULL, this series): 48.7181 +- 0.0256 seconds time elapsed ( +- 0.05% )
>
> # x86
> ATOMIC_TIMING: 31.6225 +- 0.0776 seconds time elapsed ( +- 0.25% )
> REFCOUNT_TIMING (!REFCOUNT_FULL, mainline/x86 asm): 31.6689 +- 0.0901 seconds time elapsed ( +- 0.28% )
> REFCOUNT_TIMING (REFCOUNT_FULL, mainline): 53.203 +- 0.138 seconds time elapsed ( +- 0.26% )
> REFCOUNT_TIMING (REFCOUNT_FULL, this series): 31.7408 +- 0.0486 seconds time elapsed ( +- 0.15% )
Nice improvements! :) Please consider the series:
Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>
-Kees
>
> Cheers,
>
> Will
>
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Elena Reshetova <elena.reshetova@xxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx>
> Cc: Hanjun Guo <guohanjun@xxxxxxxxxx>
> Cc: Jan Glauber <jglauber@xxxxxxxxxxx>
>
> --->8
>
> Will Deacon (6):
> lib/refcount: Define constants for saturation and max refcount values
> lib/refcount: Ensure integer operands are treated as signed
> lib/refcount: Remove unused refcount_*_checked() variants
> lib/refcount: Move bulk of REFCOUNT_FULL implementation into header
> lib/refcount: Improve performance of generic REFCOUNT_FULL code
> lib/refcount: Consolidate REFCOUNT_{MAX,SATURATED} definitions
>
> drivers/misc/lkdtm/refcount.c | 8 --
> include/linux/refcount.h | 236 +++++++++++++++++++++++++++++++++++++----
> lib/refcount.c | 237 +-----------------------------------------
> 3 files changed, 218 insertions(+), 263 deletions(-)
>
> --
> 2.11.0
>
--
Kees Cook