Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1694291rdb; Thu, 7 Dec 2023 06:32:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjMNRaV2Qy/VVtspk1ZwI/9Cwt8kDPLZUhxa0epiGeCgqrN1acJu7VZTfwBck+yOY67jsO X-Received: by 2002:a05:6a20:5481:b0:18f:bd86:ccaa with SMTP id i1-20020a056a20548100b0018fbd86ccaamr2605210pzk.55.1701959550284; Thu, 07 Dec 2023 06:32:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701959550; cv=none; d=google.com; s=arc-20160816; b=pkAP3+ZAENRIPhZqA/Zw6K3HxNvYahhiFKWn/y+ORDsPtBhK0ZOqf2uLLkj+Tc4na/ B3jxUiVwTI7CUKdDSu10nc08gNhR4Bp0bYWJx5EXZLqaGAZINJqeUmPV0TY74SeSniTc H4cLcMzvkUXeJtxIMreXYw7V4pfW1Gvh6INlwIQ2r9h4cUZrnvXcw2AbKkUB0y9n3rHn 7vV0qaqP5R8copuOmiOSckrYjCTjaKZn+8Hm3q8tNDfX7+Qs+GStgf18hY+EGgc5hNC3 6li/nWA/jE2Io0x7j4Rjd8/SVg4wMo0eJ5+xOWFnSzvBU5mhJoHTUJBIgn9viul8X5Hx /oMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=zX5uCLk1FBcUxmIFJ+9ZJ8m0tlRvDlOqkH8W/i3aPxQ=; fh=XHJC3rNtFqy9NBdwfesynq0dG98cBzq8Qrv2Usg7GS0=; b=WWdsm0/iztz75t6VMVkeXo9B30sIosfQuKhr0IQ6y+tDlBFYo09N5XbI9Eassf6Tkr N76xjr2XRgKfx3CghT0YXkWOCge4NlrcR443aLsrIkqgMGLrCENhHvSjYJzY6xpM6oqa 14285rBEwm/KYmjq/XP0oQbKm+gGJCQac9IMclUG3qFTuGz8fr7cM+JBcTXMOMgDGb9Z gnbCB6yQT82ArZ4ppSm4dEkQ0mF9LAAv6toDu0QSpgMa8AKeEoSEZy5B4Lffhe8PaTu3 6phpAHRRgfyTpdAlkVePKTItwISE3VrGtZ3JEL88EN7z0GJ53ueJz5a1mqj/3+J9gaT+ 7h0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vqro6IAH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id f13-20020a63554d000000b005b3bcd9d7f8si1226354pgm.808.2023.12.07.06.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 06:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vqro6IAH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8320B8032A37; Thu, 7 Dec 2023 06:32:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443214AbjLGOcM (ORCPT + 99 others); Thu, 7 Dec 2023 09:32:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232888AbjLGOcM (ORCPT ); Thu, 7 Dec 2023 09:32:12 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5034F121; Thu, 7 Dec 2023 06:32:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701959537; x=1733495537; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=IMMsqc0K2X/JwCbUNgUXoJZ7VcmenzGdCa/931H1GNA=; b=Vqro6IAHJ3j3wBBAfOwhxnjdwz3GyJquzm1k9f9TIhdsqBDOh5yb4UQi qMqyT9aqwgLm5Mo8n0HX/ypS9o1oy36YmOZYrSWwwbAPk3TNmGiruDzJP UKEmyZbIDHXWjX/m6MIgLhxHNDsIiwMjO9mvPHEISVzyQTAh80LMqN4+g NYwHTlbc+2+Zg2hjgZJfDfUcMXDY7MHvB1kjzw59thGHxjux7oyMU8r19 6AfTn2QkIBy5M6so8mQ6inhWO9KJ6fUugOhs2bNF501YB86TBMuOoIXOj qpu9oVHjXq3aaZTCDQsc5x7scrIcuDT+eQudUKowoDkM+bV3t0YwhrstX Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="397029637" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="397029637" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2023 06:32:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="19727735" Received: from dkrupnov-mobl3.ger.corp.intel.com ([10.249.34.6]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2023 06:32:15 -0800 Date: Thu, 7 Dec 2023 16:32:12 +0200 (EET) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Reinette Chatre cc: linux-kselftest@vger.kernel.org, Shuah Khan , Shaopeng Tan , =?ISO-8859-15?Q?Maciej_Wiecz=F3r-Retman?= , Fenghua Yu , LKML Subject: Re: [PATCH v2 08/26] selftests/resctrl: Split measure_cache_vals() In-Reply-To: Message-ID: References: <20231120111340.7805-1-ilpo.jarvinen@linux.intel.com> <20231120111340.7805-9-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-683619166-1701959536=:1765" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 07 Dec 2023 06:32:27 -0800 (PST) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-683619166-1701959536=:1765 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Tue, 28 Nov 2023, Reinette Chatre wrote: > Hi Ilpo, > > On 11/20/2023 3:13 AM, Ilpo Järvinen wrote: > > measure_cache_vals() does a different thing depending on the test case > > that called it: > > - For CAT, it measures LLC misses through perf. > > - For CMT, it measures LLC occupancy through resctrl. > > > > Split these two functionalities into own functions the CAT and CMT > > tests can call directly. Replace passing the struct resctrl_val_param > > parameter with the filename because it's more generic and all those > > functions need out of resctrl_val. > > > > Co-developed-by: Fenghua Yu > > Signed-off-by: Fenghua Yu > > Signed-off-by: Ilpo Järvinen > > --- > > tools/testing/selftests/resctrl/cache.c | 66 ++++++++++++------- > > tools/testing/selftests/resctrl/resctrl.h | 2 +- > > tools/testing/selftests/resctrl/resctrl_val.c | 2 +- > > 3 files changed, 43 insertions(+), 27 deletions(-) > > > > diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c > > index 8aa6d67db978..129d1c293518 100644 > > --- a/tools/testing/selftests/resctrl/cache.c > > +++ b/tools/testing/selftests/resctrl/cache.c > > @@ -147,7 +147,7 @@ static int get_llc_occu_resctrl(unsigned long *llc_occupancy) > > * > > * Return: 0 on success. non-zero on failure. > > */ > > -static int print_results_cache(char *filename, int bm_pid, > > +static int print_results_cache(const char *filename, int bm_pid, > > unsigned long llc_value) > > { > > FILE *fp; > > @@ -169,35 +169,51 @@ static int print_results_cache(char *filename, int bm_pid, > > return 0; > > } > > > > -int measure_cache_vals(struct resctrl_val_param *param, int bm_pid) > > +/* > > + * perf_event_measure - Measure perf events > > + * @filename: Filename for writing the results > > + * @bm_pid: PID that runs the benchmark > > + * > > + * Measures perf events (e.g., cache misses) and writes the results into > > + * @filename. @bm_pid is written to the results file along with the measured > > + * value. > > + * > > + * Return: =0 on success. <0 on failure. > > I do not think this is accurate. It looks like this function returns > the return value of print_results_cache() which returns errno on failure. > If this is the case then I think this proves that returning a > positive integer on failure should be avoided since it just creates > traps. > > > + */ > > +static int perf_event_measure(const char *filename, int bm_pid) > > { > > - unsigned long llc_perf_miss = 0, llc_occu_resc = 0, llc_value = 0; > > + unsigned long llc_perf_miss = 0; > > int ret; > > > > - /* > > - * Measure cache miss from perf. > > - */ > > - if (!strncmp(param->resctrl_val, CAT_STR, sizeof(CAT_STR))) { > > - ret = get_llc_perf(&llc_perf_miss); > > - if (ret < 0) > > - return ret; > > - llc_value = llc_perf_miss; > > - } > > + ret = get_llc_perf(&llc_perf_miss); > > + if (ret < 0) > > + return ret; > > > > - /* > > - * Measure llc occupancy from resctrl. > > - */ > > - if (!strncmp(param->resctrl_val, CMT_STR, sizeof(CMT_STR))) { > > - ret = get_llc_occu_resctrl(&llc_occu_resc); > > - if (ret < 0) > > - return ret; > > - llc_value = llc_occu_resc; > > - } > > - ret = print_results_cache(param->filename, bm_pid, llc_value); > > - if (ret) > > + ret = print_results_cache(filename, bm_pid, llc_perf_miss); > > + return ret; > > +} > > Perhaps print_results_cache() can be made to return negative error > and this just be "return print_results_cache(...)" and the function > comment be accurate? I think, I'll just change all "return errno;" to "return -1" before this, however, one open question which impacts whether this is actually Fixes class issue: It seems that perror()'s manpage doesn't answer one important question, whether it ifself can alter errno or not. The resctrl selftest code assumes it doesn't but some evidence I came across says otherwise so doing return errno; after calling perror() might not even be valid at all. So I'm tempted to create an additional Fixes patch about the return change into the front of the series. -- i. --8323329-683619166-1701959536=:1765--