From patchwork Tue Aug 6 08:10:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Szu X-Patchwork-Id: 13754547 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060.outbound.protection.outlook.com [40.107.244.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32AB516EB40; Tue, 6 Aug 2024 08:10:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722931853; cv=fail; b=K06+Zxc1i0GK8YtfM0SNzWyjnJDsq18fXQBOd2Wmxto1dB08Umhn3FDtoqYgw9l7DZaCYkER16M4aiWMbLbZblWW9pP2XeQlTZ+JZEOuV+xsvtBf5fSmD0HVRhIwfeYza94fhfk10ywVdj57K1f5OcBcm/xljO15al2dQNUMEZ0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722931853; c=relaxed/simple; bh=EikHq8El/gI9/Vfd2PSGfeoa4aUlVCM2zDgo2Z8pwHU=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=r/M0YRb0USs0g30insdLHO8FgRY+exxdTCr6W9g+Cbj+LPPoQb4QxB63eIpjmLYBft5KvhtJ2oAvmp9ISf/MkoOjZpZeA442Rgg6x6vLAFYiDKfcEgkE0ll54O1xCXPXg0H/pXedEO6Z7/r0K9Q71N2ydnHQo7DqwlEGMK9B524= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=j29ELkaN; arc=fail smtp.client-ip=40.107.244.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="j29ELkaN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u/ysp8VdzbHKztUzjVx1swHD+geGfcIhTdWDtcK+p+cN9s3GXXd0eqLiS6jAZLgRzdaQldZIrAPrxLqmnjVqWF2zWj+cfvnXJYw7aTihD7Ej3TGqwywRxoUsRZYtJX+Nwf5sk445H909mCfMdi8ASx8caQMhvb5rpRk1keLA/65/9RqKxbTJRJcEkWEwVxOt4upMz79EviT02D/7N5HG02KTpgw1H01GLRqzRGcHtbihF8OC2osbhQYGzC5JFe23NGg1CG564s+bfGeHUIUFEpX88FsjDOxDgJ+z5spdJjqwUs6S1kP+wAWNBcszCAqDBTlYX8SBPV/houoAskH8Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Bs2ggEnyeRQmDOLduo7ymTf/U4W++9raBxSHrQyjOl0=; b=rp0MbUR8Xfd9qG7kAI0FO7AfJoNTx1kBDmMxmfX0PaQtFCNS/94hgqDTT+bv6j1OBL/4loQ17waP6/v9lqZ/NtWTGFp48Sju4W/lqkX4CLnGqdZv/VRIcRLrhLy0oEPJtgo+yckWQt+ulCttj0m3ELULDeuFij0+Gwsj6KmRNiNLIjZ7BIs1X3PeJeurDG04Y7ahD9kZGac+yOLCosLfXJ/hIFMTx5RGg0vnjcu6dIK/ggCUFYrQJoa+ZTh6A/icVX1wvyKzafyOHxV8+f16Hz5E+JQ7nxphhvJyo88l41MsyIR6hNhkf7Juoe4o0EpKmkYLjUSBl+7DT+E23HrQCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bs2ggEnyeRQmDOLduo7ymTf/U4W++9raBxSHrQyjOl0=; b=j29ELkaNto47bTvHBW0lM6vC34nKNQVoQLpUaz3Equ7RG3lZFs9sD6DnCOOQxtlzvj21APMdzvYf+Y9KYwPjzwnp0k8kI1Ekbas7HaAmNAwDaMTVlVY6QimQxPBNtNtb1Nv3QSQD+pB2cWn/AWFpQO/FblurYVEPWlGVHrAXYOybSE4ybkC4Trby1JLtisq9fwAh9D5ej7CI7jSxVyyTrsnZVnqt6/Kz1vYn3ENmvruIREUR6wnBkR+bM5Po3Kc9W65riQxosWOKMfymYO1sFPRh/V2g2DhXYTXcXhnTn7aFj64ls3wvc5g4KCHzVtCRGzw3AsAX339qat+RskAKNg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from PH0PR12MB7840.namprd12.prod.outlook.com (2603:10b6:510:28a::16) by SJ2PR12MB8882.namprd12.prod.outlook.com (2603:10b6:a03:537::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.25; Tue, 6 Aug 2024 08:10:49 +0000 Received: from PH0PR12MB7840.namprd12.prod.outlook.com ([fe80::dbe7:2850:c5de:b17f]) by PH0PR12MB7840.namprd12.prod.outlook.com ([fe80::dbe7:2850:c5de:b17f%6]) with mapi id 15.20.7807.026; Tue, 6 Aug 2024 08:10:49 +0000 From: Jeremy Szu To: shuah@kernel.org, linux-kselftest@vger.kernel.org, james.clark@arm.com, linux-perf-users@vger.kernel.org Cc: Jeremy Szu Subject: [PATCH] selftest/perf: Add perf-test to perform perf testcase Date: Tue, 6 Aug 2024 16:10:43 +0800 Message-ID: <20240806081043.44935-1-jszu@nvidia.com> X-Mailer: git-send-email 2.45.2 X-ClientProxiedBy: OSTP286CA0015.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:223::10) To PH0PR12MB7840.namprd12.prod.outlook.com (2603:10b6:510:28a::16) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR12MB7840:EE_|SJ2PR12MB8882:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f561849-35a5-4c57-4771-08dcb5ef484d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: J9UzMx2wEJbSnFJ29YUEGk+czaWAhz3yUk4LSHJWHj5Ej7sEErDy0lLUaiQnrjx7ul6x8Ln+2NZZejy5ef1fgJ22g8HoNox3WxrDi9scPdPVDMxO9D6ELnr7y+5Ks1fWmCT1OGrHEC20yeHyL3h6FnUzj6mrEbIfI0K08pHkRzXmHLcKKnHY5x0VtIKBbFgloPz80o3sf+vk7+cn1PC229X54wDHaIXibDA/xTPbFgCMthTgJksA7a+bRzY+NEPVhXQYgF6ZsbR6Eg/nAqhoe0zrjuO8+tvAej0xh3tUo1J+gGPMMAQ88lgHnIW2q/MKgNT68unLA8xDo8p43dZTKSwNo6agnMi3e+XA6fJtPGXheHqo6dT+1kYcV77tCc63Wi17wxm02JiUWtCE1fTQN4tfSH1XMt8rqgrm4BJbhZMJKt2TFmStyzkn9ts98SxhVBgW8BHlTQAv/8REPhwjqGzjAWaoLVJ9jJrYTIcrFIAWwiaNzgbLA3dNdEgp882CM4kEDsO4vncA0ZdJq+0BsBmKX2MixKiaEu6CRttdmmQrUxqYW1NSDjp9gwG43BnbRFclmYZ1tXPEa+8ww8xWcwStUYSy7pYzCTRwZEum+df/tjwOtQJqjweXaLdKYR9ICNUXf+3JGFKeFIERMVaY8Ae2+LGzwVgC+6/WTiMfYuZOXkwrEFkNza/zVV/ZhoGb47JLtdWW/lp30bHFPp6z2dnxqVYmbUoe4jV0UhD0MvtBUS51F8ksePpcfkffIhPVtD8Zl/7TkXJvp5ac1iBvDnD9fl3eMQdQ7zW/8TFv53/c6BDHbHn/5xKJuvKrtHbctbQx3BWEk1YDVGID8BR9YSlCDZLbO2g65L5wzFf+e+nQLe0wArwLMffBdHL59OROlpMl3gX9yzy/jK/8bRJ8nj6uFhbGv5QU2StOgbUFWXoJP1mFVOw8f1vWWnUamW0FC50jCfFq8F/o2CehBLV+iEYGyfnA5hMaCEdsK5UXFsDrICwAu97k5oCHjJVMzklOPZpdZmbkds5MUATrfH4kOn5et/U7iWlicHR/cJbb1EXqxghTT/LbiwgRVFZ75fgYo73X15lsMd7YlYniFf/OZnMtPPRMVIRPhGVGC5SsLs5yh2bDxn7+JQv1uopTIuI8nAlsrlzWBeU2ih3TdpGYQVP8b2lfAQbn7tAn1gs5uS3wxw0vSflUOmbT+l3J34J7LT8CF0gb/9TyMycG/o8eAC23/J74eYvu7Jxkc2o8ryepZtkdQpeXhKe+twRIFr4jts5PNmfRZvpcdzH3fwbq5GPr1ZFn6PlLwur8lGodmohSoZqmt+/lAfBoqhtfogJakru7QSDTzB2CjRPRaDg67w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR12MB7840.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Azp62L/qF3lHuhntQIdnv1FXqrRz03+kamAyBj/OB0bDifTql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YADumBl8orHx/poRj/vhSyDXMNYR/3eBuDBKqEKI5ooeDKLZP/QL7PxlDbB4P62OXukBOfHXnxB8GvoYG79E7MLc6XAttiPc5+hdgvfDN7OhnDGs3YKJopCTT1OJc+w6XqH3s6qopuNiBseifX5yeO1USnsWRxUn7WrPCPGZ8Yt1GzPknxkQzJh4BHozYgameMGwtvtB5XbJHB7ux+qEwtU674LG8sZ/ZAr+br+3KUeRrO3spZHdS1EXDhGpOHtfsPFkSw8gzQU+w/2Zb4diYW2VhoCHVv3xilfKRa3CwLXfLojKtjEtLicEZLhF0oVLo0/mkmepJrE9jFynvVVmU0XmA4+X43ricJ7YBNZzjIxP92Q8f6ew9qLv5hvvZI2AmYwZIQB0TE7RvG000aK4Vqd/KxODfEadQ8EVotkSCSi4wRu2fs1k6HbRk+RYGRFJgZo= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f561849-35a5-4c57-4771-08dcb5ef484d X-MS-Exchange-CrossTenant-AuthSource: PH0PR12MB7840.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 08:10:49.6512 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2trT/79T2G+e2u6F2q7BnGF5iEE7NjeRrxJHa2nrxZ/IEFRVEcAVRHNqMa/nhHbF X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8882 The perf test supports testing many functions and includes a way to detect the prerequisites for each test case. Add a script to launch the perf test. Signed-off-by: Jeremy Szu --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/perf/Makefile | 5 ++++ tools/testing/selftests/perf/perf_test.sh | 30 +++++++++++++++++++++++ tools/testing/selftests/perf/settings | 1 + 4 files changed, 37 insertions(+) create mode 100644 tools/testing/selftests/perf/Makefile create mode 100755 tools/testing/selftests/perf/perf_test.sh create mode 100644 tools/testing/selftests/perf/settings diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 9039f3709affb..7598dd39cad28 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -67,6 +67,7 @@ TARGETS += net/openvswitch TARGETS += net/tcp_ao TARGETS += net/netfilter TARGETS += nsfs +TARGETS += perf TARGETS += perf_events TARGETS += pidfd TARGETS += pid_namespace diff --git a/tools/testing/selftests/perf/Makefile b/tools/testing/selftests/perf/Makefile new file mode 100644 index 0000000000000..72d90c71ab290 --- /dev/null +++ b/tools/testing/selftests/perf/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + +TEST_PROGS := perf_test.sh + +include ../lib.mk diff --git a/tools/testing/selftests/perf/perf_test.sh b/tools/testing/selftests/perf/perf_test.sh new file mode 100755 index 0000000000000..ee78b4f9906cd --- /dev/null +++ b/tools/testing/selftests/perf/perf_test.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +skip() { + echo "SKIP: $1" + exit 4 +} + +fail() { + echo "FAIL: $1" + exit 255 +} + +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + [ "$(id -u)" -ne 0 ] && \ + skip "this test must be run as root." + which perf >/dev/null 2>&1 || \ + skip "perf is not installed." + + cmd_output=$(perf test -vv 2>&1) + perf_ret=$? + + if [ $perf_ret -ne 0 ]; then + (IFS='\n'; echo $cmd_output) + fail "perf command returns non-zero." + elif [[ $cmd_output == *"FAILED!"* ]]; then + (IFS='\n'; echo $cmd_output) + fail "perf test got FAILED!" + fi +fi diff --git a/tools/testing/selftests/perf/settings b/tools/testing/selftests/perf/settings new file mode 100644 index 0000000000000..a62d2fa1275c6 --- /dev/null +++ b/tools/testing/selftests/perf/settings @@ -0,0 +1 @@ +timeout=600