Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1306386imm; Wed, 10 Oct 2018 12:21:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV62gsri+IjV7lgsDuACIeAbN8c0oEiFYwdVM+ASMmD+ghT/DKLp6guu7iqWEZPcPWnmI49it X-Received: by 2002:a62:aa17:: with SMTP id e23-v6mr36064903pff.211.1539199278026; Wed, 10 Oct 2018 12:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539199277; cv=none; d=google.com; s=arc-20160816; b=uifeRVdUH+wIbWi/M+nhexp7R6fFMGTHnIgl5vkYhmoKeS11X+0rVICjA/65MrJoGH yyAhDUVpxyA0s1oEm/PDWoHdVWPtlrRoqv9tuVs73GyQSezE13V/2fLC8TuWnaICykSf O7dKLQtZb3Sue5HLzup/Ph5lB46+arOkvBXBP/Seq1pa6EV6MSlXdiamiAiDGED+751k P1BBmNLNl9DuFiDrYG5x6Q7ZTmUgYTr32sDbTAZXFlRYNkJkBFI4S69UouPaydyAtM+W L/UNPnyJ05EDZRCGw06xA7gamNsUB63VoXnr0pH3X36MOI9CxNaK9nG/aKi5oYiU4giG dVRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=fcGwPM3V/nbkp63q4bvonez6xrbbL/Ahmj9LgwKvEAQ=; b=z9dHSNirSpL60uJqHmHXzy6c8AP49enFXrJCk/KZI4pGlCSa230B45enYjQI5AUOE3 whZQW89V4nCLzRX6xoyfCZJQLCahIwBulq9QMex08swMP8P2IRoYq+xuRZwLU0icE+Qb sGO1rNDFGHpknqhbaQh47qAiL9VodciGtF2HAYCvkjHN77ePEAPhF0V49Lt3PKmbbGiq NR5TsOzlbD+4bIXaX7+qnZae64Oa8VVBjHFDZzN2X3nuvW2fYwC/GI66dyMagGqxBXd2 FPaJqDjgM1Uc6Qjbi/wpHLrAxD8Pz9ZoVC+JCOG06joFciqceyz2Z2oyB+we4ON4AOUK cWKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=U6QCTqv8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4-v6si27736711pfg.112.2018.10.10.12.21.03; Wed, 10 Oct 2018 12:21:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=U6QCTqv8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727989AbeJKCny (ORCPT + 99 others); Wed, 10 Oct 2018 22:43:54 -0400 Received: from mail.efficios.com ([167.114.142.138]:33348 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbeJKCnx (ORCPT ); Wed, 10 Oct 2018 22:43:53 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id A366E183C69; Wed, 10 Oct 2018 15:20:19 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id B9_bLur915ns; Wed, 10 Oct 2018 15:20:19 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id E8DC5183C60; Wed, 10 Oct 2018 15:20:18 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com E8DC5183C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1539199218; bh=fcGwPM3V/nbkp63q4bvonez6xrbbL/Ahmj9LgwKvEAQ=; h=From:To:Date:Message-Id; b=U6QCTqv8ML7jiHQ5ZPmC9w0afF64fRyT4mrp02ArlPJaeuzq92G+0+pZJM1umkMRX qg4NJGbWwju6uXhzrzN1REO7rhhiGudpmIHMekVN7uXFgrYEqkw8F0fIT8mfbGw6Aq L+myDpsxpii6bupRZ37jcGS62RUtvuLUbNIk9flZ5tcOwrzdXCSUCSB9LaSywgAWPx Vb4h51Ebrydd/JGBgxgdTQ5QKngZTEzbB7/QVbSxx+hdY3q/oFH0h5ccMF/aikKvkL /DSy/I0vqBioG012apVmBf7YAE4mGhMDdRGw80y2TMtsPQIPlBFPygJKx9ej5qfl/U HFj4LDUqxQ5jw== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id jAMhFgSkSx7c; Wed, 10 Oct 2018 15:20:18 -0400 (EDT) Received: from thinkos.internal.efficios.com (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) by mail.efficios.com (Postfix) with ESMTPSA id BE6AC183C4D; Wed, 10 Oct 2018 15:20:17 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra , "Paul E . McKenney" , Boqun Feng Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Thomas Gleixner , Andy Lutomirski , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H . Peter Anvin" , Andi Kleen , Chris Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes , Mathieu Desnoyers , Shuah Khan , linux-kselftest@vger.kernel.org Subject: [RFC PATCH for 4.21 16/16] cpu-opv/selftests: Provide Makefile, scripts, gitignore Date: Wed, 10 Oct 2018 15:19:36 -0400 Message-Id: <20181010191936.7495-17-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181010191936.7495-1-mathieu.desnoyers@efficios.com> References: <20181010191936.7495-1-mathieu.desnoyers@efficios.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A run_param_test.sh script runs many variants of the parametrizable tests. Wire up the cpu-opv Makefile, add directory entry into MAINTAINERS file. Signed-off-by: Mathieu Desnoyers Cc: Thomas Gleixner Cc: Joel Fernandes Cc: Peter Zijlstra Cc: Catalin Marinas Cc: Dave Watson Cc: Will Deacon Cc: Shuah Khan Cc: Andi Kleen Cc: linux-kselftest@vger.kernel.org Cc: "H . Peter Anvin" Cc: Chris Lameter Cc: Russell King Cc: Michael Kerrisk Cc: "Paul E . McKenney" Cc: Paul Turner Cc: Boqun Feng Cc: Josh Triplett Cc: Steven Rostedt Cc: Ben Maurer Cc: linux-api@vger.kernel.org Cc: Andy Lutomirski Cc: Andrew Morton Cc: Linus Torvalds --- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/cpu-opv/.gitignore | 6 + tools/testing/selftests/cpu-opv/Makefile | 39 +++++++ tools/testing/selftests/cpu-opv/run_param_test.sh | 134 ++++++++++++++++++++++ 5 files changed, 181 insertions(+) create mode 100644 tools/testing/selftests/cpu-opv/.gitignore create mode 100644 tools/testing/selftests/cpu-opv/Makefile create mode 100755 tools/testing/selftests/cpu-opv/run_param_test.sh diff --git a/MAINTAINERS b/MAINTAINERS index 3b50578fc5d9..206fe4597697 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3864,6 +3864,7 @@ L: linux-kernel@vger.kernel.org S: Supported F: kernel/cpu_opv.c F: include/uapi/linux/cpu_opv.h +F: tools/testing/selftests/cpu-opv/ CRAMFS FILESYSTEM M: Nicolas Pitre diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index f1fe492c8e17..42bcc6e5fc5d 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -6,6 +6,7 @@ TARGETS += capabilities TARGETS += cgroup TARGETS += cpufreq TARGETS += cpu-hotplug +TARGETS += cpu-opv TARGETS += efivarfs TARGETS += exec TARGETS += filesystems diff --git a/tools/testing/selftests/cpu-opv/.gitignore b/tools/testing/selftests/cpu-opv/.gitignore new file mode 100644 index 000000000000..8c7bb1f8be79 --- /dev/null +++ b/tools/testing/selftests/cpu-opv/.gitignore @@ -0,0 +1,6 @@ +basic_cpu_opv_test +basic_percpu_ops_test +param_test +param_test_benchmark +param_test_compare_twice +param_test_skip_fastpath diff --git a/tools/testing/selftests/cpu-opv/Makefile b/tools/testing/selftests/cpu-opv/Makefile new file mode 100644 index 000000000000..46f49bf30bae --- /dev/null +++ b/tools/testing/selftests/cpu-opv/Makefile @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: GPL-2.0+ OR MIT +CFLAGS += -O2 -Wall -g -I./ -I../rseq/ -I../../../../usr/include/ -L./ -Wl,-rpath=./ +LDLIBS += -lpthread + +# Own dependencies because we only want to build against 1st prerequisite, but +# still track changes to header files and depend on shared object. +OVERRIDE_TARGETS = 1 + +TEST_GEN_PROGS = basic_cpu_opv_test basic_percpu_ops_test \ + param_test param_test_skip_fastpath \ + param_test_benchmark param_test_compare_twice + +TEST_GEN_PROGS_EXTENDED = librseq.so libcpu-op.so + +TEST_PROGS = run_param_test.sh + +include ../lib.mk + +$(OUTPUT)/libcpu-op.so: cpu-op.c cpu-op.h + $(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@ + +$(OUTPUT)/librseq.so: ../rseq/rseq.c ../rseq/rseq.h ../rseq/rseq-*.h + $(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@ + +$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) ../rseq/rseq.h ../rseq/rseq-*.h cpu-op.h percpu-op.h + $(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -lcpu-op -o $@ + +$(OUTPUT)/param_test_skip_fastpath: param_test.c $(TEST_GEN_PROGS_EXTENDED) \ + ../rseq/rseq.h ../rseq/rseq-*.h cpu-op.h percpu-op.h + $(CC) $(CFLAGS) -DRSEQ_SKIP_FASTPATH $< $(LDLIBS) -lrseq -lcpu-op -o $@ + +$(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \ + ../rseq/rseq.h ../rseq/rseq-*.h cpu-op.h percpu-op.h + $(CC) $(CFLAGS) -DBENCHMARK $< $(LDLIBS) -lrseq -lcpu-op -o $@ + +$(OUTPUT)/param_test_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \ + ../rseq/rseq.h ../rseq/rseq-*.h cpu-op.h percpu-op.h + $(CC) $(CFLAGS) -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -lcpu-op -o $@ + diff --git a/tools/testing/selftests/cpu-opv/run_param_test.sh b/tools/testing/selftests/cpu-opv/run_param_test.sh new file mode 100755 index 000000000000..066d2479893c --- /dev/null +++ b/tools/testing/selftests/cpu-opv/run_param_test.sh @@ -0,0 +1,134 @@ +#!/bin/bash + +NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l` + +EXTRA_ARGS=${@} + +OLDIFS="$IFS" +IFS=$'\n' +TEST_LIST=( + "-T s" + "-T l" + "-T b" + "-T b -M" + "-T m" + "-T m -M" + "-T i" +) + +TEST_NAME=( + "spinlock" + "list" + "buffer" + "buffer with barrier" + "memcpy" + "memcpy with barrier" + "increment" +) +IFS="$OLDIFS" + +REPS=1000 +SLOW_REPS=100 +NR_THREADS=$((6*${NR_CPUS})) + +function do_tests() +{ + local i=0 + while [ "$i" -lt "${#TEST_LIST[@]}" ]; do + echo "Running test ${TEST_NAME[$i]}" + ./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1 + echo "Running skip fast-path test ${TEST_NAME[$i]}" + ./param_test_skip_fastpath ${TEST_LIST[$i]} -r ${SLOW_REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1 + echo "Running compare-twice test ${TEST_NAME[$i]}" + ./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1 + let "i++" + done +} + +echo "Default parameters" +do_tests + +echo "Loop injection: 10000 loops" + +OLDIFS="$IFS" +IFS=$'\n' +INJECT_LIST=( + "1" + "2" + "3" + "4" + "5" + "6" + "7" + "8" + "9" +) +IFS="$OLDIFS" + +NR_LOOPS=10000 + +i=0 +while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do + echo "Injecting at <${INJECT_LIST[$i]}>" + do_tests -${INJECT_LIST[i]} ${NR_LOOPS} + let "i++" +done +NR_LOOPS= + +function inject_blocking() +{ + OLDIFS="$IFS" + IFS=$'\n' + INJECT_LIST=( + "7" + "8" + "9" + ) + IFS="$OLDIFS" + + NR_LOOPS=-1 + + i=0 + while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do + echo "Injecting at <${INJECT_LIST[$i]}>" + do_tests -${INJECT_LIST[i]} -1 ${@} + let "i++" + done + NR_LOOPS= +} + +echo "Yield injection (25%)" +inject_blocking -m 4 -y + +echo "Yield injection (50%)" +inject_blocking -m 2 -y + +echo "Yield injection (100%)" +inject_blocking -m 1 -y + +echo "Kill injection (25%)" +inject_blocking -m 4 -k + +echo "Kill injection (50%)" +inject_blocking -m 2 -k + +echo "Kill injection (100%)" +inject_blocking -m 1 -k + +echo "Sleep injection (1ms, 25%)" +inject_blocking -m 4 -s 1 + +echo "Sleep injection (1ms, 50%)" +inject_blocking -m 2 -s 1 + +echo "Sleep injection (1ms, 100%)" +inject_blocking -m 1 -s 1 + +echo "Disable rseq for 25% threads" +do_tests -D 4 + +echo "Disable rseq for 50% threads" +do_tests -D 2 + +echo "Disable rseq" +do_tests -d -- 2.11.0