This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v2 4/5] BENCHMARK: add a benchmark for testing new type of mutex
- From: Kemi Wang <kemi dot wang at intel dot com>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Florian Weimer <fweimer at redhat dot com>, Rical Jason <rj at 2c3t dot io>, Carlos Donell <carlos at redhat dot com>, Glibc alpha <libc-alpha at sourceware dot org>
- Cc: Dave Hansen <dave dot hansen at linux dot intel dot com>, Tim Chen <tim dot c dot chen at intel dot com>, Andi Kleen <andi dot kleen at intel dot com>, Ying Huang <ying dot huang at intel dot com>, Aaron Lu <aaron dot lu at intel dot com>, Lu Aubrey <aubrey dot li at intel dot com>, Kemi Wang <kemi dot wang at intel dot com>
- Date: Fri, 13 Jul 2018 14:52:31 +0800
- Subject: [PATCH v2 4/5] BENCHMARK: add a benchmark for testing new type of mutex
- References: <1531464752-18830-1-git-send-email-kemi.wang@intel.com>
Add the benchmark for testing the mutex with type
PTHREAD_MUTEX_QUEUESPINNER_NP.
Signed-off-by: Kemi Wang <kemi.wang@intel.com>
---
benchtests/Makefile | 4 ++--
benchtests/bench-mutex-adaptive-thread.c | 8 ++++++--
benchtests/bench-mutex-queuespinner-thread.c | 21 +++++++++++++++++++++
3 files changed, 29 insertions(+), 4 deletions(-)
create mode 100644 benchtests/bench-mutex-queuespinner-thread.c
diff --git a/benchtests/Makefile b/benchtests/Makefile
index 47b587f..31bef2e 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -96,7 +96,7 @@ bench-malloc := $(filter malloc-%,${BENCHSET})
endif
ifeq (${BENCHSET},)
-bench-mutex := mutex-adaptive-thread
+bench-mutex := mutex-adaptive-thread mutex-queuespinner-thread
else
bench-mutex := $(filter mutex-%,${BENCHSET})
endif
@@ -174,7 +174,7 @@ bench-clean:
ifneq ($(strip ${BENCHSET}),)
VALIDBENCHSETNAMES := bench-pthread bench-math bench-string string-benchset \
wcsmbs-benchset stdlib-benchset stdio-common-benchset math-benchset \
- malloc-thread mutex-adaptive-thread
+ malloc-thread mutex-adaptive-thread mutex-queuespinner-thread
INVALIDBENCHSETNAMES := $(filter-out ${VALIDBENCHSETNAMES},${BENCHSET})
ifneq (${INVALIDBENCHSETNAMES},)
$(info The following values in BENCHSET are invalid: ${INVALIDBENCHSETNAMES})
diff --git a/benchtests/bench-mutex-adaptive-thread.c b/benchtests/bench-mutex-adaptive-thread.c
index ce9c40e..0badb93 100644
--- a/benchtests/bench-mutex-adaptive-thread.c
+++ b/benchtests/bench-mutex-adaptive-thread.c
@@ -30,8 +30,12 @@
#include "json-lib.h"
/* Benchmark duration in seconds. */
-#define BENCHMARK_DURATION 15
-#define TYPE PTHREAD_MUTEX_ADAPTIVE_NP
+#define BENCHMARK_DURATION 5
+
+#ifndef TYPE
+# define TYPE PTHREAD_MUTEX_ADAPTIVE_NP
+#endif
+
#define mb() asm ("" ::: "memory")
#define UNLOCK_DELAY 10
diff --git a/benchtests/bench-mutex-queuespinner-thread.c b/benchtests/bench-mutex-queuespinner-thread.c
new file mode 100644
index 0000000..0a1693e
--- /dev/null
+++ b/benchtests/bench-mutex-queuespinner-thread.c
@@ -0,0 +1,21 @@
+/* Benchmark pthread adaptive spin mutex lock and unlock functions.
+ Copyright (C) 2018 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
+ <http://www.gnu.org/licenses/>. */
+
+#define TYPE PTHREAD_MUTEX_QUEUESPINNER_NP
+
+#include "bench-mutex-adaptive-thread.c"
--
2.7.4