Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1176582lqt; Fri, 7 Jun 2024 10:02:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVK4QgjtR88bGULtkMClV0hCtOuYmiLhDVWKl0oZz/XPoXhTlGOLbPQR4fQM1uiaPGqQnO7xHTpSHarZhY6DCTNRqzQmM5Dm49vZuVM4Q== X-Google-Smtp-Source: AGHT+IEQ+rp9EfzlwG9YyaIcZvngqUmAsUDes7sIhLju8oGn/CNiQ9CmISgUtNoj55ftbFSOQLyG X-Received: by 2002:aa7:88ce:0:b0:702:2749:608f with SMTP id d2e1a72fcca58-7040c619541mr3459845b3a.3.1717779736229; Fri, 07 Jun 2024 10:02:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717779736; cv=pass; d=google.com; s=arc-20160816; b=k1RbLpKxziRDQz4UpL6sRhVVab6pXzZPBpAbbNOgF88jHhl/RP465BC4X8ln91E5l8 u4jyLijlyFDEfW1NMB7WOqKviPWlKoEOHbq+D8qloyh0u2bzESE6twguPoyIGHybk9bO Eplydw2G4LVdfbft5NyXRNqjj7jzd7Y5G2Arl1rl9HUYBf3pivW2naPpCqqoXDFY7/Iu pIs5vJBDe23RuAkxepJr2BXtRURLSsfGqyYErlM9yoGDyZiQlPXd5WnlzK9gETwyD2di fHK53f2iHdX/n81JBL2dcfMvswXU2AosT6T8Hq7d0fdpp1EIQ8vkxCntmrHeLc2HWbUN zZmw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=E5fZywIZbOvtoswddDcndNz5B6gn2wHCeR8oBJfRvbM=; fh=7aBjJTD1LEoGsthbZX/aks6vbaOZYbIjsshak+jNdyY=; b=rGK2ZSeVqLiXPpIJ8iPxPLT0He+D8G5JSihzywUn8JXmjrBtyCZbSSoFBQjCMqSjpW L6gYnFt8hhrQ6XoUJKfep7mv9yYV9ddddCdk+5fNG6vsKBwXz03IPAxuZryRxh5qGcPi JQFzdSgfiul/miR1C2t/3EoTw42S30SzcLQd+jS1nBjF9MTZbH/fosXfcoZ956ms5lPD TP4CmrK5697Gf978WMnIJTR7/4LOexD8Szwm3xSwBUKRniOtHfw3FEhhuLukUrMsOQEA GsIQsc1/tvFhzHd+gnwrL5Kh7lM9mLvhJc3JCqIWC3XCRiYMpJroLz6KWH/9fZ832APD sf+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IT+6ypXe; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-206088-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206088-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2a280d14si3332617a12.795.2024.06.07.10.02.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 10:02:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206088-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IT+6ypXe; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-206088-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206088-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BB1AA289682 for ; Fri, 7 Jun 2024 12:54:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69DBE190678; Fri, 7 Jun 2024 12:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IT+6ypXe" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 E3ED7190682; Fri, 7 Jun 2024 12:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717764853; cv=none; b=hZX+i0+LwjRh3CXkq0Uuo8acZj+5qpGC098x2CdPEypLZFFaQQ6FLq/elfQBZkgZDboWIFBIHfQR0zZZqxtkCIyGRBiKERVg7+loT8uMyG7iNFF1USo70J1r5CM0iX40SXYigKNsWT937RU8tDveJajwxQJEPAp/vD8+Tu2xNds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717764853; c=relaxed/simple; bh=QKpi/Z2i3y+bsUnF0rYZRezABlE8chGK0hsDGf6Q8OY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Ij5ErXUabMRWnFBN/BCqN+zYK1WdfAgINn5zn5oHtnoyRytn4/Go/6Q921Ewd4ODjPk5K3nMMmV4NsGtd1SyW13+mmTu9JTWb+HJq9kktL63sifaKR5Wibn7vwG3keEbj+TlrhH4OaDUfCZJ4FOlGF9DU7A+f768mSVQqxSz9fg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IT+6ypXe; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717764853; x=1749300853; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QKpi/Z2i3y+bsUnF0rYZRezABlE8chGK0hsDGf6Q8OY=; b=IT+6ypXe5YvzhDpOOqF0enW6XUs/VgARrsNwQYConYyeotF1dZ98Mx4k 629p/fgevZ/UUR12ziTmk+PdSSrH/lukhqCxppyvrGr1j7PRO0zYFwK+R YcwtkyqqhtPPxCCWh28hwqJ6r34SFm9gl7XRqfiuk1TlwP/Tjv1tNcEwE FGU6TuSo3gilhg0pNYmmRNxtSvsXcTJecJkg8Tu6eSpSdBuk82PIFk+m0 RVbFT/BxuuyFRMsYkrEPPPrMCk2rWIGkK9nFEF7R+m2j5B9sSSD3JK4S3 LFXKIYYI5ZWo4hUYGCP1fX0GCYEPcWWEhHsDiAzKm3miL6TnmwQEX6BsT Q==; X-CSE-ConnectionGUID: MsDOIKm7TjmHyulbcCRscQ== X-CSE-MsgGUID: 49fl2CqiRaGYFR57LbtvzQ== X-IronPort-AV: E=McAfee;i="6600,9927,11096"; a="25586225" X-IronPort-AV: E=Sophos;i="6.08,221,1712646000"; d="scan'208";a="25586225" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2024 05:54:12 -0700 X-CSE-ConnectionGUID: cQ1JVESlSpiD4jTbXtm6Qw== X-CSE-MsgGUID: ZAHpzcAoTzeC1pMTcBWbsQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,221,1712646000"; d="scan'208";a="61520824" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.184]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2024 05:54:08 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Shuah Khan , Reinette Chatre , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= , Babu Moger Cc: Fenghua Yu , linux-kernel@vger.kernel.org, Shuah Khan , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v6 05/16] selftests/resctrl: Use correct type for pids Date: Fri, 7 Jun 2024 15:53:05 +0300 Message-Id: <20240607125316.7089-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240607125316.7089-1-ilpo.jarvinen@linux.intel.com> References: <20240607125316.7089-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A few functions receive PIDs through int arguments. PIDs variables should be of type pid_t, not int. Convert pid arguments from int to pid_t. Before printing PID, match the type to %d by casting to int which is enough for Linux (standard would allow using a longer integer type but generalizing for that would complicate the code unnecessarily, the selftest code does not need to be portable). Signed-off-by: Ilpo Järvinen Tested-by: Babu Moger Reviewed-by: Reinette Chatre --- v5: - Cast to int before printing to match with %d. --- tools/testing/selftests/resctrl/cache.c | 10 +++++----- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- tools/testing/selftests/resctrl/resctrl_val.c | 8 ++++---- tools/testing/selftests/resctrl/resctrlfs.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 1b339d6bbff1..1ff1104e6575 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -101,12 +101,12 @@ static int get_llc_occu_resctrl(unsigned long *llc_occupancy) * * Return: 0 on success, < 0 on error. */ -static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value) +static int print_results_cache(const char *filename, pid_t bm_pid, __u64 llc_value) { FILE *fp; if (strcmp(filename, "stdio") == 0 || strcmp(filename, "stderr") == 0) { - printf("Pid: %d \t LLC_value: %llu\n", bm_pid, llc_value); + printf("Pid: %d \t LLC_value: %llu\n", (int)bm_pid, llc_value); } else { fp = fopen(filename, "a"); if (!fp) { @@ -114,7 +114,7 @@ static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value return -1; } - fprintf(fp, "Pid: %d \t llc_value: %llu\n", bm_pid, llc_value); + fprintf(fp, "Pid: %d \t llc_value: %llu\n", (int)bm_pid, llc_value); fclose(fp); } @@ -133,7 +133,7 @@ static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value * Return: =0 on success. <0 on failure. */ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, - const char *filename, int bm_pid) + const char *filename, pid_t bm_pid) { int ret; @@ -161,7 +161,7 @@ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, * * Return: =0 on success. <0 on failure. */ -int measure_llc_resctrl(const char *filename, int bm_pid) +int measure_llc_resctrl(const char *filename, pid_t bm_pid) { unsigned long llc_occu_resc = 0; int ret; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 00d51fa7531c..e6f221236c79 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -174,8 +174,8 @@ void perf_event_initialize_read_format(struct perf_event_read *pe_read); int perf_open(struct perf_event_attr *pea, pid_t pid, int cpu_no); int perf_event_reset_enable(int pe_fd); int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, - const char *filename, int bm_pid); -int measure_llc_resctrl(const char *filename, int bm_pid); + const char *filename, pid_t bm_pid); +int measure_llc_resctrl(const char *filename, pid_t bm_pid); void show_cache_info(int no_of_bits, __u64 avg_llc_val, size_t cache_span, bool lines); /* diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index e333e4efb550..f7c62c54ad55 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -566,14 +566,14 @@ void signal_handler_unregister(void) * * Return: 0 on success, < 0 on error. */ -static int print_results_bw(char *filename, int bm_pid, float bw_imc, +static int print_results_bw(char *filename, pid_t bm_pid, float bw_imc, unsigned long bw_resc) { unsigned long diff = fabs(bw_imc - bw_resc); FILE *fp; if (strcmp(filename, "stdio") == 0 || strcmp(filename, "stderr") == 0) { - printf("Pid: %d \t Mem_BW_iMC: %f \t ", bm_pid, bw_imc); + printf("Pid: %d \t Mem_BW_iMC: %f \t ", (int)bm_pid, bw_imc); printf("Mem_BW_resc: %lu \t Difference: %lu\n", bw_resc, diff); } else { fp = fopen(filename, "a"); @@ -583,7 +583,7 @@ static int print_results_bw(char *filename, int bm_pid, float bw_imc, return -1; } if (fprintf(fp, "Pid: %d \t Mem_BW_iMC: %f \t Mem_BW_resc: %lu \t Difference: %lu\n", - bm_pid, bw_imc, bw_resc, diff) <= 0) { + (int)bm_pid, bw_imc, bw_resc, diff) <= 0) { ksft_print_msg("Could not log results\n"); fclose(fp); @@ -828,7 +828,7 @@ int resctrl_val(const struct resctrl_test *test, PARENT_EXIT(); } - ksft_print_msg("Benchmark PID: %d\n", bm_pid); + ksft_print_msg("Benchmark PID: %d\n", (int)bm_pid); /* * The cast removes constness but nothing mutates benchmark_cmd within diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 9b86f826a40c..917d677adbba 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -508,7 +508,7 @@ static int write_pid_to_tasks(char *tasks, pid_t pid) return -1; } - if (fprintf(fp, "%d\n", pid) < 0) { + if (fprintf(fp, "%d\n", (int)pid) < 0) { ksft_print_msg("Failed to write pid to tasks file\n"); fclose(fp); -- 2.39.2