• Marco Elver's avatar
    kasan: revert eviction of stack traces in generic mode · 711d3491
    Marco Elver authored
    This partially reverts commits cc478e0b, 63b85ac5, 08d7c94d,
    a414d428, and 773688a6 to make use of variable-sized stack depot
    records, since eviction of stack entries from stack depot forces fixed-
    sized stack records.  Care was taken to retain the code cleanups by the
    above commits.
    
    Eviction was added to generic KASAN as a response to alleviating the
    additional memory usage from fixed-sized stack records, but this still
    uses more memory than previously.
    
    With the re-introduction of variable-sized records for stack depot, we can
    just switch back to non-evictable stack records again, and return back to
    the previous performance and memory usage baseline.
    
    Before (observed after a KASAN kernel boot):
    
      pools: 597
      refcounted_allocations: 17547
      refcounted_frees: 6477
      refcounted_in_use: 11070
      freelist_size: 3497
      persistent_count: 12163
      persistent_bytes: 1717008
    
    After:
    
      pools: 319
      refcounted_allocations: 0
      refcounted_frees: 0
      refcounted_in_use: 0
      freelist_size: 0
      persistent_count: 29397
      persistent_bytes: 5183536
    
    As can be seen from the counters, with a generic KASAN config, refcounted
    allocations and evictions are no longer used.  Due to using variable-sized
    records, I observe a reduction of 278 stack depot pools (saving 4448 KiB)
    with my test setup.
    
    Link: https://lkml.kernel.org/r/20240129100708.39460-2-elver@google.com
    Fixes: cc478e0b ("kasan: avoid resetting aux_lock")
    Fixes: 63b85ac5 ("kasan: stop leaking stack trace handles")
    Fixes: 08d7c94d ("kasan: memset free track in qlink_free")
    Fixes: a414d428 ("kasan: handle concurrent kasan_record_aux_stack calls")
    Fixes: 773688a6 ("kasan: use stack_depot_put for Generic mode")
    Signed-off-by: default avatarMarco Elver <elver@google.com>
    Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
    Tested-by: default avatarMikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
    Cc: Alexander Potapenko <glider@google.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
    Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    711d3491
generic.c 15.8 KB