]> www.infradead.org Git - users/jedix/linux-maple.git/commit
lib/stackdepot: use read/write lock
authorAndrey Konovalov <andreyknvl@google.com>
Mon, 20 Nov 2023 17:47:10 +0000 (18:47 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 20 Nov 2023 21:16:39 +0000 (13:16 -0800)
commit01ce1b75440af06123ec00359c2f356c73af4d27
treed8b1b7d9f38f192a5dd64be05b954b9e11ea09a3
parenta58d0a581654a9cdb95736dd930c5c55b01a4242
lib/stackdepot: use read/write lock

Currently, stack depot uses the following locking scheme:

1. Lock-free accesses when looking up a stack record, which allows to
   have multiple users to look up records in parallel;
2. Spinlock for protecting the stack depot pools and the hash table
   when adding a new record.

For implementing the eviction of stack traces from stack depot, the
  lock-free approach is not going to work anymore, as we will need to be
  able to also remove records from the hash table.

Convert the spinlock into a read/write lock, and drop the atomic
  accesses, as they are no longer required.

Looking up stack traces is now protected by the read lock and adding new
  records - by the write lock.  One of the following patches will add a
  new function for evicting stack records, which will be protected by the
  write lock as well.

With this change, multiple users can still look up records in parallel.

This is preparatory patch for implementing the eviction of stack records
  from the stack depot.

Link: https://lkml.kernel.org/r/9f81ffcc4bb422ebb6326a65a770bf1918634cbb.1700502145.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/stackdepot.c