From patchwork Wed May 8 19:41:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 13659134 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2066.outbound.protection.outlook.com [40.107.220.66]) (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 DB8B14316A; Wed, 8 May 2024 19:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715197300; cv=fail; b=iG+1NmtpG72BGz77KQFjS3v8rPHjBqbFnxMStAkf3FovPHpmamVdPcYuvqqcKcl916za3Uw+GWDF/ogzJkzH213OI2TMiMWwWjgvKQe3GCVf0kUAA+CGhM+JwNKu5mFOdm4qTFkECVIKmV72JXuuluYe2B78c9Ou8gYMdygG6EM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715197300; c=relaxed/simple; bh=FTXmFLZuRpW2kSUZU/nlf2JxITqnjJ//Dme2+ZuIMJc=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=RcMQS3545/v05Oh4CUe57T+E6GE95J8xVvL0SXNCet0tGl0HP165WvhpjN44igT9uXPEHepwKLCJifFnJlyIL9RT/NPYtvOuI7t5Sn+rWnAWmU6ZVn0tmQH6N/kEZ49HloJH62SZbzw2cxMBRcLtLfX6LNKx+875ziZR0+3NzwI= 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=IPN7OJOj; arc=fail smtp.client-ip=40.107.220.66 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="IPN7OJOj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DYLv0HEowLO9nuLI6zuJu6MK0i3aB0u0lfUrsWlNxkDs2qyCDf/oo3FqaCnYKk9xw1CpNEI5iTqrG2nH7I2ZwG7Mmbph7KPomr+hjOX8hE/MrD24RSslKT1SWwUe1p0gqngdNW37EMmvXwsukS11hgBzTdLhtwRrPC/z4kudA75g+X7PJRrFP6Jc0nf6uMgls2sD9HQNzOYn1Gx/TC4rU7G+Mn75IQGbHfEIfDJOZr5GYX9IqdQlDALCR3SvcbdNSAy07elbQqN6uH/AXaqYDZkmur0vQ4mNTRenZHdYbEehiOpYLnIJ2iGJveWxcEugE7zjp4QxBakq5tlWWZxOLQ== 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=Tzp/iQV9ZtI/J88NVRv5RhlsjifciYnhXGVg1rkITus=; b=WtOu05V5++Yt6rv+qTVfGfyevXgbKAVsju3Jgo/PJWOxw519ZUmxdTXXeNDmAuA9bVubLza/QgDKyloj4gdg46X37q896YV0aghlrQqRfeEHXCsVuQmQVIEJw0g9U1wtlPtEqlzhfHja9QNU4nsjzA7LdsCBev3N3sr6qD8Y51wzv+ZA9DTX6EVMUOUsOWWtR0VuIL/9cDWGLmUTmesAELZl7NXQ/ktrD4jvbLhqUTsos8e0rDf4IBTcczhXeUHS3OsfiLUV4UO8JJjbKwk6V4pR1ecUFBGNsdS18InjOyKcSCrY6Gh3wo8sVBH//N7rYzV+StzKdLYxlSVu6xvOYA== 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=Tzp/iQV9ZtI/J88NVRv5RhlsjifciYnhXGVg1rkITus=; b=IPN7OJOjZjgkjQabtKJ9GM292lTTLo+zQEGzJRUYU7/odFuxZpvQ1jOK0SphGHeXzICSFx/W/4ZopSmNZbka0YNPaxWZG0RJihNvlk7K49BZ7+wKgbj8FPzXDQbRAP8MueHX/k0FujUAurMkls1mk0PXtOuvH07y2GkkRjJo2ko9aQtcw0lfdv1JrQvdG9eEUKUP7Lx3meuLVTbERMgrdLfRbcReC2194/MgB6qUGBascUVWAQu3CARaySWoHLtX56iVhO99b+A4A+DBpxTc+d9u2dsgl1S/Qr+pegDf2HWBKlELiz1EHBCzeljXehE7QRavBtPmzWWKEGuo26aI0Q== 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 SN7PR12MB6840.namprd12.prod.outlook.com (2603:10b6:806:264::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.46; Wed, 8 May 2024 19:41:35 +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:41:35 +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 v3] selftests/resctrl: fix clang build warnings related to abs(), labs() calls Date: Wed, 8 May 2024 12:41:32 -0700 Message-ID: <20240508194132.269168-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.45.0 X-NVConfidentiality: public X-ClientProxiedBy: SJ0PR03CA0150.namprd03.prod.outlook.com (2603:10b6:a03:33c::35) 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_|SN7PR12MB6840:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c4d88fc-499a-4773-26d0-08dc6f96dee3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|1800799015|7416005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?VS7kZoKc8fIwVpW3wQe/WqiL3Af+3xe?= =?utf-8?q?KGg2sNrzGy/9GQBxhb9ficpxNEXSJT+4UrIfAENWEtnq8fAA0OjNOMMPZTYEH+QKe?= =?utf-8?q?wmZBwa31X3X0tEuPL/u3jCHvbBG56u8rNpyBNNsxpZ3xGpC4/xy+HUeqRhcQM6QLM?= =?utf-8?q?gu3NM6QSydZzrgaqaZlGP6P1Z4KmgTjibStuR83oCkC6xxc7mrq7YXVLb21g7n1Bf?= =?utf-8?q?9Urk6rw+YyhEJNlUaYa0s9vSfFg87K9gegHdY9d4O3qi3UJfdlWt26LGXRp21ITsd?= =?utf-8?q?nN4X80IQKecSkY8UuW5xju2hckywLauL9Gd3NaSV/0R0Runky5fGAaZsyd1TwvfFC?= =?utf-8?q?E0RgXNeMs5Tv97mL/CzS09hJHCVOB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rx32rv+hPvanZw=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)(376005)(366007)(1800799015)(7416005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xuc8f+4Z5R6F325SyI9N2bYOyVsF?= =?utf-8?q?tVpbJod29gBPVN1kblgxdf1VXIQx7MooG7oj9x4Ia5yRdjFZM7gobZwqkLxWYpxP9?= =?utf-8?q?6z7G4kZiw/P5LdcO69F34X+1+sSSPOV2dP58PRODNuw4TXayg67Tm9/2YarYZzfDg?= =?utf-8?q?k0RrXyD4Eb/Ute6yc9AaExkBuRDTNPQAsHFcOhyfGq3T9CbPBFahfW13wdmxSuo5I?= =?utf-8?q?q3qMbXvSdi00/Q/eJXFp5msdVfZrMJ7GOqcItporx4vYWH3QjF/jsirvplNY4+ux/?= =?utf-8?q?mgubwicWyHgle/jEENw+wJ4svqXEYKLmHaHMtCq6lC+WHkbwrulm0NS6unX9Xspg8?= =?utf-8?q?69sLfRgyt3VWg85TlGogZ9xPAMplf7WPyKpTVIa/Rtke/8UiQM2DHvl3sAupjHZuB?= =?utf-8?q?HpkAUJyP7ieQ/SOx0Tr8mmxCAnHnA9HTDMUTrEq1hGIIOlshTUviJ6Oq/33Ka5Sbh?= =?utf-8?q?BK9C9yMr/80Aejq/04wSAGYOsDYFQvB9sUczdYjZ0kPhYE6xjLaI3wzgBJt89PKCI?= =?utf-8?q?O2vSXk7c4s5SYceNMWG5BiG//FQ1XFaF2TT/zQxCyjwncwV0m7+WYATvH3WLCg/ym?= =?utf-8?q?APvEM8vcZaDZrfG8m5UDltumGO8w3fUBc/UQEOk3pW6/Q4wXEhOFDUGkBO2nP0FNm?= =?utf-8?q?0Ke1RZ8/lpEr6I/BEEN7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ia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c4d88fc-499a-4773-26d0-08dc6f96dee3 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:41:35.5950 (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: hCVgj3IpM/FT2ua64Oo7IpAK11j5KWfr/kxbaW+wXe1LQ8nPw2kGbnXJwU0cyn+7g7IJJA9Qt8L8Tc88sNLj7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6840 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 --- 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 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;