twx-linux/tools
Chun-Tse Shao 55f75ce472 perf lock: Fix parse_lock_type which only retrieve one lock flag
[ Upstream commit 1be9264158ef4818393e5d8144887a1a5d3cc480 ]

`parse_lock_type` can only add the first lock flag in `lock_type_table`
given input `str`. For example, for `Y rwlock`, it only adds `rwlock:R`
into this perf session. Another example is for `-Y mutex`, it only adds
the mutex without `LCB_F_SPIN` flag. The patch fixes this issue, makes
sure both `rwlock:R` and `rwlock:W` will be added with `-Y rwlock`, and
so on.

Testing:
  $ ./perf lock con -ab -Y mutex,rwlock -- perf bench sched pipe
  # Running 'sched/pipe' benchmark:
  # Executed 1000000 pipe operations between two processes

       Total time: 9.313 [sec]

         9.313976 usecs/op
           107365 ops/sec
   contended   total wait     max wait     avg wait         type   caller

         176      1.65 ms     19.43 us      9.38 us        mutex   pipe_read+0x57
          34    180.14 us     10.93 us      5.30 us        mutex   pipe_write+0x50
           7     77.48 us     16.09 us     11.07 us        mutex   do_epoll_wait+0x24d
           7     74.70 us     13.50 us     10.67 us        mutex   do_epoll_wait+0x24d
           3     35.97 us     14.44 us     11.99 us     rwlock:W   ep_done_scan+0x2d
           3     35.00 us     12.23 us     11.66 us     rwlock:W   do_epoll_wait+0x255
           2     15.88 us     11.96 us      7.94 us     rwlock:W   do_epoll_wait+0x47c
           1     15.23 us     15.23 us     15.23 us     rwlock:W   do_epoll_wait+0x4d0
           1     14.26 us     14.26 us     14.26 us     rwlock:W   ep_done_scan+0x2d
           2     14.00 us      7.99 us      7.00 us        mutex   pipe_read+0x282
           1     12.29 us     12.29 us     12.29 us     rwlock:R   ep_poll_callback+0x35
           1     12.02 us     12.02 us     12.02 us     rwlock:W   do_epoll_ctl+0xb65
           1     10.25 us     10.25 us     10.25 us     rwlock:R   ep_poll_callback+0x35
           1      7.86 us      7.86 us      7.86 us        mutex   do_epoll_ctl+0x6c1
           1      5.04 us      5.04 us      5.04 us        mutex   do_epoll_ctl+0x3d4

[namhyung: Add a comment and rename to 'mutex:spin' for consistency

Fixes: d783ea8f62c4 ("perf lock contention: Simplify parse_lock_type()")
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Chun-Tse Shao <ctshao@google.com>
Cc: nick.forrington@arm.com
Link: https://lore.kernel.org/r/20250116235838.2769691-1-ctshao@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-02-08 09:52:09 +01:00
..
accounting
arch tools/x86/kcpuid: Protect against faulty "max subleaf" values 2024-10-10 11:57:29 +02:00
bootconfig
bpf bpftool: fix potential NULL pointer dereferencing in prog_dump() 2024-12-14 19:59:48 +01:00
build
certs
cgroup
counter
crypto/ccp
debugging
edid
firewire
firmware
gpio
hv tools: hv: change permissions of NetworkManager configuration file 2024-12-27 13:58:46 +01:00
iio tools/iio: Add memory allocation failure check for trigger_name 2024-10-17 15:24:20 +02:00
include memblock tests: fix implicit declaration of function 'numa_valid_node' 2025-01-17 13:36:14 +01:00
kvm/kvm_stat
laptop
leds
lib libbpf: Fix segfault due to libelf functions not setting errno 2025-02-08 09:52:04 +01:00
memory-model tools/memory-model: Fix bug in lock.cat 2024-08-03 08:54:21 +02:00
mm tools/mm: fix compile error 2024-11-22 15:38:33 +01:00
net/ynl
objtool objtool/x86: allow syscall instruction 2024-12-19 18:11:36 +01:00
pci
pcmcia
perf perf lock: Fix parse_lock_type which only retrieve one lock flag 2025-02-08 09:52:09 +01:00
power cpupower: fix TSC MHz calculation 2025-02-08 09:51:52 +01:00
rcu
scripts tools: Override makefile ARCH variable if defined, but empty 2024-12-14 19:59:49 +01:00
spi
testing ktest.pl: Remove unused declarations in run_bisect_test function 2025-02-08 09:52:06 +01:00
thermal
time
tracing rtla/timerlat: Make timerlat_hist_cpu->*_count unsigned long long 2024-12-19 18:11:26 +01:00
usb usbip: tools: Fix detach_port() invalid port error path 2024-11-08 16:28:22 +01:00
verification verification/dot2: Improve dot parser robustness 2024-12-14 20:00:13 +01:00
virtio
wmi
workqueue
Makefile