From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 E45773750C8; Fri, 13 Mar 2026 20:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433978; cv=none; b=PWPODxHa1QnOzW1SaHex9ydln1QboU06sa912vW4Cr4xNKa6lF3ShGFpyhn/riuve/vBtnXvHNccatLW5TxVWOiK3L5XZwTg4RIwuJ6SGtBhjUHZq0WQFenvJw910igLhiaEiQTQVeyS6JjKXOlth87WcQtJy1tss+NznkwUeg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433978; c=relaxed/simple; bh=K0sRnBTzLAKEaUFmotmN9mOQL4fHuh6XPiToj5j1qV0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aWjs+jqUoFD2Dq/56eZuEcBjNtUoBxkFj/wBAr2lCLy8rn29X6cLZhFTjavuT3+GyBgxS3JVwYLukyGmMLIEqYaqnJmb/G1v/pWWMME4HvxHsx48TaYjPl7A2wHhUYF0LxfFKZegL4J/Ib7YlkUsfPft9tt3Mg71Et7C8jaMfUI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Z72TlZnN; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Z72TlZnN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773433974; x=1804969974; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K0sRnBTzLAKEaUFmotmN9mOQL4fHuh6XPiToj5j1qV0=; b=Z72TlZnNo3xGuzsUHud4SzFIrSmH2lEnjGgKg9f/D0g/89Q5wWlfCn6z vs2JIRE2RYywAURr48zyVufGnorpVRzNwDElbwbWy13Fei449/KFrZUGl cFIck6li8J8VExB/FLE00mmowQ3xTucubaFyjp5GdWyW0fBEb8FoV/9H6 KgKgJXdPITBxnbwLWCZy0rD/h6JJAsySt87cfMC40hpHHjuQORJTJUdHp HqtedtEXE1yVqjRjKfBK2yEpXSBpIB4z7yVgu4YjvSisrNLQcOhEYMro5 5FVS7kngj9lkZts6TpadPKRToQfhNbnfXuvYr7A2iHfb7FwLtr01cq4ot g==; X-CSE-ConnectionGUID: 9fFjYwZxS0uBKVZY5x8PQQ== X-CSE-MsgGUID: 5gAs8+bZSBKNVi/EyY+87g== X-IronPort-AV: E=McAfee;i="6800,10657,11728"; a="74519250" X-IronPort-AV: E=Sophos;i="6.23,118,1770624000"; d="scan'208";a="74519250" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:52 -0700 X-CSE-ConnectionGUID: fhwvXaVXTmGnGmIoOMHcJw== X-CSE-MsgGUID: 4EluSVhMR2OJdgfcmCC20g== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:51 -0700 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: fenghuay@nvidia.com, peternewman@google.com, zide.chen@intel.com, dapeng1.mi@linux.intel.com, ben.horgan@arm.com, yu.c.chen@intel.com, jason.zeng@intel.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v3 01/10] selftests/resctrl: Improve accuracy of cache occupancy test Date: Fri, 13 Mar 2026 13:32:28 -0700 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Dave Martin reported inconsistent CMT test failures. In one experiment the first run of the CMT test failed because of too large (24%) difference between measured and achievable cache occupancy while the second run passed with an acceptable 4% difference. The CMT test is susceptible to interference from the rest of the system. This can be demonstrated with a utility like stress-ng by running the CMT test while introducing cache misses using: stress-ng --matrix-3d 0 --matrix-3d-zyx Below shows an example of the CMT test failing because of a significant difference between measured and achievable cache occupancy when run with interference: # Starting CMT test ... # Mounting resctrl to "/sys/fs/resctrl" # Cache size :335544320 # Writing benchmark parameters to resctrl FS # Benchmark PID: 7011 # Checking for pass/fail # Fail: Check cache miss rate within 15% # Percent diff=3D99 # Number of bits: 5 # Average LLC val: 235929 # Cache span (bytes): 83886080 not ok 1 CMT: test The CMT test creates a new control group that is also capable of monitoring and assigns the workload to it. The workload allocates a buffer that by default fills a portion of the L3 and keeps reading from the buffer, measuring the L3 occupancy at intervals. The test passes if the workload's L3 occupancy is within 15% of the buffer size. By not adjusting any capacity bitmasks the workload shares the cache with the rest of the system. Any other task that may be running could evict the workload's data from the cache causing it to have low cache occupancy. Reduce interference from the rest of the system by ensuring that the workload's control group uses the capacity bitmask found in the user parameters for L3 and that the rest of the system can only allocate into the inverse of the workload's L3 cache portion. Other tasks can thus no longer evict the workload's data from L3. With the above adjustments the CMT test is more consistent. Repeating the CMT test while generating interference with stress-ng on a sample system after applying the fixes show significant improvement in test accuracy: # Starting CMT test ... # Mounting resctrl to "/sys/fs/resctrl" # Cache size :335544320 # Writing benchmark parameters to resctrl FS # Write schema "L3:0=3Dfffe0" to resctrl FS # Write schema "L3:0=3D1f" to resctrl FS # Benchmark PID: 7089 # Checking for pass/fail # Pass: Check cache miss rate within 15% # Percent diff=3D12 # Number of bits: 5 # Average LLC val: 73269248 # Cache span (bytes): 83886080 ok 1 CMT: test Reported-by: Dave Martin Signed-off-by: Reinette Chatre Tested-by: Chen Yu Link: https://lore.kernel.org/lkml/aO+7MeSMV29VdbQs@e133380.arm.com/ Reviewed-by: Ilpo J=C3=A4rvinen --- Changes since v1: - Fix typo in changelog: "data my be in L2" -> "data may be in L2". Changes since v2: - Split patch to separate changes impacting L3 and L2 resource. (Ilpo) - Re-run tests after patch split to ensure test impact match patch and update changelog with refreshed data. - Since fix is now split across two patches: "Closes:" -> "Link:" - Rename "long_mask" to "full_mask". (Ilpo) - Add Chen Yu's tag. --- tools/testing/selftests/resctrl/cmt_test.c | 26 +++++++++++++++++-- tools/testing/selftests/resctrl/mba_test.c | 4 ++- tools/testing/selftests/resctrl/mbm_test.c | 4 ++- tools/testing/selftests/resctrl/resctrl.h | 4 ++- tools/testing/selftests/resctrl/resctrl_val.c | 2 +- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/sel= ftests/resctrl/cmt_test.c index d09e693dc739..7bc6cf49c1c5 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -19,12 +19,34 @@ #define CON_MON_LCC_OCCUP_PATH \ "%s/%s/mon_data/mon_L3_%02d/llc_occupancy" =20 -static int cmt_init(const struct resctrl_val_param *param, int domain_id) +/* + * Initialize capacity bitmasks (CBMs) of: + * - control group being tested per test parameters, + * - default resource group as inverse of control group being tested to pr= event + * other tasks from interfering with test. + */ +static int cmt_init(const struct resctrl_test *test, + const struct user_params *uparams, + const struct resctrl_val_param *param, int domain_id) { + unsigned long full_mask; + char schemata[64]; + int ret; + sprintf(llc_occup_path, CON_MON_LCC_OCCUP_PATH, RESCTRL_PATH, param->ctrlgrp, domain_id); =20 - return 0; + ret =3D get_full_cbm(test->resource, &full_mask); + if (ret) + return ret; + + snprintf(schemata, sizeof(schemata), "%lx", ~param->mask & full_mask); + ret =3D write_schemata("", schemata, uparams->cpu, test->resource); + if (ret) + return ret; + + snprintf(schemata, sizeof(schemata), "%lx", param->mask); + return write_schemata(param->ctrlgrp, schemata, uparams->cpu, test->resou= rce); } =20 static int cmt_setup(const struct resctrl_test *test, diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/sel= ftests/resctrl/mba_test.c index c7e9adc0368f..cd4c715b7ffd 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -17,7 +17,9 @@ #define ALLOCATION_MIN 10 #define ALLOCATION_STEP 10 =20 -static int mba_init(const struct resctrl_val_param *param, int domain_id) +static int mba_init(const struct resctrl_test *test, + const struct user_params *uparams, + const struct resctrl_val_param *param, int domain_id) { int ret; =20 diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/sel= ftests/resctrl/mbm_test.c index 84d8bc250539..58201f844740 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -83,7 +83,9 @@ static int check_results(size_t span) return ret; } =20 -static int mbm_init(const struct resctrl_val_param *param, int domain_id) +static int mbm_init(const struct resctrl_test *test, + const struct user_params *uparams, + const struct resctrl_val_param *param, int domain_id) { int ret; =20 diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index afe635b6e48d..c72045c74ac4 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -135,7 +135,9 @@ struct resctrl_val_param { char filename[64]; unsigned long mask; int num_of_runs; - int (*init)(const struct resctrl_val_param *param, + int (*init)(const struct resctrl_test *test, + const struct user_params *uparams, + const struct resctrl_val_param *param, int domain_id); int (*setup)(const struct resctrl_test *test, const struct user_params *uparams, diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index 7c08e936572d..a5a8badb83d4 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -569,7 +569,7 @@ int resctrl_val(const struct resctrl_test *test, goto reset_affinity; =20 if (param->init) { - ret =3D param->init(param, domain_id); + ret =3D param->init(test, uparams, param, domain_id); if (ret) goto reset_affinity; } --=20 2.50.1 From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 142203750BD; Fri, 13 Mar 2026 20:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433977; cv=none; b=fFxxZcA+TIy+bm+MrJH0zGa3wbdaR5TiLqquKieFqA3EcwFAsGCLJnlmTJ8jQJhIaVPMGn5+6Cd7FvefVwwRwUujFNKYsR1awqYXK7Hw35IlzeJflCw1w6aQ3xXCrYxtl+boR+rnHqgIIgM1WeyIuVffQ9oTk7ylP6Q6YQFZYQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433977; c=relaxed/simple; bh=wHySwkzpJMKcOqasv7ax2q0a0lzkXceTKn3QKFWr284=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ip5T5wIV60Azgc7gTGOVypIYNIeS3M5VYsmxCuywEZQ4EnpTof9VnRx/2IMaWquTXDxvLIsS0Gce8oSFRKvJy+IVtlgFAR2bMcSEJV0xud2cnM6T3t7nIER9ZXlZkC9sXn+BEoTNFfXDFullJWnHP6ceoxwAtNpRBT4XDrdIwTY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Sf5V3B6a; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Sf5V3B6a" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773433975; x=1804969975; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wHySwkzpJMKcOqasv7ax2q0a0lzkXceTKn3QKFWr284=; b=Sf5V3B6aYC86v/g5LOdRYWwMRRZx9DYgtXCZOisPLCwqwps0MJSGEWV7 0f/0YzzGE7PPx1msdBRtABYnXync9d1wCjS/vGKmnlnIIT5gBVwTox/wZ 5laoS+QIOaePhrVGTgT2eZyvAlEGw5DUa8rOfQz8mF6lB8iHSJzkDvJAP cFHp18cSiQvoOJRZmwIN1WrgMHbiwh/1Jw7TZ2VfigPAhfIAFRyxW6Urc hHuB4jp7xW2SoqRhtTBLNOgIhFmlLUW3cbSUDq8l4xthQdp4MUy+8ghgX WrByJn/0QYlrTwSS1Omu16nej7e08YgT3AOXcj52mTjJORNLJJ7sZZcq+ Q==; X-CSE-ConnectionGUID: Sl1gS8hzQt6B7Lk6ZuWA8A== X-CSE-MsgGUID: xL71xx8SQXS1DOdRYdVnAA== X-IronPort-AV: E=McAfee;i="6800,10657,11728"; a="74519258" X-IronPort-AV: E=Sophos;i="6.23,118,1770624000"; d="scan'208";a="74519258" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:52 -0700 X-CSE-ConnectionGUID: +SJZRA8LT1ms1Z7Vacq01A== X-CSE-MsgGUID: IbhoQIKSQ3yPPWGPkLbOfQ== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:51 -0700 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: fenghuay@nvidia.com, peternewman@google.com, zide.chen@intel.com, dapeng1.mi@linux.intel.com, ben.horgan@arm.com, yu.c.chen@intel.com, jason.zeng@intel.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v3 02/10] selftests/resctrl: Reduce interference from L2 occupancy during cache occupancy test Date: Fri, 13 Mar 2026 13:32:29 -0700 Message-ID: <5a23acd72af3ea0513f730d7773108586f68c430.1773432891.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The CMT test creates a new control group that is also capable of monitoring and assigns the workload to it. The workload allocates a buffer that by default fills a portion of the L3 and keeps reading from the buffer, measuring the L3 occupancy at intervals. The test passes if the workload's L3 occupancy is within 15% of the buffer size. The CMT test does not take into account that some of the workload's data may land in L2/L1. Matching L3 occupancy to the size of the buffer while a portion of the buffer can be allocated into L2 is not accurate. Take the L2 cache into account to improve test accuracy: - Reduce the workload's L2 cache allocation to the minimum on systems that support L2 cache allocation. Do so with a new utility in preparation for all L3 cache allocation tests needing the same capability. - Increase the buffer size to accommodate data that may be allocated into the L2 cache. Use a buffer size double the L3 portion to keep using the L3 portion size as goal for L3 occupancy while taking into account that some of the data may be in L2. Running the CMT test on a sample system while introducing significant cache misses using "stress-ng --matrix-3d 0 --matrix-3d-zyx" shows significant improvement in L3 cache occupancy: Before: # Starting CMT test ... # Mounting resctrl to "/sys/fs/resctrl" # Cache size :335544320 # Writing benchmark parameters to resctrl FS # Write schema "L3:0=3Dfffe0" to resctrl FS # Write schema "L3:0=3D1f" to resctrl FS # Benchmark PID: 7089 # Checking for pass/fail # Pass: Check cache miss rate within 15% # Percent diff=3D12 # Number of bits: 5 # Average LLC val: 73269248 # Cache span (bytes): 83886080 ok 1 CMT: test After: # Starting CMT test ... # Mounting resctrl to "/sys/fs/resctrl" # Cache size :335544320 # Writing benchmark parameters to resctrl FS # Write schema "L3:0=3Dfffe0" to resctrl FS # Write schema "L3:0=3D1f" to resctrl FS # Write schema "L2:1=3D0x1" to resctrl FS # Benchmark PID: 7171 # Checking for pass/fail # Pass: Check cache miss rate within 15% # Percent diff=3D0 # Number of bits: 5 # Average LLC val: 83755008 # Cache span (bytes): 83886080 ok 1 CMT: test Reported-by: Dave Martin Signed-off-by: Reinette Chatre Tested-by: Chen Yu Link: https://lore.kernel.org/lkml/aO+7MeSMV29VdbQs@e133380.arm.com/ Reviewed-by: Ilpo J=C3=A4rvinen --- Changes since v2: - New patch split from v1's "selftests/resctrl: Improve accuracy of cache occupancy test". (Ilpo) - Reword changelog. (Ilpo) - Update data used in changelog to match code after patch split. - Introduce utility to reduce L2 cache allocation. (Ilpo) - Add Chen Yu's tag. --- tools/testing/selftests/resctrl/cache.c | 13 +++++++++++++ tools/testing/selftests/resctrl/cmt_test.c | 14 ++++++++++---- tools/testing/selftests/resctrl/resctrl.h | 3 +++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selfte= sts/resctrl/cache.c index 1ff1104e6575..bef71b6feacc 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -173,6 +173,19 @@ int measure_llc_resctrl(const char *filename, pid_t bm= _pid) return print_results_cache(filename, bm_pid, llc_occu_resc); } =20 +/* + * Reduce L2 allocation to minimum when testing L3 cache allocation. + */ +int minimize_l2_occupancy(const struct resctrl_test *test, + const struct user_params *uparams, + const struct resctrl_val_param *param) +{ + if (!strcmp(test->resource, "L3") && resctrl_resource_exists("L2")) + return write_schemata(param->ctrlgrp, "0x1", uparams->cpu, "L2"); + + return 0; +} + /* * show_cache_info - Show generic cache test information * @no_of_bits: Number of bits diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/sel= ftests/resctrl/cmt_test.c index 7bc6cf49c1c5..ccb6fe881a94 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -23,7 +23,9 @@ * Initialize capacity bitmasks (CBMs) of: * - control group being tested per test parameters, * - default resource group as inverse of control group being tested to pr= event - * other tasks from interfering with test. + * other tasks from interfering with test, + * - L2 resource of control group being tested to minimize allocations into + * L2 if possible to better predict L3 occupancy. */ static int cmt_init(const struct resctrl_test *test, const struct user_params *uparams, @@ -46,7 +48,11 @@ static int cmt_init(const struct resctrl_test *test, return ret; =20 snprintf(schemata, sizeof(schemata), "%lx", param->mask); - return write_schemata(param->ctrlgrp, schemata, uparams->cpu, test->resou= rce); + ret =3D write_schemata(param->ctrlgrp, schemata, uparams->cpu, test->reso= urce); + if (ret) + return ret; + + return minimize_l2_occupancy(test, uparams, param); } =20 static int cmt_setup(const struct resctrl_test *test, @@ -175,11 +181,11 @@ static int cmt_run_test(const struct resctrl_test *te= st, const struct user_param span =3D cache_portion_size(cache_total_size, param.mask, long_mask); =20 if (uparams->fill_buf) { - fill_buf.buf_size =3D span; + fill_buf.buf_size =3D span * 2; fill_buf.memflush =3D uparams->fill_buf->memflush; param.fill_buf =3D &fill_buf; } else if (!uparams->benchmark_cmd[0]) { - fill_buf.buf_size =3D span; + fill_buf.buf_size =3D span * 2; fill_buf.memflush =3D true; param.fill_buf =3D &fill_buf; } diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index c72045c74ac4..7f2ab28be857 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -216,6 +216,9 @@ int perf_event_reset_enable(int pe_fd); int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, const char *filename, pid_t bm_pid); int measure_llc_resctrl(const char *filename, pid_t bm_pid); +int minimize_l2_occupancy(const struct resctrl_test *test, + const struct user_params *uparams, + const struct resctrl_val_param *param); void show_cache_info(int no_of_bits, __u64 avg_llc_val, size_t cache_span,= bool lines); =20 /* --=20 2.50.1 From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 A164637418E; Fri, 13 Mar 2026 20:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433980; cv=none; b=kOP/WFwfPzuuh1ImjG/fQ2negBF0/0PXJ7pA6FnF4UWzXTovwsB3KA0lkjA4sDWCLzMrHPF1AZNcTqWuxWzF4L5//WC3yiNKda9mJ8eOP+sDXL09DIq/y6xnK+VigTfmQxjlqhDTHyy06KOK2EUtdK/d3synvGSxQ7wWoVTHH6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433980; c=relaxed/simple; bh=5Qmoh1Ru8vMO1Nfg8X9L40uIhnik+WL6a07fapKwUMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aD6J4aNrrzi8k5v83iI8IEMWa/f1U9Fhiw3yNm7wVM0pCA9i0b3+HhvaSKoCKKMse/Vybs++mvx8xA0IN2OYAEYTPyljuoGO9617w3D69/KszNdcbgB2bReoJBUW+Yk8X1rA0gd/QNaTpYu94jtLuF6zFcflWWP1FFzxU6D1JRE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=flIieYJt; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="flIieYJt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773433976; x=1804969976; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5Qmoh1Ru8vMO1Nfg8X9L40uIhnik+WL6a07fapKwUMA=; b=flIieYJtHIto4bTRU7X7Q0qwAG9/N6DBnYRa37hBfF7BNjpNdCHzhM5+ 2Pa+4iwx1X+fPTTBJsE2Vu//iuvthv6eXIHJ0b/XjxtyAEsNDzf0BuHsY zShPu2+jKWxX97XkNto/ZiC4UFkr4WOQrUGS1Ilw9LHWXO4BrJRiyhvP9 ZTJwZITjWaKWWMDeOcwmuZw9tg4GWPpcbnwVtvqq2lAA+NoToWZ/nKzeS DwP7/rIfGXlERWWwqsp15TadXAh9AHPT86zKPuFqD07bJsbfNfueqFV/R U+opb+TkmpqOV2j9DJy/QU5L6gXOxbhcgU38TURtg4CR3hZ5SsfDqL6Rf Q==; X-CSE-ConnectionGUID: 5+pVJRIzSVeLI/TzpXOn5Q== X-CSE-MsgGUID: 2DDa6RptTBqP0aetje88Jw== X-IronPort-AV: E=McAfee;i="6800,10657,11728"; a="74519261" X-IronPort-AV: E=Sophos;i="6.23,118,1770624000"; d="scan'208";a="74519261" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:52 -0700 X-CSE-ConnectionGUID: iCw53FMmSSu4kTdbYbFHLw== X-CSE-MsgGUID: q0fTUhVzQx+h2gaOhI5r4w== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:52 -0700 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: fenghuay@nvidia.com, peternewman@google.com, zide.chen@intel.com, dapeng1.mi@linux.intel.com, ben.horgan@arm.com, yu.c.chen@intel.com, jason.zeng@intel.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v3 03/10] selftests/resctrl: Do not store iMC counter value in counter config structure Date: Fri, 13 Mar 2026 13:32:30 -0700 Message-ID: <740f2fe57503ea8baf8e4b5bcdf5680e90f76c3a.1773432891.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: 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 The MBM and MBA tests compare MBM memory bandwidth measurements against the memory bandwidth event values obtained from each memory controller's PMU. The memory bandwidth event settings are discovered from the memory controller details found in /sys/bus/event_source/devices/uncore_imc_N and stored in struct imc_counter_config. In addition to event settings struct imc_counter_config contains imc_counter_config::return_value in which the associated event value is stored on every read. The event value is consumed and immediately recorded at regular intervals. The stored value is never consumed afterwards, making its storage as part of event configuration unnecessary. Remove the return_value member from struct imc_counter_config. Instead just use a more aptly named "measurement" local variable for use during event reading. Signed-off-by: Reinette Chatre Tested-by: Chen Yu Reviewed-by: Ilpo J=C3=A4rvinen --- Changes since v2: - Rename "return_value" -> "measurement". (Ilpo) - Add Ilpo's Rb tag. - Add Chen Yu's tag. --- tools/testing/selftests/resctrl/resctrl_val.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index a5a8badb83d4..71d6f88cc1f7 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -32,7 +32,6 @@ struct imc_counter_config { __u64 event; __u64 umask; struct perf_event_attr pe; - struct membw_read_format return_value; int fd; }; =20 @@ -312,23 +311,23 @@ static int get_read_mem_bw_imc(float *bw_imc) * Take overflow into consideration before calculating total bandwidth. */ for (imc =3D 0; imc < imcs; imc++) { + struct membw_read_format measurement; struct imc_counter_config *r =3D &imc_counters_config[imc]; =20 - if (read(r->fd, &r->return_value, - sizeof(struct membw_read_format)) =3D=3D -1) { + if (read(r->fd, &measurement, sizeof(measurement)) =3D=3D -1) { ksft_perror("Couldn't get read bandwidth through iMC"); return -1; } =20 - __u64 r_time_enabled =3D r->return_value.time_enabled; - __u64 r_time_running =3D r->return_value.time_running; + __u64 r_time_enabled =3D measurement.time_enabled; + __u64 r_time_running =3D measurement.time_running; =20 if (r_time_enabled !=3D r_time_running) of_mul_read =3D (float)r_time_enabled / (float)r_time_running; =20 - reads +=3D r->return_value.value * of_mul_read * SCALE; + reads +=3D measurement.value * of_mul_read * SCALE; } =20 *bw_imc =3D reads; --=20 2.50.1 From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 F1D63373BF4; Fri, 13 Mar 2026 20:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433980; cv=none; b=iSHwubiAMDvuSQpfmfVH1tu8atS7U66OPYZCc3NRjYNul1lJxO2qm3eseq3eTkeyrj8soMn1TkmlR+9AfBcK6oSeLH/oWLhv7J0n82n+gF1xGqU6CKSs5W3CdWIJNPEjTJAZ+mLzMBIEQT65AECjumXPuG1fLqKdZ+Oj+rP9Iz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433980; c=relaxed/simple; bh=V9TtxLP490ADDmCo6Njop/gsPvtbt2wtkdT3+0ESNaI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yl4Y3EvzSjuKrJXMtA5F9XsMr41kVHjcl6IdzsNNB2pimxrGYY/RIZ/dGxloHodXT/Y/jb8YZIHL0LEZvUpEQ6i0tfUXrL9PjpiSToJjBTJCKYNGAigt86hwZeLZRReCDtYy1jIGalMccKEnVQRvP0P5IR6jlOmufrgFWR9RdUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=adEbZLa9; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="adEbZLa9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773433978; x=1804969978; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V9TtxLP490ADDmCo6Njop/gsPvtbt2wtkdT3+0ESNaI=; b=adEbZLa9uMtK4905EilOCXU3/XTmO0Gi0rF2i0HPpe20zUlyJBK/ra/e 1luFMMXpV3FuPg2eMUSpMHQz3zOAFLsf6UByHpHqD+p6qvvBjiftQ/gY/ p4O99P+kSu3MmxG3VjmhLAJGsrqVLi+vg/a1woRld4o+AoVGjhkgcY81D NCxxRoqMU3rTFh/yS8h0LZlkfhA2pD7o52pi4+FAqpvLNIH642SO16T/j yPixbrH946apA6GGpEmImUiKTqTL6Y43AqzYQSzKKIM+CqukA1w0vL9FF mw4LoIpLdECV6Q8WAUXOL4VtZYHKS8K5hzh/5vC9wlVlsF09lboPS6BtZ A==; X-CSE-ConnectionGUID: mrX8BS6tQN6sFUQzCuYZgQ== X-CSE-MsgGUID: FYu4V0JnRfSfkRXcYk6CmA== X-IronPort-AV: E=McAfee;i="6800,10657,11728"; a="74519268" X-IronPort-AV: E=Sophos;i="6.23,118,1770624000"; d="scan'208";a="74519268" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:53 -0700 X-CSE-ConnectionGUID: cl9l2Wo9QwGX0DCUrHVpiA== X-CSE-MsgGUID: OuF5eIK/TPSzS/0YtZZaBA== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:52 -0700 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: fenghuay@nvidia.com, peternewman@google.com, zide.chen@intel.com, dapeng1.mi@linux.intel.com, ben.horgan@arm.com, yu.c.chen@intel.com, jason.zeng@intel.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v3 04/10] selftests/resctrl: Prepare for parsing multiple events per iMC Date: Fri, 13 Mar 2026 13:32:31 -0700 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The events needed to read memory bandwidth are discovered by iterating over every memory controller (iMC) within /sys/bus/event_source/devices. Each iMC's PMU is assumed to have one event to measure read memory bandwidth that is represented by the sysfs cas_count_read file. The event's configuration is read from "cas_count_read" and stored as an element of imc_counters_config[] by read_from_imc_dir() that receives the index of the array where to store the configuration as argument. It is possible that an iMC's PMU may have more than one event that should be used to measure memory bandwidth. Change semantics to not provide the index of the array to read_from_imc_dir() but instead a pointer to the index. This enables read_from_imc_dir() to store configurations for more than one event by incrementing the index to imc_counters_config[] itself. Ensure that the same type is consistently used for the index as it is passed around during counter configuration. Signed-off-by: Reinette Chatre Tested-by: Chen Yu Reviewed-by: Zide Chen Reviewed-by: Ilpo J=C3=A4rvinen --- Changes since v1: - Add Zide Chen's RB tag. Changes since v2: - Add Chen Yu's tag. --- tools/testing/selftests/resctrl/resctrl_val.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index 71d6f88cc1f7..6d766347e3fc 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -73,7 +73,7 @@ static void read_mem_bw_ioctl_perf_event_ioc_disable(int = i) * @cas_count_cfg: Config * @count: iMC number */ -static void get_read_event_and_umask(char *cas_count_cfg, int count) +static void get_read_event_and_umask(char *cas_count_cfg, unsigned int cou= nt) { char *token[MAX_TOKENS]; int i =3D 0; @@ -110,7 +110,7 @@ static int open_perf_read_event(int i, int cpu_no) } =20 /* Get type and config of an iMC counter's read event. */ -static int read_from_imc_dir(char *imc_dir, int count) +static int read_from_imc_dir(char *imc_dir, unsigned int *count) { char cas_count_cfg[1024], imc_counter_cfg[1024], imc_counter_type[1024]; FILE *fp; @@ -123,7 +123,7 @@ static int read_from_imc_dir(char *imc_dir, int count) =20 return -1; } - if (fscanf(fp, "%u", &imc_counters_config[count].type) <=3D 0) { + if (fscanf(fp, "%u", &imc_counters_config[*count].type) <=3D 0) { ksft_perror("Could not get iMC type"); fclose(fp); =20 @@ -147,7 +147,8 @@ static int read_from_imc_dir(char *imc_dir, int count) } fclose(fp); =20 - get_read_event_and_umask(cas_count_cfg, count); + get_read_event_and_umask(cas_count_cfg, *count); + *count +=3D 1; =20 return 0; } @@ -196,13 +197,12 @@ static int num_of_imcs(void) if (temp[0] >=3D '0' && temp[0] <=3D '9') { sprintf(imc_dir, "%s/%s/", DYN_PMU_PATH, ep->d_name); - ret =3D read_from_imc_dir(imc_dir, count); + ret =3D read_from_imc_dir(imc_dir, &count); if (ret) { closedir(dp); =20 return ret; } - count++; } } closedir(dp); --=20 2.50.1 From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 D5B26375F8A; Fri, 13 Mar 2026 20:32:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433981; cv=none; b=J1GDZ6WT8Uwxm1FZllN776gkBCsiPJ413FT32X9Z+N0bZrGKicqScal0A8n+Hp+KDsTAToRoIOfyoJ08y4d+hI79BcA7hmme1m07nGduP12V5u8+aQaTwIfI7bSVxwF0fAKpYBoFeeKVq2GPMVLyM776R4LbNLlBOQlM9FV7LKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433981; c=relaxed/simple; bh=JpJBirW5YRJ9O7ntARHf6YHyVtuL0CccCFlmEXFnSns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YZamDOKV6pv6xbfHkYSbE4YOtIwNjrFCeh1+anO8kK2I5dgthCYxyd3qT0gpyXvZ/sxSCVs3jZOh25lRZyoGtVSnoJURDmrBE6cvJHGC0cIsV3gasIqM660AkKkLyJAbp4re2ELZzGRLkdHEDimRP6Jv4EzihULYdLn3SutWNjM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NTgCVmxO; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NTgCVmxO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773433979; x=1804969979; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JpJBirW5YRJ9O7ntARHf6YHyVtuL0CccCFlmEXFnSns=; b=NTgCVmxOJfYtgvswVrm9SebkXHxd1g6V0sRjVzp99FqvpBPwUQL3qv9d NzbKOSLd9Kz27RsK/qHD6OGx5w99FVJun0gVGI7mCznNntmdV/sDkz9i1 DqaAq+hoE3L3KkUXicGT2OEhsQ3Tu1zM/o81wrK1v6hMzX6ySlznDfP+z 0fIQhmNWodqqXPWtoy3sQB5JzukUW3OdgdzGYUaCOCcz3bU7+W9pHuuyv XDK0fYB0ZPPqgvOyZAQ1vxLUPw9ltAewk+7wXmxv1qCN7vnM3i/LNd8en IYkMbDzsCjCr6ViV5GgG/AAymd3pYPX2YOzXuPxqmip6Lr/ouSWC98aAP A==; X-CSE-ConnectionGUID: vVBmsq71TiuLwkkmY8IKjw== X-CSE-MsgGUID: zOe7n9g5Sh+grAzl6L5Hjg== X-IronPort-AV: E=McAfee;i="6800,10657,11728"; a="74519277" X-IronPort-AV: E=Sophos;i="6.23,118,1770624000"; d="scan'208";a="74519277" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:54 -0700 X-CSE-ConnectionGUID: rUmXAkv5RlKT/zx1kXQa4g== X-CSE-MsgGUID: LX0odvwPQGC5dVkkesjiYw== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:53 -0700 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: fenghuay@nvidia.com, peternewman@google.com, zide.chen@intel.com, dapeng1.mi@linux.intel.com, ben.horgan@arm.com, yu.c.chen@intel.com, jason.zeng@intel.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v3 05/10] selftests/resctrl: Support multiple events associated with iMC Date: Fri, 13 Mar 2026 13:32:32 -0700 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The resctrl selftests discover needed parameters to perf_event_open() via sysfs. The PMU associated with every memory controller (iMC) is discovered via the /sys/bus/event_source/devices/uncore_imc_N/type file while the read memory bandwidth event type and umask is discovered via /sys/bus/event_source/devices/uncore_imc_N/events/cas_count_read. Newer systems may have multiple events that expose read memory bandwidth. Running a recent kernel that includes commit 6a8a48644c4b ("perf/x86/intel/uncore: Add per-scheduler IMC CAS coun= t events") on these systems expose the multiple events. For example, /sys/bus/event_source/devices/uncore_imc_N/events/cas_count_read_sch0 /sys/bus/event_source/devices/uncore_imc_N/events/cas_count_read_sch1 Support parsing of iMC PMU properties when the PMU may have multiple events to measure read memory bandwidth. The PMU only needs to be discovered once. Split the parsing of event details from actual PMU discovery in order to loop over all events associated with the PMU. Match all events with the cas_count_read prefix instead of requiring there to be one file with that name. Make the parsing code more robust. With strings passed around to create needed paths, use snprintf() instead of sprintf() to ensure there is always enough space to create the path while using the standard PATH_MAX for path lengths. Ensure there is enough room in imc_counters_config[] before attempting to add an entry. Signed-off-by: Reinette Chatre Tested-by: Chen Yu Reviewed-by: Zide Chen Reviewed-by: Ilpo J=C3=A4rvinen --- Changes since v1: - Add Zide Chen's RB tag. Changes since v2: - Update changelog to note merged perf change that supports this change. - Use PATH_MAX instead of magic number for path lengths. (Ilpo) - Rename "org_count" -> "orig_count". (Ilpo) - Rework flow surrounding fscanf() used in both parse_imc_read_bw_events() and read_from_imc_dir(). (Ilpo) - Handle error first to reduce indentation. (Ilpo) - Add Chen Yu's tag. --- tools/testing/selftests/resctrl/resctrl_val.c | 118 ++++++++++++++---- 1 file changed, 93 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index 6d766347e3fc..f20d2194c35f 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -11,10 +11,10 @@ #include "resctrl.h" =20 #define UNCORE_IMC "uncore_imc" -#define READ_FILE_NAME "events/cas_count_read" +#define READ_FILE_NAME "cas_count_read" #define DYN_PMU_PATH "/sys/bus/event_source/devices" #define SCALE 0.00006103515625 -#define MAX_IMCS 20 +#define MAX_IMCS 40 #define MAX_TOKENS 5 =20 #define CON_MBM_LOCAL_BYTES_PATH \ @@ -109,46 +109,114 @@ static int open_perf_read_event(int i, int cpu_no) return 0; } =20 -/* Get type and config of an iMC counter's read event. */ -static int read_from_imc_dir(char *imc_dir, unsigned int *count) +static int parse_imc_read_bw_events(char *imc_dir, unsigned int type, + unsigned int *count) { - char cas_count_cfg[1024], imc_counter_cfg[1024], imc_counter_type[1024]; + char imc_events_dir[PATH_MAX], imc_counter_cfg[PATH_MAX]; + unsigned int orig_count =3D *count; + char cas_count_cfg[1024]; + struct dirent *ep; + int path_len; + int ret =3D -1; + int num_cfg; FILE *fp; + DIR *dp; =20 - /* Get type of iMC counter */ - sprintf(imc_counter_type, "%s%s", imc_dir, "type"); - fp =3D fopen(imc_counter_type, "r"); - if (!fp) { - ksft_perror("Failed to open iMC counter type file"); + path_len =3D snprintf(imc_events_dir, sizeof(imc_events_dir), "%sevents", + imc_dir); + if (path_len >=3D sizeof(imc_events_dir)) { + ksft_print_msg("Unable to create path to %sevents\n", imc_dir); + return -1; + } =20 + dp =3D opendir(imc_events_dir); + if (!dp) { + ksft_perror("Unable to open PMU events directory"); return -1; } - if (fscanf(fp, "%u", &imc_counters_config[*count].type) <=3D 0) { - ksft_perror("Could not get iMC type"); + + while ((ep =3D readdir(dp))) { + /* + * Parse all event files with READ_FILE_NAME prefix that + * contain the event number and umask. Skip files containing + * "." that contain unused properties of event. + */ + if (!strstr(ep->d_name, READ_FILE_NAME) || + strchr(ep->d_name, '.')) + continue; + + path_len =3D snprintf(imc_counter_cfg, sizeof(imc_counter_cfg), + "%s/%s", imc_events_dir, ep->d_name); + if (path_len >=3D sizeof(imc_counter_cfg)) { + ksft_print_msg("Unable to create path to %s/%s\n", + imc_events_dir, ep->d_name); + goto out_close; + } + fp =3D fopen(imc_counter_cfg, "r"); + if (!fp) { + ksft_perror("Failed to open iMC config file"); + goto out_close; + } + num_cfg =3D fscanf(fp, "%1023s", cas_count_cfg); fclose(fp); + if (num_cfg <=3D 0) { + ksft_perror("Could not get iMC cas count read"); + goto out_close; + } + if (*count >=3D MAX_IMCS) { + ksft_print_msg("Maximum iMC count exceeded\n"); + goto out_close; + } =20 - return -1; + imc_counters_config[*count].type =3D type; + get_read_event_and_umask(cas_count_cfg, *count); + /* Do not fail after incrementing *count. */ + *count +=3D 1; } - fclose(fp); + if (*count =3D=3D orig_count) { + ksft_print_msg("Unable to find events in %s\n", imc_events_dir); + goto out_close; + } + ret =3D 0; +out_close: + closedir(dp); + return ret; +} =20 - /* Get read config */ - sprintf(imc_counter_cfg, "%s%s", imc_dir, READ_FILE_NAME); - fp =3D fopen(imc_counter_cfg, "r"); - if (!fp) { - ksft_perror("Failed to open iMC config file"); +/* Get type and config of an iMC counter's read event. */ +static int read_from_imc_dir(char *imc_dir, unsigned int *count) +{ + char imc_counter_type[PATH_MAX]; + unsigned int type; + int path_len; + FILE *fp; + int ret; =20 + /* Get type of iMC counter */ + path_len =3D snprintf(imc_counter_type, sizeof(imc_counter_type), + "%s%s", imc_dir, "type"); + if (path_len >=3D sizeof(imc_counter_type)) { + ksft_print_msg("Unable to create path to %s%s\n", + imc_dir, "type"); return -1; } - if (fscanf(fp, "%1023s", cas_count_cfg) <=3D 0) { - ksft_perror("Could not get iMC cas count read"); - fclose(fp); + fp =3D fopen(imc_counter_type, "r"); + if (!fp) { + ksft_perror("Failed to open iMC counter type file"); =20 return -1; } + ret =3D fscanf(fp, "%u", &type); fclose(fp); - - get_read_event_and_umask(cas_count_cfg, *count); - *count +=3D 1; + if (ret <=3D 0) { + ksft_perror("Could not get iMC type"); + return -1; + } + ret =3D parse_imc_read_bw_events(imc_dir, type, count); + if (ret) { + ksft_print_msg("Unable to parse bandwidth event and umask\n"); + return ret; + } =20 return 0; } --=20 2.50.1 From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 43AA3377ECF; Fri, 13 Mar 2026 20:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433982; cv=none; b=S/G/v9AqMPGCSGIdIXTcSyfBQXcRO/bN7lIC0hZM7y+/Yc2vICXe/N6on/aBhHTvAFrzVfF1ziRPeBCxoS0oSD7KHs8wG/qbKZcNo9H79cbs4ZVnq/OhnFynDUQV/Egwrd45KR7c4uRgvAOL6Ra9wgW401+DFuWiYj9ka3YkuC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433982; c=relaxed/simple; bh=8KixJVU3eUU6QMa/RZIfK9ZWO4UtHzZLFNwGdwVoYV8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DZh5BNh4AaFh5fQeVOwzRorqYo0fzq7Bj+eOwDYtgSZ6Gc/bmkDPdUqhxT7fEmLLds/p59aSNtCx4EeT1yNGKvkx/cSye5L4KAAFqRn8vKjhvV66lmyCVT9nzIN0FnNkhxOJ2qTOahmdKYEMH8DhDFDzR/1eKNs6t9Vv0ZLRd5I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VCIpGTUf; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VCIpGTUf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773433980; x=1804969980; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8KixJVU3eUU6QMa/RZIfK9ZWO4UtHzZLFNwGdwVoYV8=; b=VCIpGTUf5kYqpLzDhCndXRSnurdPUcPin5lXrqy4kKuF370VnDjMfNyz BaEKS8ovDXWl7x9iLr7CXzJFZEFGmT8od7Hc2h1Rj82MZ07eLXVYb+tze XWTqGdaJ+OfvVfawyI70dw7wC9dVcEXNUaReayeaHhNu/iECPr4PhYPym PL7TYv6otSVbjUo8jq7dl+f9ii7cimimkisxCqs7rce8qvxS/6zl3MRyF zeHYo0y8mOYsIJhM4nSwnrw/CWBAw0NXLxL3+6P8ZacRcNRsQkh3nZk7h 7HW3qoTBnfCxQempBmwIt23U8FYoid8w7n1Kk+5SwgDd3+x3KFZ8PCY9D g==; X-CSE-ConnectionGUID: BWNSsaoaQKWQ2rW3yevjhg== X-CSE-MsgGUID: 8FD5acJKSzuQ24iq1LQT6w== X-IronPort-AV: E=McAfee;i="6800,10657,11728"; a="74519284" X-IronPort-AV: E=Sophos;i="6.23,118,1770624000"; d="scan'208";a="74519284" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:54 -0700 X-CSE-ConnectionGUID: DanAruqSQP+ISdUZ6bT4zA== X-CSE-MsgGUID: vCrr5D40QNiqUWSgeLkDPA== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:54 -0700 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: fenghuay@nvidia.com, peternewman@google.com, zide.chen@intel.com, dapeng1.mi@linux.intel.com, ben.horgan@arm.com, yu.c.chen@intel.com, jason.zeng@intel.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v3 06/10] selftests/resctrl: Increase size of buffer used in MBM and MBA tests Date: Fri, 13 Mar 2026 13:32:33 -0700 Message-ID: <32e610855f87010cd37ccc18c5eb23a1117fbb41.1773432891.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Errata for Sierra Forest [1] (SRF42) and Granite Rapids [2] (GNR12) describe the problem that MBM on Intel RDT may overcount memory bandwidth measurements. The resctrl tests compare memory bandwidth reported by iMC PMU to that reported by MBM causing the tests to fail on these systems depending on the settings of the platform related to the errata. Since the resctrl tests need to run under various conditions it is not possible to ensure system settings are such that MBM will not overcount. It has been observed that the overcounting can be controlled via the buffer size used in the MBM and MBA tests that rely on comparisons between iMC PMU and MBM measurements. Running the MBM test on affected platforms with different buffer sizes it can be observed that the difference between iMC PMU and MBM counts reduce as the buffer size increases. After increasing the buffer size to more than 4X the differences between iMC PMU and MBM become insignificant. Increase the buffer size used in MBM and MBA tests to 4X L3 size to reduce possibility of tests failing due to difference in counts reported by iMC PMU and MBM. Signed-off-by: Reinette Chatre Tested-by: Chen Yu Link: https://edc.intel.com/content/www/us/en/design/products-and-solutions= /processors-and-chipsets/sierra-forest/xeon-6700-series-processor-with-e-co= res-specification-update/errata-details/ # [1] Link: https://edc.intel.com/content/www/us/en/design/products-and-solutions= /processors-and-chipsets/birch-stream/xeon-6900-6700-6500-series-processors= -with-p-cores-specification-update/011US/errata-details/ # [2] Reviewed-by: Ilpo J=C3=A4rvinen --- Changes since v2: - Add Chen Yu's tag. --- tools/testing/selftests/resctrl/fill_buf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/sel= ftests/resctrl/fill_buf.c index 19a01a52dc1a..b9fa7968cd6e 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -139,6 +139,6 @@ ssize_t get_fill_buf_size(int cpu_no, const char *cache= _type) if (ret) return ret; =20 - return cache_total_size * 2 > MINIMUM_SPAN ? - cache_total_size * 2 : MINIMUM_SPAN; + return cache_total_size * 4 > MINIMUM_SPAN ? + cache_total_size * 4 : MINIMUM_SPAN; } --=20 2.50.1 From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 DF32E3793BC; Fri, 13 Mar 2026 20:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433983; cv=none; b=gWtdEWXfnUrRhEHeY/YnJexpFem1FotdFjF/eeq9lsgL+kcv0gqdnRguf2bYOs/exKEivqbqmVrx31/SBgc6Au+c6slBtEAWA+VGjEibs/x0bU6ArrrraO2WZJFE5BqdazW2Iut/nqmVd0DH7anE+4gM/SizlREcW5soqLAP7nE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433983; c=relaxed/simple; bh=qIe7VhOdoVlLCUxoNR7SC51N22nu+eMyI+A9ZvoW/0k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HrWPgmwCfMnBLy9pnEGTNstFH4l2b1dUDdFtINZc9CyhRrHgCAO7LTUABrxC7wVPcWyMbgKo6aRLREwUs3ALzm4w2McKNi6AYhGfdfkxNZpf6tM39SZkRj1w0lO/KsVx6aWmG13v5npt41pRDKXVJODe8ZdgJ16OuR7VXO1bnyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZuGGKNcN; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZuGGKNcN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773433981; x=1804969981; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qIe7VhOdoVlLCUxoNR7SC51N22nu+eMyI+A9ZvoW/0k=; b=ZuGGKNcNievUPm0c/4qjqrGgqyWbAviWwmI8WASeeBwOUgcEMVD490vG kGobYfWVe+6BRbgURTMjUFbxtz1q5co1KHr4bnaoBZePhCCI+1Em7Lg9O LOU6H+l8FGqPQikhmr9wCzZiY58G9gKmO9RiVKfA1d1u1y3qz835SMl08 ZcaSrbBFEMuSgvTfEpnZTWBr5L88prT7S/cjB1+mXkVngsKDbTIknTe1n 49Dll3bWc67g20mnc8h5hWIfwbte+rnd39mwBKshTm0QwiUVihwWLo3+2 8fz+Pz+ZgfMHU2DyK+XRQx4votZ1XvJxg0TYs2KGCnwwle3cZTVItqM4k w==; X-CSE-ConnectionGUID: G/yhqwv2TDa4ZcpMbNwk/Q== X-CSE-MsgGUID: HrX68culT8y+2aRTHw3jrQ== X-IronPort-AV: E=McAfee;i="6800,10657,11728"; a="74519292" X-IronPort-AV: E=Sophos;i="6.23,118,1770624000"; d="scan'208";a="74519292" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:54 -0700 X-CSE-ConnectionGUID: JGXTisTRQK+cpIaakGYmbg== X-CSE-MsgGUID: huGS3OOkSLG5nTdTACocOw== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:54 -0700 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: fenghuay@nvidia.com, peternewman@google.com, zide.chen@intel.com, dapeng1.mi@linux.intel.com, ben.horgan@arm.com, yu.c.chen@intel.com, jason.zeng@intel.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v3 07/10] selftests/resctrl: Raise threshold at which MBM and PMU values are compared Date: Fri, 13 Mar 2026 13:32:34 -0700 Message-ID: <1bdca244a899a605c1ddd701a09d6a9d0c242856.1773432891.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" commit 501cfdba0a40 ("selftests/resctrl: Do not compare performance counters and resctrl at low bandwidth") introduced a threshold under which memory bandwidth values from MBM and performance counters are not compared. This is needed because MBM and the PMUs do not have an identical view of memory bandwidth since PMUs can count all memory traffic while MBM does not count "overhead" (for example RAS) traffic that cannot be attributed to an RMID. As a ratio this difference in view of memory bandwidth is pronounced at low memory bandwidths. The 750MiB threshold was chosen arbitrarily after comparisons on different platforms. Exposed to more platforms after introduction this threshold has proven to be inadequate. Having accurate comparison between performance counters and MBM requires careful management of system load as well as control of features that introduce extra memory traffic, for example, patrol scrub. This is not appropriate for the resctrl selftests that are intended to run on a variety of systems with various configurations. Increase the memory bandwidth threshold under which no comparison is made between performance counters and MBM. Add additional leniency by increasing the percentage of difference that will be tolerated between these counts. There is no impact to the validity of the resctrl selftests results as a measure of resctrl subsystem health. Signed-off-by: Reinette Chatre Tested-by: Chen Yu Reviewed-by: Ilpo J=C3=A4rvinen --- Changes since v2: - Add Chen Yu's tag. --- tools/testing/selftests/resctrl/mba_test.c | 2 +- tools/testing/selftests/resctrl/mbm_test.c | 2 +- tools/testing/selftests/resctrl/resctrl.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/sel= ftests/resctrl/mba_test.c index cd4c715b7ffd..39cee9898359 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -12,7 +12,7 @@ =20 #define RESULT_FILE_NAME "result_mba" #define NUM_OF_RUNS 5 -#define MAX_DIFF_PERCENT 8 +#define MAX_DIFF_PERCENT 15 #define ALLOCATION_MAX 100 #define ALLOCATION_MIN 10 #define ALLOCATION_STEP 10 diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/sel= ftests/resctrl/mbm_test.c index 58201f844740..6dbbc3b76003 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -11,7 +11,7 @@ #include "resctrl.h" =20 #define RESULT_FILE_NAME "result_mbm" -#define MAX_DIFF_PERCENT 8 +#define MAX_DIFF_PERCENT 15 #define NUM_OF_RUNS 5 =20 static int diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index 7f2ab28be857..3bad2d80c09b 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -55,7 +55,7 @@ * and MBM respectively, for instance generating "overhead" traffic which * is not counted against any specific RMID. */ -#define THROTTLE_THRESHOLD 750 +#define THROTTLE_THRESHOLD 2500 =20 /* * fill_buf_param: "fill_buf" benchmark parameters --=20 2.50.1 From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 87295370D6A; Fri, 13 Mar 2026 20:33:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433983; cv=none; b=cjv6dR+B4J72lVt8mGx1krzJVGAoDGxxsCF0L0K+KdVDQE575H7mU9Wm/60+xGU+mxxzMfvPtfg2p2Ib+lV1DITm9CqhuujAmlO4wT7RZH6w+/EIIoO9LRs9UYt2Uq1v0Mc5LL5VccgbTEWKcatYsohXG3oUxKEWkPJFmPnlhHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433983; c=relaxed/simple; bh=Vnn+i8nVsH/EVmGtp2eUU58NjAstKrKZ6qtPgrztQYI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dL4zJNP/5EEVUGaFa9SIdMmHoSzXa/3IqFIp+1J2tFv7FHDP51GnVRrNpxAwOhpnEHWPtEEvEEZhkDaiN4JK6/uKYyumN+Y/oebXcYylIxdpBgFvRs7nRACw9kPNAre1vZ2reqcYdB0HePt1wk5+FXhDcw2RVFcqAs8CMg0tG60= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=B/i+jhKM; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="B/i+jhKM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773433981; x=1804969981; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Vnn+i8nVsH/EVmGtp2eUU58NjAstKrKZ6qtPgrztQYI=; b=B/i+jhKMEKyGC+rfwcMM8aJLmJx5ygG27ldB1gB2HPfbhMIhcB7yWSXx 7SmBkuYd+ywzYbjiXwkXXHVfGv/hVH8EkCDmpwdch/gNQwX0G5O3deeUl t7UZj78XddGf+/4i+vYS8aszgDkeSRRH13gNOs0magB2mFz2lWlRlRITu 4CpJeCHp3N31/P/HgnNOic+gyh8IxMvUd/HLTvmJ3LJhXgp+V4+8DP7rY g8ifBt6pezAXJ5/8wJ7hV+4V2AOPg/eR5nqzer3gHBYNoiirFayuoBdNV sm+qwSekh7jLpR+PaJRuGLoTk2JyDqnvXxQz1GIT8DTpyCSEIt+KylIr1 g==; X-CSE-ConnectionGUID: Nr3v13GCQWGpBX4dCfGccg== X-CSE-MsgGUID: weiPP19RQ+GmFYjthsAPjg== X-IronPort-AV: E=McAfee;i="6800,10657,11728"; a="74519302" X-IronPort-AV: E=Sophos;i="6.23,118,1770624000"; d="scan'208";a="74519302" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:55 -0700 X-CSE-ConnectionGUID: YpLeoj5HTA6sEBqI4AFP6w== X-CSE-MsgGUID: 5JbJIoMsRHaXlRSC2H29ow== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:54 -0700 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: fenghuay@nvidia.com, peternewman@google.com, zide.chen@intel.com, dapeng1.mi@linux.intel.com, ben.horgan@arm.com, yu.c.chen@intel.com, jason.zeng@intel.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v3 08/10] selftests/resctrl: Remove requirement on cache miss rate Date: Fri, 13 Mar 2026 13:32:35 -0700 Message-ID: <1fc79420f76d585231252e59d4fcf19b3e704ee3.1773432891.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As the CAT test reads the same buffer into different sized cache portions it compares the number of cache misses against an expected percentage based on the size of the cache portion. Systems and test conditions vary. The CAT test is a test of resctrl subsystem health and not a test of the hardware architecture so it is not required to place requirements on the size of the difference in cache misses, just that the number of cache misses when reading a buffer increase as the cache portion used for the buffer decreases. Remove additional constraint on how big the difference between cache misses should be as the cache portion size changes. Only test that the cache misses increase as the cache portion size decreases. This remains a good sanity check of resctrl subsystem health while reducing impact of hardware architectural differences and the various conditions under which the test may run. Increase the size difference between cache portions to additionally avoid any consequences resulting from smaller increments. Signed-off-by: Reinette Chatre Tested-by: Chen Yu Reviewed-by: Ilpo J=C3=A4rvinen --- Changes since v2: - Add Chen Yu's tag. --- tools/testing/selftests/resctrl/cat_test.c | 33 ++++------------------ 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/sel= ftests/resctrl/cat_test.c index f00b622c1460..8bc47f06679a 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -14,42 +14,20 @@ #define RESULT_FILE_NAME "result_cat" #define NUM_OF_RUNS 5 =20 -/* - * Minimum difference in LLC misses between a test with n+1 bits CBM to the - * test with n bits is MIN_DIFF_PERCENT_PER_BIT * (n - 1). With e.g. 5 vs 4 - * bits in the CBM mask, the minimum difference must be at least - * MIN_DIFF_PERCENT_PER_BIT * (4 - 1) =3D 3 percent. - * - * The relationship between number of used CBM bits and difference in LLC - * misses is not expected to be linear. With a small number of bits, the - * margin is smaller than with larger number of bits. For selftest purpose= s, - * however, linear approach is enough because ultimately only pass/fail - * decision has to be made and distinction between strong and stronger - * signal is irrelevant. - */ -#define MIN_DIFF_PERCENT_PER_BIT 1UL - static int show_results_info(__u64 sum_llc_val, int no_of_bits, unsigned long cache_span, - unsigned long min_diff_percent, unsigned long num_of_runs, bool platform, __s64 *prev_avg_llc_val) { __u64 avg_llc_val =3D 0; - float avg_diff; int ret =3D 0; =20 avg_llc_val =3D sum_llc_val / num_of_runs; if (*prev_avg_llc_val) { - float delta =3D (__s64)(avg_llc_val - *prev_avg_llc_val); - - avg_diff =3D delta / *prev_avg_llc_val; - ret =3D platform && (avg_diff * 100) < (float)min_diff_percent; - - ksft_print_msg("%s Check cache miss rate changed more than %.1f%%\n", - ret ? "Fail:" : "Pass:", (float)min_diff_percent); + ret =3D platform && (avg_llc_val < *prev_avg_llc_val); =20 - ksft_print_msg("Percent diff=3D%.1f\n", avg_diff * 100); + ksft_print_msg("%s Check cache miss rate increased\n", + ret ? "Fail:" : "Pass:"); } *prev_avg_llc_val =3D avg_llc_val; =20 @@ -58,10 +36,10 @@ static int show_results_info(__u64 sum_llc_val, int no_= of_bits, return ret; } =20 -/* Remove the highest bit from CBM */ +/* Remove the highest bits from CBM */ static unsigned long next_mask(unsigned long current_mask) { - return current_mask & (current_mask >> 1); + return current_mask & (current_mask >> 2); } =20 static int check_results(struct resctrl_val_param *param, const char *cach= e_type, @@ -112,7 +90,6 @@ static int check_results(struct resctrl_val_param *param= , const char *cache_type =20 ret =3D show_results_info(sum_llc_perf_miss, bits, alloc_size / 64, - MIN_DIFF_PERCENT_PER_BIT * (bits - 1), runs, get_vendor() =3D=3D ARCH_INTEL, &prev_avg_llc_val); if (ret) --=20 2.50.1 From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 DF9AA37C936; Fri, 13 Mar 2026 20:33:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433984; cv=none; b=ZjvOHKyhC/V/Afri77fxVc8sg9phJAG9sFejwAMuN73FXi6CnOZPOzqc5mKmmt1thlnWiyF3fkRdNfhs9R4D9jXjT+tmvhRwWrPI5PI5Q/7DjqlwSr2h73mmz8T4FonDOyag4G+fHV3LaoFuuhMR5CrFPQGUc7gXRzwNm89h+rA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433984; c=relaxed/simple; bh=5icHJepnYg/ZGdiimsTcVy+sqKzRjjaidfvA4uhUzMI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BQnOIuqTNaMprGblaEDlAI0WMtIVVRzojYCR9kvj2J/ND6TLYJPbPW0pgDEFPPAhIiEejmqgFZvnSUXuZi0r5A8hSA8SQflZzlRulPy46VNXRGunsjXHqZdkDgYLzx0Lo5yyo1jMuA3dv+e0fwyRvY3pHDrDmgN3XxPNY4b6fWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kIzHiedx; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kIzHiedx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773433983; x=1804969983; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5icHJepnYg/ZGdiimsTcVy+sqKzRjjaidfvA4uhUzMI=; b=kIzHiedxHesapEKu4smrTc7HZqUc5u5Hnb0+62IhckttxSZ8gjIFJjeu +8Mi+GDmZqafC5qdztNxR2h94swJYjT6nwwu3Xb989RJefVBhzvApl/98 K7bKSFb0gdYUdRGyDKvCFQlGHEFnlo6qRpGYZZ8a/2LV78ACPHrOayXr5 nlSJ4gxGahy8UaGLDhDTv++Mr3p4WqPWaNlHhVp02bwYUW/g/son3/1w0 mIlWDBvLqAct21sk2+NtVzofTDFdtOSALTTaqDLYKMF3hZqZn0pGvcLdP TVJwh0JeOoW+n/h6dBOVRSqGQAL+O485Tm4iPo0pxk7JlerqH4yqxV6F0 A==; X-CSE-ConnectionGUID: Kdf7nSCNRoitxQHRwi7zdA== X-CSE-MsgGUID: pqrXlX+yREmmkYLdi0h/vA== X-IronPort-AV: E=McAfee;i="6800,10657,11728"; a="74519312" X-IronPort-AV: E=Sophos;i="6.23,118,1770624000"; d="scan'208";a="74519312" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:55 -0700 X-CSE-ConnectionGUID: VK2yLEEkRh2JBJu+FHpNPg== X-CSE-MsgGUID: DF8r4FVUT4iO25c6MgY6zg== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:55 -0700 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: fenghuay@nvidia.com, peternewman@google.com, zide.chen@intel.com, dapeng1.mi@linux.intel.com, ben.horgan@arm.com, yu.c.chen@intel.com, jason.zeng@intel.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v3 09/10] selftests/resctrl: Simplify perf usage in CAT test Date: Fri, 13 Mar 2026 13:32:36 -0700 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The CAT test relies on the PERF_COUNT_HW_CACHE_MISSES event to determine if modifying a cache portion size is successful. This event is configured to report the data as part of an event group, but no other events are added to the group. Remove the unnecessary PERF_FORMAT_GROUP format setting. This eliminates the need for struct perf_event_read and results in read() of the associated file descriptor to return just one value associated with the PERF_COUNT_HW_CACHE_MISSES event of interest. Signed-off-by: Reinette Chatre Tested-by: Chen Yu Reviewed-by: Ilpo J=C3=A4rvinen --- Changes since v2: - Add Chen Yu's tag. --- tools/testing/selftests/resctrl/cache.c | 17 +++++------------ tools/testing/selftests/resctrl/cat_test.c | 4 +--- tools/testing/selftests/resctrl/resctrl.h | 11 +---------- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selfte= sts/resctrl/cache.c index bef71b6feacc..df9bea584a2d 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -10,7 +10,6 @@ void perf_event_attr_initialize(struct perf_event_attr *p= ea, __u64 config) memset(pea, 0, sizeof(*pea)); pea->type =3D PERF_TYPE_HARDWARE; pea->size =3D sizeof(*pea); - pea->read_format =3D PERF_FORMAT_GROUP; pea->exclude_kernel =3D 1; pea->exclude_hv =3D 1; pea->exclude_idle =3D 1; @@ -37,19 +36,13 @@ int perf_event_reset_enable(int pe_fd) return 0; } =20 -void perf_event_initialize_read_format(struct perf_event_read *pe_read) -{ - memset(pe_read, 0, sizeof(*pe_read)); - pe_read->nr =3D 1; -} - int perf_open(struct perf_event_attr *pea, pid_t pid, int cpu_no) { int pe_fd; =20 pe_fd =3D perf_event_open(pea, pid, cpu_no, -1, PERF_FLAG_FD_CLOEXEC); if (pe_fd =3D=3D -1) { - ksft_perror("Error opening leader"); + ksft_perror("Unable to set up performance monitoring"); return -1; } =20 @@ -132,9 +125,9 @@ static int print_results_cache(const char *filename, pi= d_t bm_pid, __u64 llc_val * * Return: =3D0 on success. <0 on failure. */ -int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, - const char *filename, pid_t bm_pid) +int perf_event_measure(int pe_fd, const char *filename, pid_t bm_pid) { + __u64 value; int ret; =20 /* Stop counters after one span to get miss rate */ @@ -142,13 +135,13 @@ int perf_event_measure(int pe_fd, struct perf_event_r= ead *pe_read, if (ret < 0) return ret; =20 - ret =3D read(pe_fd, pe_read, sizeof(*pe_read)); + ret =3D read(pe_fd, &value, sizeof(value)); if (ret =3D=3D -1) { ksft_perror("Could not get perf value"); return -1; } =20 - return print_results_cache(filename, bm_pid, pe_read->values[0].value); + return print_results_cache(filename, bm_pid, value); } =20 /* diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/sel= ftests/resctrl/cat_test.c index 8bc47f06679a..6aac03147d41 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -135,7 +135,6 @@ static int cat_test(const struct resctrl_test *test, struct resctrl_val_param *param, size_t span, unsigned long current_mask) { - struct perf_event_read pe_read; struct perf_event_attr pea; cpu_set_t old_affinity; unsigned char *buf; @@ -159,7 +158,6 @@ static int cat_test(const struct resctrl_test *test, goto reset_affinity; =20 perf_event_attr_initialize(&pea, PERF_COUNT_HW_CACHE_MISSES); - perf_event_initialize_read_format(&pe_read); pe_fd =3D perf_open(&pea, bm_pid, uparams->cpu); if (pe_fd < 0) { ret =3D -1; @@ -192,7 +190,7 @@ static int cat_test(const struct resctrl_test *test, =20 fill_cache_read(buf, span, true); =20 - ret =3D perf_event_measure(pe_fd, &pe_read, param->filename, bm_pid); + ret =3D perf_event_measure(pe_fd, param->filename, bm_pid); if (ret) goto free_buf; } diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index 3bad2d80c09b..175101022bf3 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -148,13 +148,6 @@ struct resctrl_val_param { struct fill_buf_param *fill_buf; }; =20 -struct perf_event_read { - __u64 nr; /* The number of events */ - struct { - __u64 value; /* The value of the event */ - } values[2]; -}; - /* * Memory location that consumes values compiler must not optimize away. * Volatile ensures writes to this location cannot be optimized away by @@ -210,11 +203,9 @@ unsigned int count_bits(unsigned long n); int snc_kernel_support(void); =20 void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config); -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, pid_t bm_pid); +int perf_event_measure(int pe_fd, const char *filename, pid_t bm_pid); int measure_llc_resctrl(const char *filename, pid_t bm_pid); int minimize_l2_occupancy(const struct resctrl_test *test, const struct user_params *uparams, --=20 2.50.1 From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 A02D5374E57; Fri, 13 Mar 2026 20:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433986; cv=none; b=QKUkjFHx6fLUAg7c3LQ6npa+bBc8FB48c4tv+qVzn0RamGTiLuJ977wPBff1j1rtSgLrf9meFDifkzR0971aqDZfkAeqQVrz6oDH5qGw66F3krmpeNpcW3Y6zTGILnv4v2Yhwq+yHmP+wJLIlUMC058CklJWeHaIJek7X6TLmos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773433986; c=relaxed/simple; bh=2D1jGTPCH4a1Z7vhqzVpwmCENBPnUn+PfbsVlqLp23c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LPdXIZil4tbgoEy9rtycY1xSrsBndkvuj5j6u397FwmRsNbUX73iFZls4SNDJ0JYqvPI7jK9Ct/7abjhZI08kiTu+dqpnH/koT1GgmoCVYj7Ss6DH62RpgWJRtS5LbXOllfuy/lpcDRx91kKSLVaQZigyQVTED0LHvGBdJaRaeY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bLYvw7Cv; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bLYvw7Cv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773433983; x=1804969983; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2D1jGTPCH4a1Z7vhqzVpwmCENBPnUn+PfbsVlqLp23c=; b=bLYvw7CvI+ej38zd44wheHqskYT+s6sRviLspVeFIQBvni6FUxQEovpG jKpgjEV1Cydz9w4aPhtverMBe2TJLB5Kg/NtMDaVjnV/4n9HbuVkov7at Kcvd+m/bc6NvbddQ5170cb9AEDXZRb6qM+78CoIEouS1TVSWFfzZAaLjc AvXFNannW+uhbbf2iffyzHU+VZomvu6Lu1WFxPDxd6jo1z8ud0FVzo/JR Y447ikWoMxW8Uj/kjnF/uYllBDOtrcE5AZ/WEFJcHizqvwuMPXeeAQpsh fdrbiJNgFCbQrbp9Fo5PGW9dsb3OomnrDD7dbBd5QaRU3w0yQE+gepoQf g==; X-CSE-ConnectionGUID: 9sHNWcFlSmqrX6lz+woghA== X-CSE-MsgGUID: ttirlQdUTQ+o94WCACx9kQ== X-IronPort-AV: E=McAfee;i="6800,10657,11728"; a="74519319" X-IronPort-AV: E=Sophos;i="6.23,118,1770624000"; d="scan'208";a="74519319" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:56 -0700 X-CSE-ConnectionGUID: YQ8S024OTbeSSaBLLMi4Gw== X-CSE-MsgGUID: Omyv3AS3QJKPHtV9ZbPDYg== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 13:32:55 -0700 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: fenghuay@nvidia.com, peternewman@google.com, zide.chen@intel.com, dapeng1.mi@linux.intel.com, ben.horgan@arm.com, yu.c.chen@intel.com, jason.zeng@intel.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v3 10/10] selftests/resctrl: Reduce L2 impact on CAT test Date: Fri, 13 Mar 2026 13:32:37 -0700 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The L3 CAT test loads a buffer into cache that is proportional to the L3 size allocated for the workload and measures cache misses when accessing the buffer as a test of L3 occupancy. When loading the buffer it can be assumed that a portion of the buffer will be loaded into the L2 cache and depending on cache design may not be present in L3. It is thus possible for data to not be in L3 but also not trigger an L3 cache miss when accessed. Reduce impact of L2 on the L3 CAT test by, if L2 allocation is supported, minimizing the portion of L2 that the workload can allocate into. This encourages most of buffer to be loaded into L3 and support better comparison between buffer size, cache portion, and cache misses when accessing the buffer. Signed-off-by: Reinette Chatre Tested-by: Chen Yu Reviewed-by: Ilpo J=C3=A4rvinen --- Changes since v2: - Add Chen Yu's tag. --- tools/testing/selftests/resctrl/cat_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/sel= ftests/resctrl/cat_test.c index 6aac03147d41..371a2f26dc47 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -157,6 +157,10 @@ static int cat_test(const struct resctrl_test *test, if (ret) goto reset_affinity; =20 + ret =3D minimize_l2_occupancy(test, uparams, param); + if (ret) + goto reset_affinity; + perf_event_attr_initialize(&pea, PERF_COUNT_HW_CACHE_MISSES); pe_fd =3D perf_open(&pea, bm_pid, uparams->cpu); if (pe_fd < 0) { --=20 2.50.1