From patchwork Wed May 8 20:41:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 13659155 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) (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 28D7F225D9; Wed, 8 May 2024 20:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715200869; cv=fail; b=f5eFe7+C0TG8JKPlykbS2PcPCgj6yw1C0xzpOMUx+pJlVJmJ7/NhuW+JU+lpJ6r0Hi+InasOThF0Vh/kuvSthy/syWrdsBdH+t66FYyXLAP/FMGEZxQoBUxmceeFrhDmOpH4vnzPZP51njYl7JmndgJgXFDKcJzPG/m3Dm9c8bo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715200869; c=relaxed/simple; bh=6I/7UqVjwA+snHwbZXefxxrCaYbneFpqVQTnDQNLM/A=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=TiZZi9aFuZc4hAXl4zqHrOUImQAcXL7Hhu3tE+wJU4XvBkgArzDAG+xiDigF4MN6OWLrsW+sB0pt/I/asPJKWR9njgm3f4DND/hHa6y6W8mxiWoRFYjwdnanrNy77CRRHOnOTM+NIuQ2ih29tWxkYNBi64hmSxu13Z/JrNNti3I= 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=S4J4JgYk; arc=fail smtp.client-ip=40.107.220.52 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="S4J4JgYk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LuiJ+rOTIjaxMHj2oCyYlh1WkR6TbfF2/sOWBjJDvYTjxk8H5onaxmjpce37vEl/9naIF4B/Z0gknTXjDVwV20P8pwcNHNgSQFAq1UCiLKGK19nkoMon194slmi2CxweAFxghX8VVIYu/EcL6iY+T0Jvn9QTUMyD9nAVIUQM3ZWFfXYloYRA7/rd+KOH9BWbDPyJxOpdkBJbRip2/Vt5B7VEDSguDpVIYnDn1Q1N9YP2SMVyCGgX1s0lrLwD35xKX5MSS5qIWDIvtP/a1WD7OAbD5m8EPD7WzN8bw3bBzZSYOpxRe7VqPlXE9anSfUtFEJdKwDkloqzZDN+fj87lxQ== 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=DD/lFxLf2LFO94FzGaqfGfKiDFEvpFbehGYAWrRa9kU=; b=Gw54CfEkAPmjS5B20T35KCLr+QgO+2WGd4j03+0mmVvhKz/384mlLEjUIqOYKQXHYk6HFBNly5IzZDf5+hlzqCDlBpFsXfK76PESN9We6CMxQVkJo7Zty4VFaRm/1pQImPNfSgTpSDEs2QGmtb7cwyf1cNW3oLfmTnlenfjDHjRKioqlYBql80EDKiJG87BGSwHfkiAURR0GCWNVXkPi4l3rrbYwFB5/SV7zCaDpXRRgNhQBxeawtbpFBjcvn7tEcOMV2i17dOdQhXUNT3VbYShdjrEPSGpwW/7lyItEaj95tSvi8YtQkfrIRal0oxeesu7w6544bKoC2FP5pUyZAg== 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=DD/lFxLf2LFO94FzGaqfGfKiDFEvpFbehGYAWrRa9kU=; b=S4J4JgYkFd3PIuFJ/AJZYQ8eAqe65M3/2eEr6WTY2P5rffoJ/FNwjAs6XzngvKkB7QaigwroimJTK0X4y0ODckESqAJDriJn0B/VQGhJMdexUANVfgdEufgCcq6gs0+i8LIkGBw9dIN+eHKFfXuNLwVq7fQEniM8FB8gnBTcQxP6VO3LE1yq2VrddTPLqjlXhRNZ8sx098jhjLO/Ro8ks6N9UCS4YawpxDsZFdwCHx5INEN34W+mcHgV9DAdXOHP4hQ8x1J0sQolU2Xc4L/lSCY/oNZBLnC0LPyX1hmoCPW3Ef2epRQvU8zFt2Qc8yuUxs/RXpRisJBfxS+33ARg0g== 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 CY8PR12MB7586.namprd12.prod.outlook.com (2603:10b6:930:99::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Wed, 8 May 2024 20:41:05 +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 20:41:05 +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 v4] selftests/resctrl: fix clang build warnings related to abs(), labs() calls Date: Wed, 8 May 2024 13:41:01 -0700 Message-ID: <20240508204101.277146-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.45.0 X-NVConfidentiality: public X-ClientProxiedBy: BYAPR04CA0017.namprd04.prod.outlook.com (2603:10b6:a03:40::30) 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_|CY8PR12MB7586:EE_ X-MS-Office365-Filtering-Correlation-Id: e95c536c-b83c-45f8-067d-08dc6f9f2e75 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|366007|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?z4atvkOEjAfpA5mkpUH+sH2J7vkdQb0?= =?utf-8?q?4UvYeZgbjZimSpDq9E1rW/XB0KsS6kVxa+PXL0ADRC4fOMbRsWx7/x0gbTlF9QVoG?= =?utf-8?q?0Y5Xl/P98jAC6TjxOW2hooIyoggRXbr37ZkW8kqJClcEcFNiVUT4Ko1e+x6mQ3JDP?= =?utf-8?q?2dMIXN14iugjMuzCZ0E2QRfNIurJgqQWE4OfLjB+34BVhwS4Y9yt6fNAmSXOwZBzM?= =?utf-8?q?ak69NMmNaTxqE4F9cCFqhwf3eI0pp/TTtLE/6PCOiAM2t5w5Uh/98MSqIDhO8790P?= =?utf-8?q?/X8LTTCQHZ8zp2iPoLlI1Cy/vAKFFJyB4eSa0qDIRq8ouBZl5ff4jpwXIqyEZzinP?= =?utf-8?q?iMB27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K9V4oIniWIlv/mawPtjRbWLDQ=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)(7416005)(1800799015)(366007)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?9jnkXEt9FwKunAybrKEINooJXUrU?= =?utf-8?q?U54okMSMRJCLfcBd2UnMWhJGz112NpFIQ/6nH7vWYaoiar8ciup9tKN394Zis3Mdh?= =?utf-8?q?Om6yRnxA+O/aVDtkSVfQrtMgw180xD8x9YjfeSamU6yPT/nsmRATsHiwoNBSKpRyl?= =?utf-8?q?69jfxbfYsXpjnpwgRSkQD3UafiRsb+s31RhGTsbZ86ibo9Z1IJxMS6of+xrT8z3ub?= =?utf-8?q?vGmXgReYFKXBDMVrXY2cgH/j6N8MNeGa90xUvV0bxuviRy+jkvc3OyNkt5aTZZ67F?= =?utf-8?q?EWR4qToJuSi1J/vHXHjxbR6at6dUi9sLzhacItzOGN76kYgM2AFWlPfNugKsyTz1c?= =?utf-8?q?TP9tV5lwfplWhlBibcKZlWBR/wmiTXGSG7eX3Kj41iBE6GE/RHsDD1VrwxqlGimCp?= =?utf-8?q?xqEyCotQlidYUdCnizoFGYB/KWIWXyiPMfKLCSDE57L/8PuE0inwtvKujwl6nRA1p?= =?utf-8?q?mAYH5W4guxdcW8yNkUB0wffcA+WGdNOe+Whvm4wZmhnPeAzhO4+HVkfQwJ2yUPYHW?= =?utf-8?q?UVzmRzTFCUFcXj0TuzbPoZ1x0VJZds3OFjA6ytCydtO6sxXGqRvjGd+VbL1kBbaix?= =?utf-8?q?wbelIga7k8hIg4gikD33uXX+IQpI41fvMC5sNzjDYF6eVnhATo27jv3oryUxaBYUR?= =?utf-8?q?SrUdgWq9QVkfDsuwGbbQubpNI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atorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e95c536c-b83c-45f8-067d-08dc6f9f2e75 X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2024 20:41:05.0569 (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: n+0Z4MapgZXm0wd/hZ2DiB06p4wujaLYWWMbUK5N9TmtJhSD0oo1uSx2Rz4oa7f8jeZoidgBxwgHjrBuX9qz6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7586 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: Ilpo Järvinen Reviewed-by: Reinette Chatre 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: 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..8fd16b117092 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -60,8 +60,8 @@ 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; unsigned long sum_bw_imc = 0, sum_bw_resc = 0; + long avg_bw_imc, avg_bw_resc; 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..252c94ff2a3d 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -17,8 +17,8 @@ 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; unsigned long sum_bw_imc = 0, sum_bw_resc = 0; + long avg_bw_imc = 0, avg_bw_resc = 0; int runs, ret, avg_diff_per; float avg_diff = 0;