From patchwork Fri May 3 02:32:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 13652283 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2062.outbound.protection.outlook.com [40.107.236.62]) (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 1E14F57CBF; Fri, 3 May 2024 02:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714703536; cv=fail; b=LGvwXJ9JHkTO72ST20EJi7jH7t+KhaVknmgI9GvIgbeD2IsgYlSferCi3EMplZW27p/khBdBPvBTTte0ULdAXVVBvbv5G1jQ1xD0z5XeOLJpari0Cgix0NiYVJJ1CE6BxylxwTHI2iIb6oCW7j1H86h0DBZ8oJLJsI4VksLN0y4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714703536; c=relaxed/simple; bh=fqqE/VkxJ8SzEXx4uQcG7Ye+u4OlMWicHrS6ifpJwGU=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=e45u+ghiKWriw5x4YpDWKbgfnHrVtTp9TNAtmi9oqfIqf7C8aBodIXMenaCpMaGpzypH39d59+sNdPNLKwVR/LJkO3q/Jre+SDb7AZffoSlHpp+aY8ewxvCBoX9HL2sexK32ota23J/M3O54xhC8gBtXxsCv9ghLLWPfC2Fbxgw= 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=oQnakwLw; arc=fail smtp.client-ip=40.107.236.62 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="oQnakwLw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ey3VpzU/UCg/zrfrw4SXRZ/It+DW7FzGPuBL6ZGvGO65qDsfZA2n1QPFSgYfoM90b5yWZ68z5BbOhrQqUl1c1K4gFhFAaGPAFMocdvLgaaqdnyVD5SoiwRnrQ77DXCmL7cvHrc+WaQt2lYsqsKswzcFVAoduo6LZQZdknbPxmaopE8r6s24s+si4QKw4vUbyqrh4vd77t1Pdq0m0fYy4CjQtJMk7QuDLKDS+NwE0V3abYYeqLvKzfssiiZl16HTvzIe3Bp5gmKphNt6xp1OpcyrLGmothU18gNZ4+8f3ny2y8SVQg/0kAx73UdcZlaKUMjXxAbk+T/5TezTxm0vtSQ== 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=soo+zhRBM6cBLzZ+I5T/E2J3L+AnLMNAHJwZzQXiK90=; b=HVnBLzbjnEySR/ETy49g6VPJ5ROaNHYHI+balxZhIfVVfvYL3Zbw5virrXFCZ2jnoCn1SqJZwhb+/il95YjT4w7iS1J8Ih+YLCqucz99Ak0M+8eZSm+dY1vACS6a9GlUTjg8hOiatRUqUJYWv8knjB/oZPjXtMbrFQ3XGjrrUNRdJYhSjr5VTVQKm44TK8Q99pY3Ed0AgW2BQGnjZKEYXtvV0c+11jqDN+dUsjd0swimmDEdvWbm7yskuJlDVYKuiou6b8eTrni3X8c2vVeKk2sN6BUC1Y4Dzn7kQa8ROUt4hiJ149rEpYYJSXpB8g+YEjDAbbO6sIK2K2VEWbSyPw== 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=soo+zhRBM6cBLzZ+I5T/E2J3L+AnLMNAHJwZzQXiK90=; b=oQnakwLwlavvLpyeLkn3twYtZRAO6w8qiPkhvdWuHWzLGn1w2QuEBEUlUnU8HcxBh5jc+wfrx0AanMTIplthxRUyC2GKNe3Irm7lJYFfvLeiIFnvhU7eiKKCSU/QW89tCHKeoTIq1WFudktGrubP5mYj72IlS+r7by1hpwNAY36OaWxl5rMcnrmEJfsAeFoWdGTEC3MDOub/WV6GZ9wCfRcveU9koqaqYN7X38vQiu0sInoQcMHH+aJ/HgpJuNxhalL7wctcwB+qsdJubfWavYwj1ZUoq+3/ferL1osz+EMFHiSD+aUVpxvTAvnI3UiHdwtSj2H01sdsFHvoE0plNg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) by BY5PR12MB4193.namprd12.prod.outlook.com (2603:10b6:a03:20c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.30; Fri, 3 May 2024 02:32:11 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::2cf4:5198:354a:cd07]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::2cf4:5198:354a:cd07%4]) with mapi id 15.20.7519.035; Fri, 3 May 2024 02:32:11 +0000 From: John Hubbard To: Shuah Khan Cc: Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Fenghua Yu , Reinette Chatre , Valentin Obst , linux-kselftest@vger.kernel.org, LKML , llvm@lists.linux.dev, John Hubbard Subject: [PATCH] selftests/resctrl: fix clang build warnings related to abs(), labs() calls Date: Thu, 2 May 2024 19:32:09 -0700 Message-ID: <20240503023209.80787-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.45.0 X-NVConfidentiality: public X-ClientProxiedBy: SJ0PR13CA0127.namprd13.prod.outlook.com (2603:10b6:a03:2c6::12) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::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: BY5PR12MB4130:EE_|BY5PR12MB4193:EE_ X-MS-Office365-Filtering-Correlation-Id: b0c2ee7e-b568-4e30-35ab-08dc6b193c54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|7416005|1800799015; X-Microsoft-Antispam-Message-Info: 8onFU7QxvmG4rLVbdFBXk6Ya11jY335ahaT0iASsOEe1jsQVvVs7Djje5tRcH5Y8Y9j+tWm3OpWuATNHIRunghapWLX2tqRmkPv/HxyjA9BiANU8GHLb/b9nFP7LRGw8nqVJae6Mw5AIfWsAHcALzUW4Npuk274kWWZpd1q3dpmj/wEU3nzCMzjO3L/+wW6pS5Lx/m22c4U04oS85eIZ65bPtWciDSLRPSstzX7faMaoKQcBQgsBKIpPd91C222fD8ePSgJcC97e99rufNCslNlk89lbc7fDW8gdqvb557tTUaFtAAuBbdhSrMfqVzlFIgzntlkOxvfVsL7whhd44irt7y6l6OCwPxSndfKmC+dO/5TAsBulZBvTITR5tClNeNYmmQc99IjOU5OzwFCEvC9yjPBjhZtHiNk5PBVIVRqqZlNmhVuCY7c6Zbf9ju9+c+3aVPcULShngZ57zcERXY25/WnOVWX2uKA8quGYi97an2lSay3b5+QWWgW5RY3OyKBcn/TnpJJleZ8wGMyRr7lkAsY98UpJ2H3NnAlkEm7c+ThURoB1XBQxyYglFJ9j0YdR29Zo0qwTP7F1wC8ZpNcK/Nn61avWSlIgd1G7YwJiKzHKm1YX98VcllHpc93k7kGX6RgeiSOjnI8VDDAzwhmVPjlOSiXGRzgmTcgWLkgNtB3qbqtLnpCwc5a7RQlyjhkfuXFGZK6gr/tb3vdtzuejun5ii3JDF7Gj767pk2aOVH4lbOhT6McOZTRirtz6XSNYkKdGzsK+7CxUAXfpj0gplqypkAWIys50FODpk3c/WgOGZoxHowaTexcO9D+4dd1EmlGtBRFnwLo7kAzmKcgSP9Skwqcgm1Al8djbd+78EnYhd7YraRYDWUQ23Fp243e2NGPljJBm1N5NVBKrafDbkERLQZiK5grRgYeHb9stTaIH5CUsYuP/1oV+o8EGFdeLnSPnxE9I/5E+Um4J99HXEE6QZe8p7IGF1HiX+SuvQ9k5ZemEiRSydPIqqE7G/WLCMbBeCo8Fzoofmp2rPWUuoA1F6bgRyv04EpMfOBJNzDOSWE8W171CqifoFtFJpyj9HUZI2UtdEbm/TLnPHBwkmIO53jIIbtytNIvUhtNNKwn3wE5Wp4XByppK1KoNAYCPO6oMtxlVzg4FQkIa7T9AbMRDGGD5KPYnrld7PFR83yx67z8PFTQMeen2CzAo0z0tJpznuLdZQ2YCYP73djQEaJhqH4UEYKwATKsNHcmXjPw+bVLrGMrLHGxIDEZ6K5lZ/bHEFs3xz+wQIAi0bQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB4130.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(7416005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +YU3bHU7CnCsYyB5K2UuTs8sKIgOQG5cZNZEssk2F3FZ8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GHRIHIzgFoeh0YWykmzyNTTKV+nwtgKb1tc/+tfOf4I9D/Gkz3S8FSc29+B1A6Mjp8S6k+eAududXLXmTeOY9CUSduiSi8AZSW7ZuK4DvDenYrpkGiGpM/QFvO0GThtCQnN7GburKEhF3qrJNG1zzJR3ZsbnHHqcN0glyUGu7zSaNPV0jLdyo2pYmQfv3jMIqu8QrnUMXVUffwWRDckkLaxax7pdelUCBP6aLIyyYU3F7YwASC/meBtZ2IkslNyXdb6MxCUUCTbNB1XtGO2ou5tEa6QtiaGQDlZWLvYy8NULXtFEpnItEJ98VJ7O2PDRImsQayyJWdWsnLSHpQ6f1qqQKXwrqHP4PApkdUlle4QGcSn6Ac47YT21dNz3jTIuDwaQEFJAFje9NgEzIx0yeqPJw7JLzVEgtvv9bmXqKHqh+ehUdMI0wm4wgDWUcEydd961n0k9IX5KZRR1B9os8R X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0c2ee7e-b568-4e30-35ab-08dc6b193c54 X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 02:32:11.1284 (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: IPofZ1ooQiU9GDl7wDGPFHzYzQofyAVz9NczSkxhynRYJ+vGQ29FaNEqxQUkwxqzClVZdjbNuCl2jWszC5S5dg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4193 First of all, in order to build with clang at all, one must first apply Valentin Obst's build fix for LLVM [1]. Furthermore, for this particular resctrl directory, my pending fix [2] must also be applied. Once those fixes are in place, then when building with clang, via: make LLVM=1 -C tools/testing/selftests ...two types of warnings occur: warning: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value warning: taking the absolute value of unsigned type 'unsigned long' has no effect Fix these by: a) using labs() in place of abs(), when long integers are involved, and b) don't call labs() unnecessarily. [1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1c49f@valentinobst.de/ [2] https://lore.kernel.org/all/20240503021712.78601-1-jhubbard@nvidia.com/ Signed-off-by: John Hubbard --- tools/testing/selftests/resctrl/cmt_test.c | 4 ++-- tools/testing/selftests/resctrl/mba_test.c | 2 +- tools/testing/selftests/resctrl/mbm_test.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) base-commit: f03359bca01bf4372cf2c118cd9a987a5951b1c8 prerequisite-patch-id: b901ece2a5b78503e2fb5480f20e304d36a0ea27 prerequisite-patch-id: 8d96c4b8c3ed6d9ea2588ef7f594ae0f9f83c279 diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index a81f91222a89..05a241519ae8 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -40,11 +40,11 @@ static int show_results_info(unsigned long sum_llc_val, int no_of_bits, int ret; avg_llc_val = sum_llc_val / num_of_runs; - avg_diff = (long)abs(cache_span - avg_llc_val); + avg_diff = (long)(cache_span - avg_llc_val); diff_percent = ((float)cache_span - avg_llc_val) / cache_span * 100; ret = platform && abs((int)diff_percent) > max_diff_percent && - abs(avg_diff) > max_diff; + labs(avg_diff) > max_diff; ksft_print_msg("%s Check cache miss rate within %lu%%\n", ret ? "Fail:" : "Pass:", max_diff_percent); diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 7946e32e85c8..673b2bb800f7 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -77,7 +77,7 @@ static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) avg_bw_imc = sum_bw_imc / (NUM_OF_RUNS - 1); avg_bw_resc = sum_bw_resc / (NUM_OF_RUNS - 1); - avg_diff = (float)labs(avg_bw_resc - avg_bw_imc) / avg_bw_imc; + avg_diff = (float)(avg_bw_resc - avg_bw_imc) / avg_bw_imc; avg_diff_per = (int)(avg_diff * 100); ksft_print_msg("%s Check MBA diff within %d%% for schemata %u\n", diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index d67ffa3ec63a..c873793d016d 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -33,7 +33,7 @@ show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, size_t span) avg_bw_imc = sum_bw_imc / 4; avg_bw_resc = sum_bw_resc / 4; - avg_diff = (float)labs(avg_bw_resc - avg_bw_imc) / avg_bw_imc; + avg_diff = (float)(avg_bw_resc - avg_bw_imc) / avg_bw_imc; avg_diff_per = (int)(avg_diff * 100); ret = avg_diff_per > MAX_DIFF_PERCENT;