From: Sunil K Pandey Date: Tue, 16 Dec 2025 05:53:51 +0000 (-0800) Subject: benchtests: Add pthread mutex trylock recursive throughput test (BZ #33704) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=inline;p=thirdparty%2Fglibc.git benchtests: Add pthread mutex trylock recursive throughput test (BZ #33704) This benchmark measures number of successful updates per second under high cache contention. Tested on x86_64. Reviewed-by: H.J. Lu --- diff --git a/benchtests/Makefile b/benchtests/Makefile index c3368a7603..59f4503ebb 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -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 index 0000000000..9bfc4f1140 --- /dev/null +++ b/benchtests/bench-pthread-mutex-trylock-recursive-throughput.c @@ -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 + . */ + +#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"