Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp429053lqp; Mon, 10 Jun 2024 08:17:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMyvywgeW7XeCeWLNq9DHj0UVotIb4SvEEgJfP9pFr7qs2rg3jcVgzpgb7oYKY8sbtKzGGyTg5331qacbceYT7FmlWJvyJN4sntIWh3A== X-Google-Smtp-Source: AGHT+IGEgXeNmoSoa+R3Em44UA9wdGcMGCHKg1xZjR+bZasqSuCbVIataN0O+k1ih6H/pXMjPb7u X-Received: by 2002:a17:907:970e:b0:a6f:da1:d077 with SMTP id a640c23a62f3a-a6f0da1d11bmr476272066b.25.1718032645943; Mon, 10 Jun 2024 08:17:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718032645; cv=pass; d=google.com; s=arc-20160816; b=c15nm4GFjGVF6RzWAAiaGCMdjdeAE6x6yuummLOqJ5goFt4Ua8RyDHXwhbMm41LxA3 eJjjfTvlSVbhCysANiiE4IdliSmLOu5+yu0E0tC3bi0SFjtUy+n/L+DwKqzJzghfhWz5 UkhQD+Tb5XOv8mSUqbbqbuqKcS/75YOvWRvxjh6GjtJjM1PGtBRMBI2NzJZNT6nD5kSP XYRSWgZLAVLK3ZgRIqd/ggXO/cvtMs1499To8UdcWsMWd91vYXy7cpykFlgduXJx+Nmk Ch6HgmLpaMWkU1EnCi74Cdh/gqEbFT0Z4yD1Z4DFiBhUdwOMkd3cW1f10+TgVGpbQnSf dkDQ== 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=1WHRBx4/yjWMTaC8lmBW3/DM1TV6eOrcGlMtWJzF8BE=; fh=NBWFQeoQJCxKalVKeIRTZaO55uIqw1uKTUtRX+uowOE=; b=HiBB/g+koxJfcCV5lsCjsE+/i1IVfTRwn5iEtOq06YqIa/u/gyU03R6QLgNze4kq2V Qq6Q44lEFuUNOrzvPPybsfkMLi2/8Qk40Yp6bTmnmaEtn6XQIo4xd8CO3Nh1ZxpLa4Ep OYGl8a6bWBky1Cb2YuzwP46D1cUFp7JF2xpo3Gosc7OjPefTT8S4CGEOapMr5KQGwQXu OGzUqXO+9DeVgbVPCc/+YfrYYpirJYlylC+DNfldxiuPrV0WO74lc6UbxoAcuH1hlPMg X5Pw1V7WM3ax8tmxB7TU19q4zH27JwuboLVEgqkr9SOViakby0vGJtwEs0RLmJWm90tM 7cBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=M3CxDOK0; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-208445-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208445-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6efaece611si288351066b.935.2024.06.10.08.17.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 08:17:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208445-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=M3CxDOK0; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-208445-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208445-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7F4221F251B1 for ; Mon, 10 Jun 2024 15:17:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4688140E4D; Mon, 10 Jun 2024 15:16:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="M3CxDOK0" 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 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: 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 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 = 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