From patchwork Wed May 8 19:02:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 795928 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2084.outbound.protection.outlook.com [40.107.101.84]) (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 06F0B14A8C; Wed, 8 May 2024 19:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715194987; cv=fail; b=d2qqpSBVRr2tFl+bX7SQmAV2EOoDA1SyZp8qVG5OlvEcHhCF3ne1iDuZHAANeNU/wvEtBAMheSkLmnRNjqvExVuHLpXMqQ+XOrvAMATmLGe5E7u0jSt2Jl5v3nNwgjHeQox3iAlbtpLIRxG04MlAO4xczWZhD536Vrfr9bAugKA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715194987; c=relaxed/simple; bh=pSJKsdH6oOHNLLuI2Ic8jDxSl4kRvmsdQkQl194Y5Cs=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=fkoUOwaCsJifye7nOAIbo9Wted+wzdsQkIH2QvDDHpt7dnpopUGkvzrrdEgE0DFPHjvrULsWfFKgmw0S7mrNeoNLXwmsxUwGSxUZfapgCQ/OAXAoCN1B6XoPftOk+fNK5IR6tHufvuvqVgNeymNz6MB4aSVAOYCBV4Lb8QgW3U0= 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=e57Vi184; arc=fail smtp.client-ip=40.107.101.84 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="e57Vi184" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ac2165mAs+uRjqmafdF167jw8w5tAlcSJcUsSSoXAQtpWEi354wYIbOa/ZHyCUsZK4Iq4+tm5iI68fVi4W92qVO5qzhk6BIhFtQllr9t9T5mDvERbXTtPrknAzy4rr8Q9K/YDG1B5VOoJzIyLn/6PigKyz4SlV5j6xqUhYafCSnswcRLT0cURnnrhkimzSmXD8yiUjzUBUPZdvHSrCJIU1IDP3xLw11n0GSUkLYcMNNnuDI3y+YTX66Q4oKweSpHSgKNUa4E0Moq+fFROtOGwLVynNkys6c0DpLUcObH9WBBtfKTVYvX0BUfg1f22p6vaWemXhDtv4a0GU6WNeosXQ== 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=JHIi6izlW8bmJsYQU6u3iaOw0Z/NDGCiyMf/jA1QRxc=; b=Vfa9r053MAJwiEBamk8BSglvnJPgiWMQ2CHGPU+JndO3VTEgtlK75A2G1iq0H3y7fjn9VXLwFMIStxj3SfX9P1dcXNs2PCrMI+id6eYRkKIZtJNSy7Ag9xm9UdjpnmbaNEgDOEG0Oaa9mTfGNYKDpHcYB1f/i6be5eNhXANK+Gyu+xGNE3hFEDZHXI0fM1fIdKQbFFh06CTwlQlRSChikYK4J7wMP4mhFtRQXhYUSIIEPdsLdT7w2BgKg5LoAOZnoYn/FoCZGLHes2SMgNRqsxK34HgHpi6xi/EUwDwhm6zx079YyxXwZ7w3TGge89UPT2ADVXNLPs0B4wy4HHswUw== 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=JHIi6izlW8bmJsYQU6u3iaOw0Z/NDGCiyMf/jA1QRxc=; b=e57Vi1842zugvhXMim2snXySwreWw4hF5Jw2F2xHEKdHfTxv5N4ZP6R4xIV6JjTsG6mPVqT2e//fZGe2iGWdrzeACD4HWH4SJx+nkcsBn6m2NyOI7Dk2wxFCrgi2LWDbjqRhCqDnoSlZKlcoBGjT/gvuJFNJZYh7kS3fn86QVd+eacUQncl1yRGJ0L/+pjNPHIVH9Nf7FFj9IHxy8+p6yWPnVxLIb1gmFRbdypFBHqQSgNy0M6QrM0PKPuTRi8vHzwrig1ogwTiCpn9Ox6snEdvPdMqqSek7uM23m/34H5bfRXM3mZPMtze82ExLi2ti7mESXj9g4zbGi3rNvfVaaA== 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 SA1PR12MB7126.namprd12.prod.outlook.com (2603:10b6:806:2b0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.43; Wed, 8 May 2024 19:02:57 +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.7544.041; Wed, 8 May 2024 19:02:56 +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 , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH] selftests/resctrl: fix clang build warnings related to abs(), labs() calls Date: Wed, 8 May 2024 12:02:54 -0700 Message-ID: <20240508190254.266892-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.45.0 X-NVConfidentiality: public X-ClientProxiedBy: BYAPR01CA0044.prod.exchangelabs.com (2603:10b6:a03:94::21) 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_|SA1PR12MB7126:EE_ X-MS-Office365-Filtering-Correlation-Id: 7dd635b4-e693-46f6-f4d0-08dc6f9178ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|7416005|1800799015|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?lTB/s7FCf9mWzi14/5EnJumVgkw1Ir7?= =?utf-8?q?eqfSwE5Gada/xdacOoxqGSlVlulZ4Rs/+gT5ccO2qJ8H8hizzpFJb8JtVMFGcJgOJ?= =?utf-8?q?yhdI77Bn8TPKbGHbmdWwihax89LYOGGPmK9UFwAnJtUsNaWoSPVJ7GthhwabbbLgS?= =?utf-8?q?V598CeAtP9/Nd3eI8UxFVQyOMMyhVclmIyYXNswA/iDqRayY9TAXc0fVm+twLhncQ?= =?utf-8?q?7g38iU0tGW8FSqO3wkgkxmGE1OMHmYJZkd8WX+YELFAEi4FLtlz0+m/aU8iwHP4fT?= =?utf-8?q?hKOfAtE8WIo1SYcPMHBzD9/B1IDci84Lrh201J3ypAuwv0kzVuc8ibzWY6FbQGfH1?= =?utf-8?q?AR1d4fO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KFmQ9+J5Dr4vh86hi3k3+GUUBQ1w=3D=3D?= 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)(366007)(7416005)(1800799015)(376005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Yjwhs1QhwLql0YmG0zibSoNIc2pR?= =?utf-8?q?YKYUz3tdIGLg0/E/eufzUxlZlcLNRhYFxn/RQx6N4G8buvX204LNFpEjNb+ZabFWu?= =?utf-8?q?5zuKVjbeR/G2IjMfW8bEWcHrcWqj52e9IGS9oJHj8nFHdXNExEysUjrpsNr73odC+?= =?utf-8?q?2+fIzL+ObFMB8j+JvG/pENrStmoN98Hkntm2VgxSjiPtF+VBZl69B4Jj/DGsD+nGi?= =?utf-8?q?hitjKzTK0bLP1xieGpvEGODLAu4e6mfrm5bBDakgdGKQ+dRFEUL/0+4+2ANLaxlY9?= =?utf-8?q?4rPQm+9FiYWoLPskati9VjZXSYbjLWwFE8eZkLLWZ9fXGF1X7c6Rg9WE91imVkXWY?= =?utf-8?q?NB4fJ9FazCamcCmuJGcLs/ki1533dr0RRo17wVxr6LqMiPwpJBVVvBLdzfgf7wWBj?= =?utf-8?q?c1ACikxiHhblyJSnCRSmkzudrH7MBJ/VBbg7xsntOaX9z98ECpb6yB/FrW9GcpZJh?= =?utf-8?q?7xPHUH+rKCk6JSLy3xkYOBKunPcdvVRvMZFYvKNv236F22HNtkqZHSTcdRMceCmOZ?= =?utf-8?q?5sBPoFsT3ci548cgMljXqyJB+b/k3vFF/GKZYP8CEmXoxDinGH7+LVPfpVS+zA64l?= =?utf-8?q?K9cR4AQQZg6Pzsw+5nu/m3A8nkS0d15K/7Adt5/Zw5AnJCtl+qtEeD7waCv0ndEeR?= =?utf-8?q?EbRQNPUh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: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7dd635b4-e693-46f6-f4d0-08dc6f9178ca X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2024 19:02:56.8399 (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: Z+nJRsp5/6mvd7vmz3RzwSXdJ12bF2UYRws6cuwkVOHI57C1Y6N1He2ldXGp/FKjqbfVkR5jprYlCvGDSiEVcA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7126 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) Change to use signed integer data types, in places where subtraction is used (and could end up with negative values). c) Remove a duplicate abs() call in cmt_test.c. Cc: Reinette Chatre Cc: Ilpo Järvinen Signed-off-by: John Hubbard Reviewed-by: Ilpo Järvinen --- 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: 45db3ab70092637967967bfd8e6144017638563c 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..5fffbc9ff6a4 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -60,7 +60,7 @@ static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) /* Memory bandwidth from 100% down to 10% */ for (allocation = 0; allocation < ALLOCATION_MAX / ALLOCATION_STEP; allocation++) { - unsigned long avg_bw_imc, avg_bw_resc; + long avg_bw_imc, avg_bw_resc; unsigned long sum_bw_imc = 0, sum_bw_resc = 0; int avg_diff_per; float avg_diff; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index d67ffa3ec63a..a4c3ea49b0e8 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -17,7 +17,7 @@ static int show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, size_t span) { - unsigned long avg_bw_imc = 0, avg_bw_resc = 0; + long avg_bw_imc = 0, avg_bw_resc = 0; unsigned long sum_bw_imc = 0, sum_bw_resc = 0; int runs, ret, avg_diff_per; float avg_diff = 0;