linux-stable/tools
Namhyung Kim b5711042a1 perf lock contention: Use per-cpu array map for spinlocks
Currently lock contention timestamp is maintained in a hash map keyed by
pid.  That means it needs to get and release a map element (which is
proctected by spinlock!) on each contention begin and end pair.  This
can impact on performance if there are a lot of contention (usually from
spinlocks).

It used to go with task local storage but it had an issue on memory
allocation in some critical paths.  Although it's addressed in recent
kernels IIUC, the tool should support old kernels too.  So it cannot
simply switch to the task local storage at least for now.

As spinlocks create lots of contention and they disabled preemption
during the spinning, it can use per-cpu array to keep the timestamp to
avoid overhead in hashmap update and delete.

In contention_begin, it's easy to check the lock types since it can see
the flags.  But contention_end cannot see it.  So let's try to per-cpu
array first (unconditionally) if it has an active element (lock != 0).
Then it should be used and per-task tstamp map should not be used until
the per-cpu array element is cleared which means nested spinlock
contention (if any) was finished and it nows see (the outer) lock.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Song Liu <song@kernel.org>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20231020204741.1869520-3-namhyung@kernel.org
2023-10-25 10:02:55 -07:00
..
accounting
arch tools arch x86: Sync the msr-index.h copy with the kernel sources 2023-09-13 08:53:37 -03:00
bootconfig
bpf bpftool: Fix build warnings with -Wtype-limits 2023-08-30 08:39:00 +02:00
build tools/build: Fix -s detection code in tools/build/Makefile.build 2023-10-18 15:29:35 -07:00
certs
cgroup iocost_monitor: improve it by adding iocg wait_ms 2023-08-08 15:43:03 -06:00
counter tools/counter: Makefile: Replace rmdir by rm to avoid make,clean failure 2023-07-24 10:29:52 -04:00
crypto/ccp crypto: ccp - Add unit tests for dynamic boost control 2023-07-20 22:15:12 +12:00
debugging
edid
firewire
firmware
gpio
hv vmbus_testing: fix wrong python syntax for integer value comparison 2023-07-23 23:19:30 +00:00
iio tools: iio: iio_generic_buffer: Fix some integer type and calculation 2023-07-29 15:59:20 +01:00
include perf tools: Add get_unaligned_leNN() 2023-10-17 12:40:02 -07:00
kvm/kvm_stat
laptop
leds
lib tools api: Avoid potential double free 2023-10-12 10:01:57 -07:00
memory-model
mm tools/mm: fix undefined reference to pthread_once 2023-09-05 10:13:45 -07:00
net/ynl tools/net/ynl: Add support for create flags 2023-08-27 17:17:10 -07:00
objtool objtool/x86: Fixup frame-pointer vs rethunk 2023-08-17 00:44:35 +02:00
pci
pcmcia
perf perf lock contention: Use per-cpu array map for spinlocks 2023-10-25 10:02:55 -07:00
power More power management updates for 6.6-rc1 2023-09-04 15:21:55 -07:00
rcu
scripts tools/build: Fix -s detection code in tools/scripts/Makefile.include 2023-10-18 15:29:47 -07:00
spi
testing XArray/IDA updates for 6.6 2023-09-08 21:46:26 -07:00
thermal
time
tracing
usb
verification
virtio
wmi
workqueue workqueue: Implement non-strict affinity scope for unbound workqueues 2023-08-07 15:57:25 -10:00
Makefile