From patchwork Mon Jul 2 08:11:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemi Wang X-Patchwork-Id: 28184 Received: (qmail 24161 invoked by alias); 2 Jul 2018 08:17:04 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 23741 invoked by uid 89); 2 Jul 2018 08:16:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=1747, duration X-HELO: mga09.intel.com From: Kemi Wang To: Adhemerval Zanella , Florian Weimer , Rical Jason , Carlos Donell , Glibc alpha Cc: Dave Hansen , Tim Chen , Andi Kleen , Ying Huang , Aaron Lu , Lu Aubrey , Kemi Wang Subject: [PATCH 3/4] BENCHMARK: add a benchmark for testing new type of mutex Date: Mon, 2 Jul 2018 16:11:55 +0800 Message-Id: <1530519116-13103-4-git-send-email-kemi.wang@intel.com> In-Reply-To: <1530519116-13103-1-git-send-email-kemi.wang@intel.com> References: <1530519116-13103-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 --- 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 + . */ + +#define TYPE PTHREAD_MUTEX_QUEUESPINNER_NP + +#include "bench-mutex-adaptive-thread.c"