From nobody Sun Feb 8 19:40:03 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 5D68A81754; Mon, 10 Jun 2024 15:16:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718032561; cv=none; b=u7uHCNYkX1ozX95EUJEZ0tlg0ILn8HUl3cWDGq+nrnV6PVdqSac9gMdWlwV+AXLw1Vp5EiYwpETTsjTcLGKpbvJNzgxJjMfxoXYpSf40V2rRHXHW949MxnQ+YN/GvNjh25EKji3X7BTSSJfcANhQ8T8M+ilP1xXsVtCwIojft00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718032561; c=relaxed/simple; bh=J8MXk2+opYTa7xZQ/Gh3p+vp6i8luDzj3u3KMCcjByM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=kJQ7em0E9is4PR7upoJWOChgXnEXd/8L4Oy6JO2IZeGz20UVYrjFXAFCil0Za1LSOSVZpRQi/+TEdemDZt7GNS7gw2tLCFaO2YW0zqp0j8zHk8ARvemCnKWGO4MYb0ZJdTd9PnRt+qnojZnUHUfRxPN6NmXnG2izo71FZwdxfhM= 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=M3CxDOK0; arc=none smtp.client-ip=198.175.65.14 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="M3CxDOK0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718032560; x=1749568560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J8MXk2+opYTa7xZQ/Gh3p+vp6i8luDzj3u3KMCcjByM=; b=M3CxDOK0ss7EAJuV9BL7cYnYiyZCFixr2FFgepsRQSRtNviP40f0TaCp cc7b/KNlsoCxBA48MMpGXFGtumlB4IYC3wKP4FAPbfTEbKARG44QP+9mT LoJ9h4wVkwmB/Kv4LWSieXQdjLdp9/SsUfJGPqxQJEZZnbaOTk5YoyMJB sVAqWtKWX2mC480jHiosVgDUskbzH8FhZWJbL39itBIOM6mv/WViGWY06 5DPURsgkh5LSPRUiWKtrR+mt2Fg+B05G9uraaNRJ/g/4Q4pn1c7tprJd6 rc9+jObwTINQv8qwx+kTt5Dpz1a4KfZTKmBmariS8ErSpl/aebSeGAzy4 g==; X-CSE-ConnectionGUID: 92IfzP8bSmmx4sUr1neZRw== X-CSE-MsgGUID: ovGRmyjAQj6+n0/lq9si4A== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="18530836" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="18530836" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 08:16:00 -0700 X-CSE-ConnectionGUID: HoBNmIP0SxijAJWn9TI8rg== X-CSE-MsgGUID: vK+sG1WuQImm4pGnpP4DcA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="39650727" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.194]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 08:15:49 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Shuah Khan , Reinette Chatre , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, Shuah Khan , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v7 05/16] selftests/resctrl: Use correct type for pids Date: Mon, 10 Jun 2024 18:14:46 +0300 Message-Id: <20240610151457.7305-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610151457.7305-1-ilpo.jarvinen@linux.intel.com> References: <20240610151457.7305-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: quoted-printable 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=C3=A4rvinen 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/selfte= sts/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_oc= cupancy) * * 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 l= lc_value) { FILE *fp; =20 if (strcmp(filename, "stdio") =3D=3D 0 || strcmp(filename, "stderr") =3D= =3D 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 =3D fopen(filename, "a"); if (!fp) { @@ -114,7 +114,7 @@ static int print_results_cache(const char *filename, in= t bm_pid, __u64 llc_value =20 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); } =20 @@ -133,7 +133,7 @@ static int print_results_cache(const char *filename, in= t bm_pid, __u64 llc_value * Return: =3D0 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; =20 @@ -161,7 +161,7 @@ int perf_event_measure(int pe_fd, struct perf_event_rea= d *pe_read, * * Return: =3D0 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 =3D 0; int ret; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/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_even= t_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); =20 /* diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index cccf6b80f3f3..5704fa3ba202 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 =3D fabs(bw_imc - bw_resc); FILE *fp; =20 if (strcmp(filename, "stdio") =3D=3D 0 || strcmp(filename, "stderr") =3D= =3D 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 =3D 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 Differ= ence: %lu\n", - bm_pid, bw_imc, bw_resc, diff) <=3D 0) { + (int)bm_pid, bw_imc, bw_resc, diff) <=3D 0) { ksft_print_msg("Could not log results\n"); fclose(fp); =20 @@ -828,7 +828,7 @@ int resctrl_val(const struct resctrl_test *test, PARENT_EXIT(); } =20 - ksft_print_msg("Benchmark PID: %d\n", bm_pid); + ksft_print_msg("Benchmark PID: %d\n", (int)bm_pid); =20 /* * The cast removes constness but nothing mutates benchmark_cmd within diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/se= lftests/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) =20 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); =20 --=20 2.39.2