From patchwork Fri Mar 31 08:26:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li (Jassmine)" X-Patchwork-Id: 13195412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7185DC6FD18 for ; Fri, 31 Mar 2023 08:27:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230496AbjCaI1o (ORCPT ); Fri, 31 Mar 2023 04:27:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjCaI1k (ORCPT ); Fri, 31 Mar 2023 04:27:40 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CF7BB44C; Fri, 31 Mar 2023 01:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HpuajdG+X4Sky6wLGdQ3NzBmRPthCbzGMOUNKC/qeI4WoL6jRoZx3Sbgj0TngkA4Zc8iyOrcD+ZLM6PO0UFQtESVZ76CNaRdOiwbjTuNzIQUCOD1oo+SDpLAg4hPvwiC/C5BiFpwtaoa8SsYaUd9Pc4fal4P25oVe0JDrJd6aClti16q/rxNnSrvGAxVKdzPCCMBWboOYUQpRjno9Xqzf/FuzCBRCYnbVlkzukCYl9+JGx+hRROeBCIMzMk1Ld0lXz35F0y4uUTv8zt5tXx1PnnlEiSwQgpzdy4RBEa2sErZPriufAASMKhuIistmfDRUgQhPTp8ZZXMFKp//y4akA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P+LFsFcUzfSlFWvrwqo86BFI9ah4JmCB5vBhpOhV4Bo=; b=VGDqCHv0kB64TNT9nbi9aTuMNju4iDIWDGcaUphUsEbgUh1tKhTpfL0JNlUV05o1ilhqHDWhZt9Bjup/KEeKh7J7rtV5PXg5xxzi36c1wOVWohpgZoechl/8k+8w1y4ImzXxiSNoOxnEehTgDvkWnaReEPXBvK56Zc4uKY1xi7s0bYwDYsP+0Nqjyxlj3K0kCH69JPYKfhVh9lCwfMGzzQftTaC85ujgWwcJ+A1zvzNgASD3MAgyT4oppX3AB8ecjmXEOwhbDgTjKknOfXN+hpZrCTvnOUSU8Vozvz+35zfXdFbfDfp2WubM62JAV7HbbhVqs1YCdT/N9/vbfZgdWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P+LFsFcUzfSlFWvrwqo86BFI9ah4JmCB5vBhpOhV4Bo=; b=5rIIKLftEyRunuOhB+OfWoQMwDDAznxOGbec58twnwIjzX4R2nfrg3lXLdMKiLRCCCRhX05pIIGuOWFVJswqIzBggwE7JNNTqTkf96BHyKgNIyloaR0/HmCWmn2DvMOSypEuhUMdenu6SQAlgPpItjHKwDf/w5ZxZS2itOrcnKo= Received: from BLAPR03CA0176.namprd03.prod.outlook.com (2603:10b6:208:32f::26) by BL1PR12MB5320.namprd12.prod.outlook.com (2603:10b6:208:314::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.23; Fri, 31 Mar 2023 08:27:34 +0000 Received: from BL02EPF000145B9.namprd05.prod.outlook.com (2603:10b6:208:32f:cafe::16) by BLAPR03CA0176.outlook.office365.com (2603:10b6:208:32f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22 via Frontend Transport; Fri, 31 Mar 2023 08:27:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF000145B9.mail.protection.outlook.com (10.167.241.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6222.35 via Frontend Transport; Fri, 31 Mar 2023 08:27:34 +0000 Received: from jasmine-meng.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 31 Mar 2023 03:27:29 -0500 From: Meng Li To: Shuah Khan , Huang Rui , CC: "Rafael J . Wysocki" , Nathan Fontenot , Deepak Sharma , "Alex Deucher" , Mario Limonciello , Shimmer Huang , "Perry Yuan" , Xiaojian Du , Viresh Kumar , Borislav Petkov , , Meng Li Subject: [PATCH V3 1/2] selftests: amd-pstate: Trigger speedometer benchmark and test cpus Date: Fri, 31 Mar 2023 16:26:58 +0800 Message-ID: <20230331082659.1887946-2-li.meng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230331082659.1887946-1-li.meng@amd.com> References: <20230331082659.1887946-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000145B9:EE_|BL1PR12MB5320:EE_ X-MS-Office365-Filtering-Correlation-Id: c46f3b47-485a-45db-57a7-08db31c1c714 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jzDtfWACbaKb+Fg9/7RYhCtd6t3FmElZpH8K895sbb5Y5DPBf+PWnd7xnl5bT7dQrq9cTqo3P7V7fPs9mEBeyhXPvruHQNzFj1TxToeMLEvpKvWS6Dn3xiVgsATc5wf2Mj6fSYkw1N5RdzuvIALIQYFiK5fbUt9owIfWPkRdPCM1i66WAp8eC6ogDMf8UvTfeKyynejwpwyXDf5T6uQgpjMrp1ifjgp8lXqo7PW5CfeBqlTWtEXsB5PurQiUWMgRQ3sr/YL0aqgDimcAckYz4Fu4Fd8jfDQGhMKuwD6OAOIq8fJDKntOAsr42n/KfHRzM5zE1DyBJXTRhZcS1+KPVMkfEuNGPYR6vfzV78PFsYRQZpDpzK3LrezlMqdhbmdaeWFE0uGUn4BPo9JJIo5SI4ltO+71XnTYXCao7GRM/t03/fEQxoehEmR9fqLtL2IKO5IHwUKRtEWlOgdGIw1xPhsH708DufXgCh/nu3NXc0wBSWa86mpCQxWeImGYoIkYfm3VjBpl+NDYgmfAlGAxCDDLBJ+/xhmoFLKMMHiq8MiCPp5xHrxsZB8XkgUVJxlob8H/GmxS8QWPtSbRztovo9NCKffAXXFWQB/3fpUawL+eqdiwuR/86nstcoJOSN2aM1uXAzsr0sOEdrM2CyJiO7bkelnbAKB053BsV0jUTU2P8YVVWEXLu9Vw7sDBDXnRmeoikvsHqFIbtEgEepW/O4CW45w5S1izrUex2sHXq+g= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(1076003)(40480700001)(186003)(16526019)(6666004)(82310400005)(8936002)(36860700001)(86362001)(30864003)(5660300002)(478600001)(110136005)(54906003)(70206006)(40460700003)(316002)(70586007)(47076005)(83380400001)(26005)(426003)(2616005)(66574015)(336012)(41300700001)(2906002)(82740400003)(81166007)(36756003)(4326008)(356005)(7696005)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2023 08:27:34.1036 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c46f3b47-485a-45db-57a7-08db31c1c714 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000145B9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5320 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add speedometer.sh trigger the speedometer testing and monitor the cpu desire performance, frequency, load, power consumption and throughput etc. Signed-off-by: Meng Li --- tools/testing/selftests/amd-pstate/Makefile | 13 +- tools/testing/selftests/amd-pstate/run.sh | 32 +- .../selftests/amd-pstate/selenium_server.sh | 15 + .../selftests/amd-pstate/speedometer.sh | 348 ++++++++++++++++++ .../selftests/amd-pstate/speedometer_web.py | 106 ++++++ 5 files changed, 504 insertions(+), 10 deletions(-) create mode 100755 tools/testing/selftests/amd-pstate/selenium_server.sh create mode 100755 tools/testing/selftests/amd-pstate/speedometer.sh create mode 100755 tools/testing/selftests/amd-pstate/speedometer_web.py diff --git a/tools/testing/selftests/amd-pstate/Makefile b/tools/testing/selftests/amd-pstate/Makefile index 5fd1424db37d..13335c00239d 100644 --- a/tools/testing/selftests/amd-pstate/Makefile +++ b/tools/testing/selftests/amd-pstate/Makefile @@ -4,10 +4,15 @@ # No binaries, but make sure arg-less "make" doesn't trigger "run_tests" all: -uname_M := $(shell uname -m 2>/dev/null || echo not) -ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) +ARCH ?= $(shell uname -m 2>/dev/null || echo not) +ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/) -TEST_PROGS := run.sh -TEST_FILES := basic.sh tbench.sh gitsource.sh +ifeq (x86,$(ARCH)) +TEST_FILES += ../../../power/x86/amd_pstate_tracer/amd_pstate_trace.py +TEST_FILES += ../../../power/x86/intel_pstate_tracer/intel_pstate_tracer.py +endif + +TEST_PROGS += run.sh +TEST_FILES += basic.sh tbench.sh gitsource.sh speedometer.sh speedometer_web.py selenium_server.sh include ../lib.mk diff --git a/tools/testing/selftests/amd-pstate/run.sh b/tools/testing/selftests/amd-pstate/run.sh index de4d8e9c9565..f29673528572 100755 --- a/tools/testing/selftests/amd-pstate/run.sh +++ b/tools/testing/selftests/amd-pstate/run.sh @@ -11,6 +11,7 @@ fi source basic.sh source tbench.sh source gitsource.sh +source speedometer.sh # amd-pstate-ut only run on x86/x86_64 AMD systems. ARCH=$(uname -m 2>/dev/null | sed -e 's/i.86/x86/' -e 's/x86_64/x86/') @@ -21,6 +22,7 @@ FUNC=all OUTFILE=selftest OUTFILE_TBENCH="$OUTFILE.tbench" OUTFILE_GIT="$OUTFILE.gitsource" +OUTFILE_SPEEDOMETER="$OUTFILE.speedometer" SYSFS= CPUROOT= @@ -136,6 +138,9 @@ amd_pstate_all() # gitsource amd_pstate_gitsource + + # speedometer + amd_pstate_speedometer } help() @@ -146,10 +151,11 @@ help() [-c ] + gitsource: Gitsource testing, + speedometer: Speedometer testing.>] [-t ] [-p ] - [-l ] + [-l ] [-i ] [-m ] \n" @@ -165,7 +171,7 @@ parse_arguments() help ;; - c) # --func_type (Function to perform: basic, tbench, gitsource (default: all)) + c) # --func_type (Function to perform: basic, tbench, gitsource, speedometer (default: all)) FUNC=$OPTARG ;; @@ -181,7 +187,7 @@ parse_arguments() PROCESS_NUM=$OPTARG ;; - l) # --tbench/gitsource-loop-times + l) # --tbench/gitsource/speedometer-loop-times LOOP_TIMES=$OPTARG ;; @@ -249,7 +255,7 @@ prerequisite() fi else case "$FUNC" in - "tbench" | "gitsource") + "tbench" | "gitsource" | "speedometer") if [ "$scaling_driver" != "$COMPARATIVE_TEST" ]; then echo "$0 # Skipped: Comparison test can only run on $COMPARISON_TEST driver." echo "$0 # Current cpufreq scaling driver is $scaling_driver." @@ -258,7 +264,7 @@ prerequisite() ;; *) - echo "$0 # Skipped: Comparison test are only for tbench or gitsource." + echo "$0 # Skipped: Comparison test are only for tbench, gitsource or speedometer." echo "$0 # Current comparative test is for $FUNC." exit $ksft_skip ;; @@ -284,6 +290,10 @@ prerequisite() "gitsource") command_perf ;; + + "speedometer") + command_perf + ;; esac SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` @@ -335,6 +345,10 @@ do_test() amd_pstate_gitsource ;; + "speedometer") + amd_pstate_speedometer + ;; + *) echo "Invalid [-f] function type" help @@ -364,6 +378,12 @@ pre_clear_dumps() rm -rf gitsource_*.png ;; + "speedometer") + rm -rf $OUTFILE.log + rm -rf $OUTFILE.backup_governor.log + rm -rf speedometer_*.png + ;; + *) ;; esac diff --git a/tools/testing/selftests/amd-pstate/selenium_server.sh b/tools/testing/selftests/amd-pstate/selenium_server.sh new file mode 100755 index 000000000000..d2cb5aeaea3f --- /dev/null +++ b/tools/testing/selftests/amd-pstate/selenium_server.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +# Before test speedometer benchmark, this script trigger selenium server. + +selenium_server_name="selenium-server.jar" +selenium_server_url="https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.3.0/selenium-server-4.3.0.jar" + +if [ ! -f $selenium_server_name ]; then + printf "Download selenium server, please wait a moment ...\n\n" + wget -O $selenium_server_name $selenium_server_url +fi + +printf "Run selenium server standalone ...\n\n" +java -jar $selenium_server_name standalone --port 9515 diff --git a/tools/testing/selftests/amd-pstate/speedometer.sh b/tools/testing/selftests/amd-pstate/speedometer.sh new file mode 100755 index 000000000000..ff86203cf651 --- /dev/null +++ b/tools/testing/selftests/amd-pstate/speedometer.sh @@ -0,0 +1,348 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +# Testing and monitor the cpu frequency and performance when +# this script trigger speedometer test. + +# protect against multiple inclusion +if [ $FILE_SPEEDOMETER ]; then + return 0 +else + FILE_SPEEDOMETER=DONE +fi + +speedometer_governors=("ondemand" "schedutil") + +# $1: governor, $2: round, $3: des-perf, $4: freq, $5: load, $6: goal, $7: time $8: energy, $9: PPW +store_csv_speedometer() +{ + echo "$1, $2, $3, $4, $5, $6, $7, $8, $9" | tee -a $OUTFILE_SPEEDOMETER.csv > /dev/null 2>&1 +} + +# clear some special lines +clear_csv_speedometer() +{ + if [ -f $OUTFILE_SPEEDOMETER.csv ]; then + sed -i '/Comprison(%)/d' $OUTFILE_SPEEDOMETER.csv + sed -i "/$(scaling_name)/d" $OUTFILE_SPEEDOMETER.csv + fi +} + +# find string $1 in file csv and get the number of lines +get_lines_csv_speedometer() +{ + if [ -f $OUTFILE_SPEEDOMETER.csv ]; then + return `grep -c "$1" $OUTFILE_SPEEDOMETER.csv` + else + return 0 + fi +} + +pre_clear_speedometer() +{ + post_clear_speedometer + rm -rf speedometer_*.png + clear_csv_speedometer +} + +post_clear_speedometer() +{ + rm -rf results/tracer-speedometer* + rm -rf $OUTFILE_SPEEDOMETER*.log + rm -rf $OUTFILE_SPEEDOMETER*.result +} + +# $1: governor, $2: loop +run_speedometer() +{ + local_host="`hostname --fqdn`" + local_ip=`host $local_host 2>/dev/null | awk '{print $NF}'` + + echo "Launching amd pstate tracer for $1 #$2 tracer_interval: $TRACER_INTERVAL" + ./amd_pstate_trace.py -n tracer-speedometer-$1-$2 -i $TRACER_INTERVAL > /dev/null 2>&1 & + + echo "Run speedometer for $1 #$2" + perf stat -a --per-socket -I 1000 -e power/energy-pkg/ > $OUTFILE_SPEEDOMETER-perf-$1-$2.log 2>&1 & pid_perf=$! + ./speedometer_web.py -i $local_ip -n $OUTFILE_SPEEDOMETER-web-$1-$2.log + + kill $pid_perf + for job in `jobs -p` + do + echo "Waiting for job id $job" + wait $job + done +} + +# $1: governor, $2: loop +parse_speedometer() +{ + awk '{print $5}' results/tracer-speedometer-$1-$2/cpu.csv | sed -e '1d' | sed s/,// > $OUTFILE_SPEEDOMETER-des-perf-$1-$2.log + avg_des_perf=$(awk 'BEGIN {i=0; sum=0};{i++; sum += $1};END {print sum/i}' $OUTFILE_SPEEDOMETER-des-perf-$1-$2.log) + printf "Speedometer-$1-#$2 avg des perf: $avg_des_perf\n" | tee -a $OUTFILE_SPEEDOMETER.result + + awk '{print $7}' results/tracer-speedometer-$1-$2/cpu.csv | sed -e '1d' | sed s/,// > $OUTFILE_SPEEDOMETER-freq-$1-$2.log + avg_freq=$(awk 'BEGIN {i=0; sum=0};{i++; sum += $1};END {print sum/i}' $OUTFILE_SPEEDOMETER-freq-$1-$2.log) + printf "Speedometer-$1-#$2 avg freq: $avg_freq\n" | tee -a $OUTFILE_SPEEDOMETER.result + + awk '{print $11}' results/tracer-speedometer-$1-$2/cpu.csv | sed -e '1d' | sed s/,// > $OUTFILE_SPEEDOMETER-load-$1-$2.log + avg_load=$(awk 'BEGIN {i=0; sum=0};{i++; sum += $1};END {print sum/i}' $OUTFILE_SPEEDOMETER-load-$1-$2.log) + printf "Speedometer-$1-#$2 avg load: $avg_load\n" | tee -a $OUTFILE_SPEEDOMETER.result + + awk '{print $1}' $OUTFILE_SPEEDOMETER-web-$1-$2.log > $OUTFILE_SPEEDOMETER-time-$1-$2.log + time_sum=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum}' $OUTFILE_SPEEDOMETER-time-$1-$2.log) + printf "Speedometer-$1-#$2 user time(s): $time_sum\n" | tee -a $OUTFILE_SPEEDOMETER.result + + awk '{print $2}' $OUTFILE_SPEEDOMETER-web-$1-$2.log > $OUTFILE_SPEEDOMETER-goal-$1-$2.log + goal_sum=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum}' $OUTFILE_SPEEDOMETER-goal-$1-$2.log) + printf "Speedometer-$1-#$2 goal: $goal_sum\n" | tee -a $OUTFILE_SPEEDOMETER.result + + grep Joules $OUTFILE_SPEEDOMETER-perf-$1-$2.log | awk '{print $4}' > $OUTFILE_SPEEDOMETER-energy-$1-$2.log + en_sum=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum}' $OUTFILE_SPEEDOMETER-energy-$1-$2.log) + printf "Speedometer-$1-#$2 power consumption(J): $en_sum\n" | tee -a $OUTFILE_SPEEDOMETER.result + + # Performance is runs per second, denoted G/60, where G is runs per minute. + # It is well known that P=E/t, where P is power measured in watts(W), E is energy measured in joules(J), + # and t is time measured in seconds(s). This means that performance per watt becomes + # G/60 G/60 Gt + # ----- = ----- = ----- + # P E/t 60*E + # with unit given by runs per watt. + ppw=`echo "scale=4;$goal_sum*$time_sum/($en_sum*60)" | bc | awk '{printf "%.4f", $0}'` + printf "Speedometer-$1 performance per watt(goal/w): $ppw\n" | tee -a $OUTFILE_SPEEDOMETER.result + printf "\n" | tee -a $OUTFILE_SPEEDOMETER.result + + driver_name=`echo $(scaling_name)` + store_csv_speedometer "$driver_name-$1" $2 $avg_des_perf $avg_freq $avg_load $goal_sum $time_sum $en_sum $ppw +} + +# $1: governor +loop_speedometer() +{ + printf "\nSpeedometer total test times is $LOOP_TIMES for $1\n\n" + for i in `seq 1 $LOOP_TIMES` + do + run_speedometer $1 $i + parse_speedometer $1 $i + done +} + +# $1: governor +gather_speedometer() +{ + printf "Speedometer test result for $1 (loops:$LOOP_TIMES)" | tee -a $OUTFILE_SPEEDOMETER.result + printf "\n--------------------------------------------------\n" | tee -a $OUTFILE_SPEEDOMETER.result + + grep "Speedometer-$1-#" $OUTFILE_SPEEDOMETER.result | grep "avg des perf:" | awk '{print $NF}' > $OUTFILE_SPEEDOMETER-des-perf-$1.log + avg_des_perf=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum/'$LOOP_TIMES'}' $OUTFILE_SPEEDOMETER-des-perf-$1.log) + printf "Speedometer-$1 avg des perf: $avg_des_perf\n" | tee -a $OUTFILE_SPEEDOMETER.result + + grep "Speedometer-$1-#" $OUTFILE_SPEEDOMETER.result | grep "avg freq:" | awk '{print $NF}' > $OUTFILE_SPEEDOMETER-freq-$1.log + avg_freq=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum/'$LOOP_TIMES'}' $OUTFILE_SPEEDOMETER-freq-$1.log) + printf "Speedometer-$1 avg freq: $avg_freq\n" | tee -a $OUTFILE_SPEEDOMETER.result + + grep "Speedometer-$1-#" $OUTFILE_SPEEDOMETER.result | grep "avg load:" | awk '{print $NF}' > $OUTFILE_SPEEDOMETER-load-$1.log + avg_load=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum/'$LOOP_TIMES'}' $OUTFILE_SPEEDOMETER-load-$1.log) + printf "Speedometer-$1 avg load: $avg_load\n" | tee -a $OUTFILE_SPEEDOMETER.result + + grep "Speedometer-$1-#" $OUTFILE_SPEEDOMETER.result | grep "goal:" | awk '{print $NF}' > $OUTFILE_SPEEDOMETER-goal-$1.log + avg_goal=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum/'$LOOP_TIMES'}' $OUTFILE_SPEEDOMETER-goal-$1.log) + printf "Speedometer-$1 avg goal: $avg_goal\n" | tee -a $OUTFILE_SPEEDOMETER.result + + grep "Speedometer-$1-#" $OUTFILE_SPEEDOMETER.result | grep "user time(s):" | awk '{print $NF}' > $OUTFILE_SPEEDOMETER-time-$1.log + time_sum=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum}' $OUTFILE_SPEEDOMETER-time-$1.log) + printf "Speedometer-$1 total user time(s): $time_sum\n" | tee -a $OUTFILE_SPEEDOMETER.result + + avg_time=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum/'$LOOP_TIMES'}' $OUTFILE_SPEEDOMETER-time-$1.log) + printf "Speedometer-$1 avg user times(s): $avg_time\n" | tee -a $OUTFILE_SPEEDOMETER.result + + grep "Speedometer-$1-#" $OUTFILE_SPEEDOMETER.result | grep "power consumption(J):" | awk '{print $NF}' > $OUTFILE_SPEEDOMETER-energy-$1.log + en_sum=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum}' $OUTFILE_SPEEDOMETER-energy-$1.log) + printf "Speedometer-$1 total power consumption(J): $en_sum\n" | tee -a $OUTFILE_SPEEDOMETER.result + + avg_en=$(awk 'BEGIN {sum=0};{sum += $1};END {print sum/'$LOOP_TIMES'}' $OUTFILE_SPEEDOMETER-energy-$1.log) + printf "Speedometer-$1 avg power consumption(J): $avg_en\n" | tee -a $OUTFILE_SPEEDOMETER.result + + # Permance is runs per second, denoted G/60, where G is runs per minute. + # It is well known that P=E/t, where P is power measured in watts(W), E is energy measured in joules(J), + # and t is time measured in seconds(s). This means that performance per watt becomes + # G/60 G/60 Gt + # ----- = ----- = ----- + # P E/t 60*E + # with unit given by runs per wattt. + ppw=`echo "scale=4;$avg_goal*$avg_time/($avg_en*60)" | bc | awk '{printf "%.4f", $0}'` + printf "Speedometer-$1 performance per watt(goal/w): $ppw\n" | tee -a $OUTFILE_SPEEDOMETER.result + printf "\n" | tee -a $OUTFILE_SPEEDOMETER.result + + driver_name=`echo $(scaling_name)` + store_csv_speedometer "$driver_name-$1" "Average" $avg_des_perf $avg_freq $avg_load $avg_goal $avg_time $avg_en $ppw +} + +# $1: base scaling_driver $2: base governor $3: comparison scaling_driver $4: comparison governor +__calc_comp_speedometer() +{ + base=`grep "$1-$2" $OUTFILE_SPEEDOMETER.csv | grep "Average"` + comp=`grep "$3-$4" $OUTFILE_SPEEDOMETER.csv | grep "Average"` + + if [ -n "$base" -a -n "$comp" ]; then + printf "\n==================================================\n" | tee -a $OUTFILE_SPEEDOMETER.result + printf "Speedometer comparison $1-$2 VS $3-$4" | tee -a $OUTFILE_SPEEDOMETER.result + printf "\n==================================================\n" | tee -a $OUTFILE_SPEEDOMETER.result + + # get the base values + des_perf_base=`echo "$base" | awk '{print $3}' | sed s/,//` + freq_base=`echo "$base" | awk '{print $4}' | sed s/,//` + load_base=`echo "$base" | awk '{print $5}' | sed s/,//` + goal_base=`echo "$base" | awk '{print $6}' | sed s/,//` + time_base=`echo "$base" | awk '{print $7}' | sed s/,//` + energy_base=`echo "$base" | awk '{print $8}' | sed s/,//` + ppw_base=`echo "$base" | awk '{print $9}' | sed s/,//` + + # get the comparison values + des_perf_comp=`echo "$comp" | awk '{print $3}' | sed s/,//` + freq_comp=`echo "$comp" | awk '{print $4}' | sed s/,//` + load_comp=`echo "$comp" | awk '{print $5}' | sed s/,//` + goal_comp=`echo "$comp" | awk '{print $6}' | sed s/,//` + time_comp=`echo "$comp" | awk '{print $7}' | sed s/,//` + energy_comp=`echo "$comp" | awk '{print $8}' | sed s/,//` + ppw_comp=`echo "$comp" | awk '{print $9}' | sed s/,//` + + # compare the base and comp values + des_perf_drop=`echo "scale=4;($des_perf_comp-$des_perf_base)*100/$des_perf_base" | bc | awk '{printf "%.4f", $0}'` + printf "Speedometer-$1 des perf base: $des_perf_base comprison: $des_perf_comp percent: $des_perf_drop\n" | tee -a $OUTFILE_SPEEDOMETER.result + + freq_drop=`echo "scale=4;($freq_comp-$freq_base)*100/$freq_base" | bc | awk '{printf "%.4f", $0}'` + printf "Speedometer-$1 freq base: $freq_base comprison: $freq_comp percent: $freq_drop\n" | tee -a $OUTFILE_SPEEDOMETER.result + + load_drop=`echo "scale=4;($load_comp-$load_base)*100/$load_base" | bc | awk '{printf "%.4f", $0}'` + printf "Speedometer-$1 load base: $load_base comprison: $load_comp percent: $load_drop\n" | tee -a $OUTFILE_SPEEDOMETER.result + + time_drop=`echo "scale=4;($time_comp-$time_base)*100/$time_base" | bc | awk '{printf "%.4f", $0}'` + printf "Speedometer-$1 time base: $time_base comprison: $time_comp percent: $time_drop\n" | tee -a $OUTFILE_SPEEDOMETER.result + + goal_drop=`echo "scale=4;($goal_comp-$goal_base)*100/$goal_base" | bc | awk '{printf "%.4f", $0}'` + printf "Speedometer-$1 goal base: $goal_base comprison: $goal_comp percent: $goal_drop\n" | tee -a $OUTFILE_SPEEDOMETER.result + + energy_drop=`echo "scale=4;($energy_comp-$energy_base)*100/$energy_base" | bc | awk '{printf "%.4f", $0}'` + printf "Speedometer-$1 energy base: $energy_base comprison: $energy_comp percent: $energy_drop\n" | tee -a $OUTFILE_SPEEDOMETER.result + + ppw_drop=`echo "scale=4;($ppw_comp-$ppw_base)*100/$ppw_base" | bc | awk '{printf "%.4f", $0}'` + printf "Speedometer-$1 performance per watt base: $ppw_base comprison: $ppw_comp percent: $ppw_drop\n" | tee -a $OUTFILE_SPEEDOMETER.result + printf "\n" | tee -a $OUTFILE_SPEEDOMETER.result + + store_csv_speedometer "$1-$2 VS $3-$4" "Comprison(%)" "$des_perf_drop" "$freq_drop" "$load_drop" "$goal_drop" "$time_drop" "$energy_drop" "$ppw_drop" + fi +} + +# calculate the comparison(%) +calc_comp_speedometer() +{ + # acpi-cpufreq-ondemand VS acpi-cpufreq-schedutil + __calc_comp_speedometer ${all_scaling_names[0]} ${speedometer_governors[0]} ${all_scaling_names[0]} ${speedometer_governors[1]} + + # amd-pstate-ondemand VS amd-pstate-schedutil + __calc_comp_speedometer ${all_scaling_names[1]} ${speedometer_governors[0]} ${all_scaling_names[1]} ${speedometer_governors[1]} + + # acpi-cpufreq-ondemand VS amd-pstate-ondemand + __calc_comp_speedometer ${all_scaling_names[0]} ${speedometer_governors[0]} ${all_scaling_names[1]} ${speedometer_governors[0]} + + # acpi-cpufreq-schedutil VS amd-pstate-schedutil + __calc_comp_speedometer ${all_scaling_names[0]} ${speedometer_governors[1]} ${all_scaling_names[1]} ${speedometer_governors[1]} +} + +# $1: file_name, $2: title, $3: ylable, $4: column +plot_png_speedometer() +{ + # all_scaling_names[1] all_scaling_names[0] flag + # amd-pstate acpi-cpufreq + # N N 0 + # N Y 1 + # Y N 2 + # Y Y 3 + ret=`grep -c "${all_scaling_names[1]}" $OUTFILE_SPEEDOMETER.csv` + if [ $ret -eq 0 ]; then + ret=`grep -c "${all_scaling_names[0]}" $OUTFILE_SPEEDOMETER.csv` + if [ $ret -eq 0 ]; then + flag=0 + else + flag=1 + fi + else + ret=`grep -c "${all_scaling_names[0]}" $OUTFILE_SPEEDOMETER.csv` + if [ $ret -eq 0 ]; then + flag=2 + else + flag=3 + fi + fi + + gnuplot << EOF + set term png + set output "$1" + + set title "$2" + set xlabel "Test Cycles (round)" + set ylabel "$3" + + set grid + set style data histogram + set style fill solid 0.5 border + set boxwidth 0.8 + + if ($flag == 1) { + plot \ + "<(sed -n -e 's/,//g' -e '/${all_scaling_names[0]}-${speedometer_governors[0]}/p' $OUTFILE_SPEEDOMETER.csv)" using $4:xtic(2) title "${all_scaling_names[0]}-${speedometer_governors[0]}", \ + "<(sed -n -e 's/,//g' -e '/${all_scaling_names[0]}-${speedometer_governors[1]}/p' $OUTFILE_SPEEDOMETER.csv)" using $4:xtic(2) title "${all_scaling_names[0]}-${speedometer_governors[1]}" + } else { + if ($flag == 2) { + plot \ + "<(sed -n -e 's/,//g' -e '/${all_scaling_names[1]}-${speedometer_governors[0]}/p' $OUTFILE_SPEEDOMETER.csv)" using $4:xtic(2) title "${all_scaling_names[1]}-${speedometer_governors[0]}", \ + "<(sed -n -e 's/,//g' -e '/${all_scaling_names[1]}-${speedometer_governors[1]}/p' $OUTFILE_SPEEDOMETER.csv)" using $4:xtic(2) title "${all_scaling_names[1]}-${speedometer_governors[1]}" + } else { + if ($flag == 3 ) { + plot \ + "<(sed -n -e 's/,//g' -e '/${all_scaling_names[0]}-${speedometer_governors[0]}/p' $OUTFILE_SPEEDOMETER.csv)" using $4:xtic(2) title "${all_scaling_names[0]}-${speedometer_governors[0]}", \ + "<(sed -n -e 's/,//g' -e '/${all_scaling_names[0]}-${speedometer_governors[1]}/p' $OUTFILE_SPEEDOMETER.csv)" using $4:xtic(2) title "${all_scaling_names[0]}-${speedometer_governors[1]}", \ + "<(sed -n -e 's/,//g' -e '/${all_scaling_names[1]}-${speedometer_governors[0]}/p' $OUTFILE_SPEEDOMETER.csv)" using $4:xtic(2) title "${all_scaling_names[1]}-${speedometer_governors[0]}", \ + "<(sed -n -e 's/,//g' -e '/${all_scaling_names[1]}-${speedometer_governors[1]}/p' $OUTFILE_SPEEDOMETER.csv)" using $4:xtic(2) title "${all_scaling_names[1]}-${speedometer_governors[1]}" + } + } + } + quit +EOF +} + +amd_pstate_speedometer() +{ + echo "!!!*** Please make sure to run selenium_server.sh on the server before you start testing speedometer. ***!!!" + + printf "\n---------------------------------------------\n" + printf "*** Running speedometer ***" + printf "\n---------------------------------------------\n" + + pre_clear_speedometer + + get_lines_csv_speedometer "Governor" + if [ $? -eq 0 ]; then + # add titles and unit for csv file + store_csv_speedometer "Governor" "Round" "Des-perf" "Freq" "Load" "Goal" "Time" "Energy" "Performance Per Watt" + store_csv_speedometer "Unit" "" "" "GHz" "" "Runs/Minute" "s" "J" "Runs/w" + fi + + backup_governor + for governor in ${speedometer_governors[*]} ; do + printf "\nSpecified governor is $governor\n\n" + switch_governor $governor + loop_speedometer $governor + gather_speedometer $governor + done + restore_governor + + plot_png_speedometer "speedometer_goal.png" "Speedometer Goal" "Goal (Runs/Minute)" 6 + plot_png_speedometer "speedometer_time.png" "Speedometer Time" "Time (s)" 7 + plot_png_speedometer "speedometer_energy.png" "Speedometer Energy" "Energy (J)" 8 + plot_png_speedometer "speedometer_ppw.png" "Speedometer Performance Per Watt" "Performance Per Watt (Runs/W)" 9 + + calc_comp_speedometer + + post_clear_speedometer +} diff --git a/tools/testing/selftests/amd-pstate/speedometer_web.py b/tools/testing/selftests/amd-pstate/speedometer_web.py new file mode 100755 index 000000000000..2f969e261ed6 --- /dev/null +++ b/tools/testing/selftests/amd-pstate/speedometer_web.py @@ -0,0 +1,106 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: GPL-2.0-only +# -*- coding: utf-8 -*- +# +""" This utility can be used to run speedometer. + +Prerequisites: + Python version 3.0.x or higher + chromium-browser + chromium-chromedriver + selenium + selenium-server + + see print_help(): for Usage and Output details + +""" + +from selenium import webdriver +from selenium.webdriver.chrome.options import Options +from selenium.webdriver.common.by import By +from selenium.webdriver.remote import webelement +from time import sleep +import os +import sys +import getopt + +test_result = False +ip_addr = "" +file_name = "" + +def print_help(): + print('speedometer_web.py:') + print(' Usage:') + print(' To generate speedometer test result file, parse and plot, use:') + print(' ./speedometer_web.py -i -n ') + +def store_data_file(time, result_text): + """ Store speedometer test results """ + + try: + f_handle = open(file_name, 'a') + str_buffer = "%u %s" % (time, result_text) + f_handle.write(str_buffer) + f_handle.close() + except: + print('IO error', file_name) + return + +def remove_data_file(): + """ Remove data files """ + + if os.path.exists(file_name): + os.remove(file_name) + +if __name__ == "__main__": + + valid1 = False + valid2 = False + + try: + opts, args = getopt.getopt(sys.argv[1:],"hn:i:",["help","name="]) + except getopt.GetoptError: + print_help() + sys.exit(2) + for opt, arg in opts: + if opt == '-h': + print_help() + sys.exit() + elif opt in ("-i", "--ip"): + valid1 = True + ip_addr = arg + elif opt in ("-n", "--name"): + valid2 = True + file_name = arg + + if (valid1 and valid2) : + chrome_options = Options() + chrome_options.add_argument('--no-sandbox') + chrome_options.add_argument('--incognito') + + driver = webdriver.Remote(command_executor='http://{}:9515/wd/hub'.format(ip_addr), options=chrome_options) + + driver.get('https://browserbench.org/Speedometer2.0/') + sleep(1) + + driver.find_element(By.XPATH,"//div[@class='buttons']/button").click() + for i in range(0, 200, +1): + print("\rRun speedometer: \033[0;31m{:2}\033[0ms".format(i), end="", flush=True) + sleep(1) + if i > 50: + result = driver.find_element(By.XPATH,"//div[@id='result-number']") + if result.text: + test_result = True + print("\nTest result: " + result.text) + remove_data_file() + store_data_file(i, result.text) + break + + if test_result == False: + print("\nTest fail, please test again!") + + driver.quit() + else: + print_help() + sys.exit() + From patchwork Fri Mar 31 08:26:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Meng, Li (Jassmine)" X-Patchwork-Id: 13195413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FE27C77B60 for ; Fri, 31 Mar 2023 08:27:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230331AbjCaI1q (ORCPT ); Fri, 31 Mar 2023 04:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230475AbjCaI1n (ORCPT ); Fri, 31 Mar 2023 04:27:43 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 699CF18809; Fri, 31 Mar 2023 01:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QmoH61vO8hLf5hO9vi3iVpNoLUCcOIHAlMW2qjcHf+95EoV09fWxxwJJvQxtgFtBD83QUEObKV18StfHUCEAIxt923Z6R9J0YkRzvklyZ7fsjPZIJTbfVK7Hh3AE/RH92WvKTu3XE+oCosJYvrnX7OFSKzolYNEGfbix+hSG50XFCmvVRi6RASoCQCag4sXRsEgoxXssOqnghm5Hu4a0ha1hvgRi+mt+pRXbW7nUHWh1Qo70R8au+wEoSN0LmJ152jZHcoe61B3iPFask9a0XDRfhkjGGXD5g0Asf1QjO2SMt3z6JohUfcFQtVS++P59CGLUqTpVKAMG8W/NvKInjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JJuzzUGNVlcJ2WGAlAfgfIYFgZzZy/JuVBhhxTB2PDY=; b=gD5e7anMalBtQPITaUNi7p/bHrC9pQGk32/VszQL97jQicWcXtFCzGGjX/wORZjyJ/wCZCNgGEaDkpJ+6Ik9V9/gVwF5lZLJvdfARvfKSRGURHhHjrv9xuTOX2O7E6ImBuQbcHIuxob223hGdNUw9eeTytkX7FiN1UF0M4bEZ88Qbz3HE1E2S24OzNyNavgfrt+eUI5UyaxdQQNAZJ1222mTS4gZza10cQRjMUKS1mljcVMwkwP2TvpKxlhdJRblD/Loj3Qc/+XsHwBquLqbQtzECin9Kvw3J3yP+35nZ5j4iQQ5Y7+58oeZVf39YIahh8+nsKueQJr8u3YUAohS7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JJuzzUGNVlcJ2WGAlAfgfIYFgZzZy/JuVBhhxTB2PDY=; b=ZcuEqLkyCBa1SZ3C+4ymH3MPM4U/94rPclvRZdAY043865vpBXVXxYBeLlF2b2ag6NLnYRUu3XD+1zZll87l68G+71fliDoWMVJCy+dqUF8gNH767of/8iztGTCk9bbTNEM/wCznIvNSfRi1YNA7MW5Tg+VbnrU6mafMGjb9JiI= Received: from BLAPR03CA0178.namprd03.prod.outlook.com (2603:10b6:208:32f::32) by DM4PR12MB6088.namprd12.prod.outlook.com (2603:10b6:8:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.35; Fri, 31 Mar 2023 08:27:38 +0000 Received: from BL02EPF000145B9.namprd05.prod.outlook.com (2603:10b6:208:32f:cafe::e3) by BLAPR03CA0178.outlook.office365.com (2603:10b6:208:32f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22 via Frontend Transport; Fri, 31 Mar 2023 08:27:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF000145B9.mail.protection.outlook.com (10.167.241.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6222.35 via Frontend Transport; Fri, 31 Mar 2023 08:27:37 +0000 Received: from jasmine-meng.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 31 Mar 2023 03:27:33 -0500 From: Meng Li To: Shuah Khan , Huang Rui , CC: "Rafael J . Wysocki" , Nathan Fontenot , Deepak Sharma , "Alex Deucher" , Mario Limonciello , Shimmer Huang , "Perry Yuan" , Xiaojian Du , Viresh Kumar , Borislav Petkov , , Meng Li Subject: [PATCH V3 2/2] Documentation: amd-pstate: Add speedometer test introduction Date: Fri, 31 Mar 2023 16:26:59 +0800 Message-ID: <20230331082659.1887946-3-li.meng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230331082659.1887946-1-li.meng@amd.com> References: <20230331082659.1887946-1-li.meng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000145B9:EE_|DM4PR12MB6088:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ef0f9f3-bd12-44b5-3e0b-08db31c1c942 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0AVK7pHSgahDYnSUnaS7DFe78h4G6Jkk2MZOpNSSqjot3qlnlYDfSftdYRnJvjRuWh4oFjAhuAp1Hl0aCOhr51ovUMbUQ2p70kpBOPvE51NJrabVSLdM3wIlnJJpFnMbCRcCHt8W2yQYsP9RZ3aSsNi9lSejcpV2HI/WHWSO5QK9HbUWviM0d/lV0RrprIt4EHRNi8tFoplNgDwecmqKg3nPd7U+CpsgWDt5Gr3pfDTcynlv9EcsCWnV8A5Hh8sf4PWAd3i742KHd43bYZtGESLEovQ0vG3X7eIFvb5F43cHdjLDpZnqcbYoZiN3CquDpkYDpZP/pZLhn8oCdQ9j8F1jfrAn1WA+gOgGMNcZdoGqjtCiF1/kKBGSryEFBL+EcX1EeOtefKeRxECGOdbCbK7f8xB7SkH01JsvwXeXer6JccDwteIVoF32yOGlraf0R5J6EgHuQTSE0opPAxAFOjBZBdmK2X6pzv1uRUaUqJh9jOmgC5u6iWAlo5LrNhhl0Vfrj5nHAkeuBu5MvqV1jYF3VjHlOyHBlkRlw38wGQXr6RhuqaWtpmo0Jvf7TbQT/O55ly/cXvkIwnZW/55fGum5X3KthY//e4ch/w3BElf1D3XndIUAj+iFEnsTcjDVI9zeR77hGdJbgv12w5FgA5R1hAQK39ClT0y2NUmXMelIe7nKrZom4ozAicTtYw6vO4fOA16NRLWV1nW/jv10qPwgPiCkQeUZW8JIqF/DLpw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(136003)(39860400002)(396003)(451199021)(36840700001)(46966006)(40470700004)(36756003)(110136005)(478600001)(7696005)(86362001)(83380400001)(4326008)(70206006)(54906003)(6666004)(41300700001)(316002)(70586007)(5660300002)(82310400005)(2616005)(82740400003)(40480700001)(8936002)(8676002)(81166007)(36860700001)(16526019)(356005)(1076003)(186003)(47076005)(66574015)(336012)(426003)(26005)(2906002)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2023 08:27:37.7599 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ef0f9f3-bd12-44b5-3e0b-08db31c1c942 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000145B9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6088 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Introduce speedometer test cases design and implementation. Monitor cpus changes about performance and power consumption etc. Signed-off-by: Meng Li --- Documentation/admin-guide/pm/amd-pstate.rst | 88 +++++++++++++++++++-- 1 file changed, 81 insertions(+), 7 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 6e5298b521b1..d0158128a0a3 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -517,6 +517,23 @@ Unit Tests for amd-pstate The specified governor is ondemand or schedutil. Gitsource can also be tested on the ``acpi-cpufreq`` kernel driver for comparison. + 4). Speedometer test + + Test and monitor the cpu changes when running speedometer benchmark under the specified governor. + These changes include desire performance, frequency, load, time, energy etc. + The specified governor is ondemand or schedutil. + Speedometer can also be tested on the ``acpi-cpufreq`` kernel driver for comparison. + +#. Preparations before tests + + 1). Speedometer + + + Python version 3.0.x or higher + + Install chromium-browser + + Install chromium-chromedriver + + Install selenium on the client + + Install selenium-server on the server + #. How to execute the tests We use test module in the kselftest frameworks to implement it. @@ -536,7 +553,7 @@ Unit Tests for amd-pstate + make perf :: $ cd tools/perf/ - $ make + $ make && make install 2). Installation & Steps :: @@ -548,11 +565,14 @@ Unit Tests for amd-pstate 3). Specified test case :: $ cd ~/kselftest/amd-pstate - $ sudo ./run.sh -t basic - $ sudo ./run.sh -t tbench - $ sudo ./run.sh -t tbench -m acpi-cpufreq - $ sudo ./run.sh -t gitsource - $ sudo ./run.sh -t gitsource -m acpi-cpufreq + $ sudo ./run.sh -c basic + $ sudo ./run.sh -c tbench + $ sudo ./run.sh -c tbench -m acpi-cpufreq + $ sudo ./run.sh -c gitsource + $ sudo ./run.sh -c gitsource -m acpi-cpufreq + $ ./selenium_server.sh + $ sudo ./run.sh -c speedometer + $ sudo ./run.sh -c speedometer -m acpi-cpufreq $ ./run.sh --help ./run.sh: illegal option -- - Usage: ./run.sh [OPTION...] @@ -561,7 +581,8 @@ Unit Tests for amd-pstate [-c ] + gitsource: Gitsource testing, + speedometer: Speedometer testing.>] [-t ] [-p ] [-l ] @@ -687,6 +708,59 @@ Unit Tests for amd-pstate + acpi-cpufreq-schedutil VS amd-pstate-schedutil | Comprison(%) | | | | 2.1115 | 4.2873 | -4.1110 | +-------------------------------------------------+--------------+----------+----------+----------+-------------+---------+----------------------+ + + speedometer + + When you finish test, you will get selftest.speedometer.csv and png images. + The selftest.speedometer.csv file contains the raw data and the drop of the comparative test. + The png images shows the goal, time, energy and performan per watt of each test. + Open selftest.speedometer.csv : + + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + Governor | Round | Des-perf | Freq | Load | Goal | Time | Energy | Performance Per Watt | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + Unit | | | GHz | | Runs/Minute | s | J | Runs/w | + +=================================================+==============+==========+==========+==========+=============+=============+=========+======================+ + + acpi-cpufreq-ondemand | 1 | | | | 209 | 51 | 731.84 | 0.2427 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + acpi-cpufreq-ondemand | 2 | | | | 205 | 51 | 759.03 | 0.2295 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + acpi-cpufreq-ondemand | 3 | | | | 206 | 51 | 755.15 | 0.2318 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + acpi-cpufreq-ondemand | Average | | | | 206.667 | 51 | 748.673 | 0.2346 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + acpi-cpufreq-schedutil | 1 | | | | 206 | 56 | 775.08 | 0.248 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + acpi-cpufreq-schedutil | 2 | | | | 204 | 51 | 762.06 | 0.2275 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + acpi-cpufreq-schedutil | 3 | | | | 207 | 56 | 776.35 | 0.2488 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + acpi-cpufreq-schedutil | Average | | | | 205.667 | 54.3333 | 771.163 | 0.2415 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + amd-pstate-ondemand | 1 | 24.7974 | 1.73142 | 7.71728 | 195 | 64 | 756.6 | 0.2749 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + amd-pstate-ondemand | 2 | 26.1653 | 1.91492 | 8.5525 | 195 | 51 | 705.67 | 0.2348 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + amd-pstate-ondemand | 3 | 24.1789 | 1.69516 | 7.41152 | 196 | 65 | 758.98 | 0.2797 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + amd-pstate-ondemand | Average | 25.0472 | 1.7805 | 7.89377 | 195.333 | 60 | 740.417 | 0.2638 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + amd-pstate-schedutil | 1 | 67.0214 | 2.76691 | 17.1314 | 197 | 51 | 737.52 | 0.227 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + amd-pstate-schedutil | 2 | 64.3032 | 2.75981 | 16.1196 | 198 | 55 | 763.57 | 0.2376 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + amd-pstate-schedutil | 3 | 65.5175 | 2.59423 | 17.0067 | 201 | 51 | 735.96 | 0.2321 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + amd-pstate-schedutil | Average | 65.614 | 2.70698 | 16.7526 | 198.667 | 52.3333 | 745.683 | 0.2323 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + acpi-cpufreq-ondemand VS acpi-cpufreq-schedutil | Comprison(%) | | | | -0.4838 | 6.5358 | 3.0039 | 2.9411 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + amd-pstate-ondemand VS amd-pstate-schedutil | Comprison(%) | 161.9614 | 52.0348 | 112.2255 | 1.7068 | -12.7778 | 0.7112 | -11.9408 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + acpi-cpufreq-ondemand VS amd-pstate-ondemand | Comprison(%) | | | | -5.4841 | 17.647 | -1.1027 | 12.4467 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + + acpi-cpufreq-schedutil VS amd-pstate-schedutil | Comprison(%) | | | | -3.4035 | -3.6809 | -3.3041 | -3.8095 | + +-------------------------------------------------+--------------+----------+----------+----------+-------------+-------------+---------+----------------------+ + Reference ===========