Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1763499rda; Tue, 24 Oct 2023 02:28:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDTsRS0vKq6TIxiEuCYvI1863YiuC71SScEo9ep6lQ6ZhbOk5pp9OIcj0i9vTNTbEttGy5 X-Received: by 2002:a17:90b:128e:b0:27d:4686:73b2 with SMTP id fw14-20020a17090b128e00b0027d468673b2mr10814828pjb.20.1698139735733; Tue, 24 Oct 2023 02:28:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698139735; cv=none; d=google.com; s=arc-20160816; b=aUd+yHt1GHbxYERqW4OOEYY9lPmBfeYgZ78hY+cj0ZMdw4oL8OURQLndN/zWMbaI9N rTZ+fXF8lb/iM5ou9Ty3lrsLXeMbIzb6qPqG1GJuoFYzt4VMiZgs+OmjnB7gRQg/mUx+ KzQWyrVgwnfGlNj8NHfoghO55R2uY0IKs2ZPz5hCp2U6ustGcYW4p0exFTBuchsDUuXQ bWlLasfbu0XP62bMO6dDjnBm4FZSPya2KyKGMnlmyAGEx4Fs+ukJdCsNuJcuirUbs362 qhOsWgxekzjcTN/ZH81q9ayNzZXkZ2vCCJyeNI4CKM4vlndL42T2EMpev6EhxyD/GFzV am2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rQFRIxqsi2m2crJK+3cGWPRZ3MOgzyPfZTUZZfw2pn4=; fh=gPQ6jqLSfsDb5bE3yrtO+AlT5R4d75RXkjC5xckz7Dk=; b=ZB86BAEAXgomoUlZn1S5KGHSUZpLLCdDIy0A+VUci42vBcVeVFnnqJ16YH/2kGwuYN joh74jNVRJj2oEK4uWfXEsb+djQMEUue1UgC6chCKOBqA9CHwIidWakjOUFiQR7zApQ7 bGrovriVBkYPn/NOVkAP6A7UADNqAkiLxU9UCXa2fhrAEkKaRistZYWijM0gSqx/aisc 7x9OxpL5IqEQAjqTBd4lrKWn1mdKf+o1aPQ6Ci98+l0ZX8JkmEAYUMidAB/WRq7jrQHK 0OIJ9TtlGGv2JJVFVLvp3N0uFFS/rBG9cWFQ+L7cNVAN7PwQh+cr3sM8bo5Oh2J7qiyW g6OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GpQsKIZD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id ot2-20020a17090b3b4200b0027cff4f35cbsi8626151pjb.73.2023.10.24.02.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 02:28:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GpQsKIZD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id E025F80569B1; Tue, 24 Oct 2023 02:28:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234220AbjJXJ2g (ORCPT + 99 others); Tue, 24 Oct 2023 05:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234223AbjJXJ2R (ORCPT ); Tue, 24 Oct 2023 05:28:17 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24896F9; Tue, 24 Oct 2023 02:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698139668; x=1729675668; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iXxHTqJrXVaGB5EYZWuORQMkSW5xHXnb5vc8EVQCUGk=; b=GpQsKIZDSX84wk77EYyplM8hYGyr78V8/4LoK7GW2Deentx1/VZCcqrN be7/yNYw8y5O7t1QMLWNKgXD+7+JEI/320JMPbpX2YmbPdpXpR2ICmRv2 mNyC8H8/9jDRHe/WbLkFJbxnytSGqRDIbHytgAV/9PBIQfk4fO5bKCAvc l8/FOeWXysVo771qK8M6BDgkTzP+RxTPBuI4fNclUrebM1PmgfbYSHqQc M5TDSU2Wd0vUewxa4LGwf2wHBafmE2BgvXm0/Il6HKrGMtEZy3AM+1f8C Wi+isqo0zrrD7CxLOp2aSHudPupFfCiZlgzPNToc0LF2cvoQkJ+cLS7Lh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="386829500" X-IronPort-AV: E=Sophos;i="6.03,247,1694761200"; d="scan'208";a="386829500" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 02:27:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="751939155" X-IronPort-AV: E=Sophos;i="6.03,247,1694761200"; d="scan'208";a="751939155" Received: from hprosing-mobl.ger.corp.intel.com (HELO localhost) ([10.249.40.219]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 02:27:43 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= , Fenghua Yu Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 07/24] selftests/resctrl: Split measure_cache_vals() function Date: Tue, 24 Oct 2023 12:26:17 +0300 Message-Id: <20231024092634.7122-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231024092634.7122-1-ilpo.jarvinen@linux.intel.com> References: <20231024092634.7122-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 24 Oct 2023 02:28:53 -0700 (PDT) The measure_cache_vals() function does a different thing depending on the test case that called it: - For CAT, it measures LLC perf misses. - For CMT, it measures LLC occupancy through resctrl. Split these two functionalities into own functions the CAT and CMT tests can call directly. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 37 ++++++++++--------- tools/testing/selftests/resctrl/resctrl.h | 2 +- tools/testing/selftests/resctrl/resctrl_val.c | 2 +- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index bcbca356d56a..299d9508221f 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -170,35 +170,36 @@ static int print_results_cache(char *filename, int bm_pid, return 0; } -int measure_cache_vals(struct resctrl_val_param *param, int bm_pid) +static int measure_llc_perf(struct resctrl_val_param *param, 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; + + ret = print_results_cache(param->filename, bm_pid, llc_perf_miss); + return ret; +} + +int measure_llc_resctrl(struct resctrl_val_param *param, int bm_pid) +{ + unsigned long llc_occu_resc = 0; + int 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 = get_llc_occu_resctrl(&llc_occu_resc); + if (ret < 0) return ret; - return 0; + ret = print_results_cache(param->filename, bm_pid, llc_occu_resc); + return ret; } /* @@ -253,7 +254,7 @@ int cat_val(struct resctrl_val_param *param, size_t span) } sleep(1); - ret = measure_cache_vals(param, bm_pid); + ret = measure_llc_perf(param, bm_pid); if (ret) goto pe_close; } diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 10fd3161e63a..56afdc190727 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -114,7 +114,7 @@ int cmt_resctrl_val(int cpu_no, int n, const char * const *benchmark_cmd); unsigned int count_bits(unsigned long n); void cmt_test_cleanup(void); int get_core_sibling(int cpu_no); -int measure_cache_vals(struct resctrl_val_param *param, int bm_pid); +int measure_llc_resctrl(struct resctrl_val_param *param, int bm_pid); int show_cache_info(unsigned long sum_llc_val, int no_of_bits, size_t cache_span, unsigned long max_diff, unsigned long max_diff_percent, unsigned long num_of_runs, diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 88789678917b..43ca026c6e0f 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -830,7 +830,7 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { sleep(1); - ret = measure_cache_vals(param, bm_pid); + ret = measure_llc_resctrl(param, bm_pid); if (ret) break; } -- 2.30.2