Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp439002lqh; Fri, 31 May 2024 06:13:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUtc5kstCp070uSg6f/L185caIFguQXVNef9P0K25lCgZaPtAdC8E/JtKu6yYNp+vaEJ90vmSQqik6/eUqZm6Q7k6/KdWm4OjNL6kgO4w== X-Google-Smtp-Source: AGHT+IGKXkPB1fxuIm2Cdn0hnSiOuH5JQqTqQKICt5Z0r1b7jUOgIfZKkXoa0cr+pn8KA33EXx6m X-Received: by 2002:a50:d596:0:b0:574:eb69:fadf with SMTP id 4fb4d7f45d1cf-57a3656455fmr1226511a12.36.1717161232019; Fri, 31 May 2024 06:13:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717161232; cv=pass; d=google.com; s=arc-20160816; b=JUWCYuCvVT23BzOOWAW0XP0anfI3v/KJkOvGP7dpESfadifcwOAyj8K5Nu9ymfI2Gx kW3w0ZPTK3SKZjBc+nmtJVyz/aLY5U4nyUgb3mKNOo6PvSI5bweGpge0A63JVutLd3KF oFnNhRbW99zGyFsbMPLyKSNR3ZTbRd7pZN7QiJodTMTrA/Fx5nH2kFTHcs288pAD/VJE XaJa5NfrsfW8XBpTIpmRekqbecX95Zh3tns25NYn+pXBdhyeEAt19WIeQLxYxS4ctu1d wi7zUEqHu7T/wzPhoBapu/bOQxHXVUX8na5sv0bkQWiLJqn0snh5ZyP0ljXurGo9Xi4n OsHg== 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=+43FRKV7l9leGCNF/NwGeFktRFJDoXBSvlTDDl159ok=; fh=3qdKZaZnWy2Zq4/Kg/IJyvunFN5PAGmH2zs2MHj5FgQ=; b=heorc4KYDDHp3NDLfTqIcsPbP5SY8Bgf8GNZmaMlZg0Rkg+1/T1xO5nCvbUsZUO+oA pHTWVbqfkP9I/kfBUmaTnyBfg8foihEo48WR/FkUMLsy0bYj1OA5Li5qnryZFpvQLjz8 5tzXDsSTtpA4gmS4iVfx7tdio/BIyCwfg2aCtmqDTam9SU/1rl20TNUqTDDQZiPasrh/ ItBHxmNgVrp9lvyqUbZaL1J1jnjOzDxunzbY+TNL5idj4/L55zFLBwlZuhE+wBZlH7iR NPw83RSu3SifMKUo+uoDZj1nJarl2lplRE3HeMrkLuIt4eqwV+XRbVR6YruVm8H3AQWf dMSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=APaK9CVO; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-196853-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196853-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. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c6275esi913774a12.253.2024.05.31.06.13.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:13:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196853-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=APaK9CVO; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-196853-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196853-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 680741F27AEF for ; Fri, 31 May 2024 13:13:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58ED2158D60; Fri, 31 May 2024 13:12:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="APaK9CVO" 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 EB4EC158A26; Fri, 31 May 2024 13:12:40 +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=1717161162; cv=none; b=pFtvCJCtqolz12YZu/ZUCT2U33QrIbFKKPdaUBFo6io2NhpVGaQDDKh/cVme5qV/nx6bGNu9XBaARFOrQn4qVIKrQn57au3mXaWQRJx1s0ltEUs1ZIQgp9b/sEpvIXKO9J5K8ni8HXK0gBHJeT1fFlGPReH3FhzIuhAq56OVO0c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717161162; c=relaxed/simple; bh=LmE4FlciLL+cu5fhNjsY1HfGtrfdQq1IaG3rCXtdeTE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=h82MvzI49OXCI99Xp1NzuyFARN2zcNRLMSngKliLs0mYP+x3u0DTfh7BYx+64eeNEstYuUn13WenNprXoNmn01OfSWoA76CG4W8I5tF5LfipS7s4uMbLqvCy3stT3Ars/wPljQiQ8RQAOx9AkWg8wquHa9iL8l7d0Hq13RszmMw= 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=APaK9CVO; 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=1717161161; x=1748697161; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LmE4FlciLL+cu5fhNjsY1HfGtrfdQq1IaG3rCXtdeTE=; b=APaK9CVOly4kp6x66hL1TQpLKZAL0EHwT8zDMNXAQisujVIV5NBzPwD3 x/5AbEU3tHHaFgfDejElSzA3vphJ/qXncjBrh0xGJhS0N/7k7h/50eiRv XXiilIDxntH9HV/mW2TBODFtVysr7XCNWqyANDJ9i7Ge/rR+bagsJC9yp 0QVUMA+HdYdTn4f0EqjBJacCc9WiECaEOq8He41KGqVF9L2eY4froqxFr zERgLlA9ZK34WwEPtea8GMIoXLc9of+s3zk8Y5SIUYezhR2dqI+G23vkh XTcDz/33xjGdl3etu9FAueTSN0j+W5I433ElyKuYfVmFxQqZ+vZYGTycS A==; X-CSE-ConnectionGUID: azLxBRKqTIOCUkH6rj23FQ== X-CSE-MsgGUID: MFW1aUh8RkaS/oI6+Sl10g== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="17532563" X-IronPort-AV: E=Sophos;i="6.08,204,1712646000"; d="scan'208";a="17532563" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 06:12:40 -0700 X-CSE-ConnectionGUID: K4yOc981RrWEMy0toPsoQw== X-CSE-MsgGUID: l5fNEYQVQFSYLaVZ/ax+xA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,204,1712646000"; d="scan'208";a="36106903" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.152]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 06:12:36 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v5 05/16] selftests/resctrl: Use correct type for pids Date: Fri, 31 May 2024 16:11:31 +0300 Message-Id: <20240531131142.1716-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240531131142.1716-1-ilpo.jarvinen@linux.intel.com> References: <20240531131142.1716-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 --- 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 e1ae59063c51..d6f6db77d480 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -572,14 +572,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"); @@ -589,7 +589,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); @@ -832,7 +832,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