Branch: refs/heads/master
Home:
https://github.com/openssl/openssl
Commit: ab021b624f1d09378bb5115ccfa01517a5ea0bdc
https://github.com/openssl/openssl/commit/ab021b624f1d09378bb5115ccfa01517a5ea0bdc
Author: Neil Horman <
nho...@openssl.org>
Date: 2025-07-11 (Fri, 11 Jul 2025)
Changed paths:
M crypto/threads_pthread.c
Log Message:
-----------
Add lock contention checking to our pthreads implementation
Something we're missing in our ability to do performance monitoring
and diagnosis in openssl is the ability to check for lock contention.
While some tools exist for this (valgrinds drd tool for example), they
really only measure the time spent in critical sections, not the
instances in which they are contended. For that we need something more
specific.
This patch introduces the REPORT_RWLOCK_CONTENTION macro. When openssl
is built with:
./Configure -rdynamic -fno-omit-frame-pointer -DREPORT_RWLOCK_CONTENTION
We can now get output sent to a log file that looks like the following:
===============
lock blocked on WRITE for 1001 usec
/lib64/libasan.so.8(+0x525e7) [0x7fc5ef4525e7]
../../test/quic_radix_test(CRYPTO_THREAD_write_lock+0x151) [0x79d976]
../../test/quic_radix_test() [0x61e6fb]
../../test/quic_radix_test(test_vprintf_stderr+0x15) [0x61e78d]
../../test/quic_radix_test(test_printf_stderr+0x10f) [0x623ba4]
../../test/quic_radix_test(test_fail_message_prefix+0xf7) [0x62436b]
../../test/quic_radix_test() [0x6243b9]
../../test/quic_radix_test(test_info+0x133) [0x624842]
../../test/quic_radix_test() [0x415aad]
../../test/quic_radix_test() [0x417bad]
../../test/quic_radix_test() [0x41b1a9]
../../test/quic_radix_test() [0x41b2eb]
../../test/quic_radix_test() [0x8071fc]
/lib64/libasan.so.8(+0x28ee6) [0x7fc5ef428ee6]
/lib64/libc.so.6(+0x711d4) [0x7fc5ef27f1d4]
/lib64/libc.so.6(+0xf3cec) [0x7fc5ef301cec]
==============
Which tells us when a thread blocked because someone else was already
holding the lock, how long it was blocked for, and where the blocking
call originated from via its backtrace.
I think this should enable us to better determine where our contended
locking paths are for a given application, and give us some insight on
how to fix them.
Currently its linux only (as the backtrace functionality only exists
there, and there are few warts (like the need to use a file pointer
rather than a bio to record the log, see comments), but I think its
enough to give us a useful diagnostic tool to help drive some
performance improvements.
Fixes openssl/project#1237
Reviewed-by: Saša Nedvědický <
sas...@openssl.org>
Reviewed-by: Tomas Mraz <
to...@openssl.org>
Reviewed-by: Matt Caswell <
ma...@openssl.org>
(Merged from
https://github.com/openssl/openssl/pull/27884)
To unsubscribe from these emails, change your notification settings at
https://github.com/openssl/openssl/settings/notifications