]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
benchtests: Add pthread mutex trylock recursive throughput test (BZ #33704) master
authorSunil K Pandey <sunil.k.pandey@intel.com>
Tue, 16 Dec 2025 05:53:51 +0000 (21:53 -0800)
committerSunil K Pandey <sunil.k.pandey@intel.com>
Wed, 17 Dec 2025 01:18:55 +0000 (17:18 -0800)
This benchmark measures number of successful updates per second
under high cache contention.

Tested on x86_64.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
benchtests/Makefile
benchtests/bench-pthread-mutex-trylock-recursive-throughput.c [new file with mode: 0644]

index c3368a7603847480044164fc81e1c71f488f0087..59f4503ebbe0a7a91ff1398170f0445bee529f51 100644 (file)
@@ -175,6 +175,7 @@ bench-pthread := \
   pthread-locks \
   pthread-mutex-lock \
   pthread-mutex-trylock \
+  pthread-mutex-trylock-recursive-throughput \
   pthread-mutex-trylock-throughput \
   pthread-spin-lock \
   pthread-spin-trylock \
@@ -189,6 +190,7 @@ bench-resolv := \
 
 LDLIBS-bench-pthread-mutex-lock += -lm
 LDLIBS-bench-pthread-mutex-trylock += -lm
+LDLIBS-bench-pthread-mutex-trylock-recursive-throughput += -lm
 LDLIBS-bench-pthread-mutex-trylock-throughput += -lm
 LDLIBS-bench-pthread-spin-lock += -lm
 LDLIBS-bench-pthread-spin-trylock += -lm
diff --git a/benchtests/bench-pthread-mutex-trylock-recursive-throughput.c b/benchtests/bench-pthread-mutex-trylock-recursive-throughput.c
new file mode 100644 (file)
index 0000000..9bfc4f1
--- /dev/null
@@ -0,0 +1,21 @@
+/* Measure pthread trylock recursive throughput under high cache contention.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#define TEST_NAME "pthread-mutex-trylock-recursive-throughput"
+#define PTHREAD_MUTEX_TYPE_INITIALIZER PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#include "bench-pthread-mutex-trylock-base.c"