From patchwork Fri Jul 13 06:52:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kemi X-Patchwork-Id: 943310 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-94243-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="pQotS0FW"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Rk9f1qC4z9ryt for ; Fri, 13 Jul 2018 16:56:22 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=nm3CKNMsfHN3hKMR5VG3sdmOTCaFz7r 0wz9tTLNHq4hjuCbD2ZclKm/VCMApLkuGBYxhVG4FHE6S7tWQZzEMlGVcK6nYSc/ oQhpNVMml+lygaM03x6jw2c9kea1SK3++M2fWRbbUmkNySpa5tgHQUDzFyvnNUjy EfMyV2eWsO4s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=z71BjzzZVX74ibOUGCJfBcIiwwk=; b=pQotS 0FWbMjlOxyyXcShzJckjCpY8ZrHNZRNzUxSd7IXR0JIrVhdPDuXku+OUiaxIG5Sr WWp+EcLjPtcIU93AOIVQJElQTHyJKYHPwqWRcNeuZvtQrJYm52rABoi5r7kZ6CZe rzZzHTFgtYOzcTX0NPOKT6kmcWuGs11Et2bkXg= Received: (qmail 13693 invoked by alias); 13 Jul 2018 06:55:42 -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 13568 invoked by uid 89); 13 Jul 2018 06:55:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT autolearn=ham version=3.3.2 spammy= X-HELO: mga18.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 v2 4/5] BENCHMARK: add a benchmark for testing new type of mutex Date: Fri, 13 Jul 2018 14:52:31 +0800 Message-Id: <1531464752-18830-5-git-send-email-kemi.wang@intel.com> In-Reply-To: <1531464752-18830-1-git-send-email-kemi.wang@intel.com> 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 --- 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"