From nobody Tue Apr 7 09:05:10 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 11E4023EABA; Sat, 4 Apr 2026 01:56:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267807; cv=none; b=jcEl0E68oQ72URg5rO5JzqcwWzPa7kc5CqdPOsapS2X1QEoZOZze3otd3P7Inc8NRUJENJCERVr3UeU2E6tYDUoOtbon/d3ds2fWI30V/coOFyOcEPdNqQMxbVwSp+NBLyf7BJVs5JnW1nvg3CbDvwTcZMbD7cu/6EgG++bmz2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267807; c=relaxed/simple; bh=fK5XQeBQzWMAEfkpexHViEcwK3WoZrQhjXaLzGSiMDA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AvZADETKkbEywa8iM6k2f+VT3OupIZ7KQs/Un4SDedaySYkqzqGFHy14pI+Vg24ITXnU1dV+CdjGQBu8Xu1i1UwFbYxAawMQ3Dbt5m+Eun8OSakROUsop3ya5wuWxLhlyOlDoSo5/CHhhu4eCXCXbSiePNoWBuIqvrQjGgi5100= 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=WddOZric; arc=none smtp.client-ip=198.175.65.18 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="WddOZric" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775267805; x=1806803805; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fK5XQeBQzWMAEfkpexHViEcwK3WoZrQhjXaLzGSiMDA=; b=WddOZricsenisGwoAiQ84kP4EOM19GCiRHSGPF0XKFy7NKH59R9uxFhD qkI+FqtmjTHOiHXbdOyX3YiK+nXObfvOseSqMABbTZ/AskRFBt/MxMfPf YpYa6iJ+hK4+n18EzkQrJsfp8fFvmkD5tbABEIYYQeO5JYTeUtOk5tw5u 51kgWWHvZ/n6YPpwa851BlqubrSkbResVYgad3TfLf/If27Cl3bcF5lEz Dqr+KGT9I2IzehH828JYhl1O8BVfwjh4okgdZuSbGCRFMu14kVX+Eo5Ud 4Hq9I/LxF5I/XBgOb69KqYuIP3K/L5T9at6ki7ro8ivT44WtaFDsGocVQ A==; X-CSE-ConnectionGUID: lCXn0jeaRim3C/Rgpm0Z/A== X-CSE-MsgGUID: 6KTVylsaS4OrtXLCRRPjLQ== X-IronPort-AV: E=McAfee;i="6800,10657,11748"; a="76343376" X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="76343376" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:44 -0700 X-CSE-ConnectionGUID: Lxh12dmoT/enq5S79zXJlQ== X-CSE-MsgGUID: fjY+0pJ6Szywgp6MS4Ev2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="224121495" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:16 -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 v4 01/10] selftests/resctrl: Improve accuracy of cache occupancy test Date: Fri, 3 Apr 2026 18:56:00 -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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 Reviewed-by: Ilpo J=C3=A4rvinen Link: https://lore.kernel.org/lkml/aO+7MeSMV29VdbQs@e133380.arm.com/ --- 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. Changes since v3: - Add Ilpo's RB 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.18]) (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 608E72D3A6A; Sat, 4 Apr 2026 01:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267808; cv=none; b=PUq4APq/O6fVvMxN4aUDhogEeuAX/I3XxPFstNsMjleLDa+qL2+4tyVjDK1E8vJpeNr27YIJUe8W75ksJONnwGyY5scl0fDPR2ufCWfLxWsKSWDlS8zE0Ke4ubyniiQ8SsFfgeWEkRpckhmI1vM15BqHjHd/bS7jAFl4QV/DSNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267808; c=relaxed/simple; bh=UbEi4EyzUvCP0cqbMLxC0sNz/D5ML1LcivjHnWxizY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c/1x+CINrLDVLfliqjCOAjQMNTzdM3YTZ09m5QcSJZuGbHbEW9AkJawrMoua5P1TfgYW7qPjzS/QuWiMXvmXNgK8PVcQQBvDzS5lm3WHapEbhZOxiERqVaEWrTjigRf6RIikBj9v2EDehKivlzjWZjMdwqsE6DsvpVHQpsG7KaA= 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=kQ2O0pHN; arc=none smtp.client-ip=198.175.65.18 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="kQ2O0pHN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775267807; x=1806803807; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UbEi4EyzUvCP0cqbMLxC0sNz/D5ML1LcivjHnWxizY0=; b=kQ2O0pHNDhjAVtZfJ/xxOpWiVZ7iQvsKXi5YPVykyY+RsXdiD3a0PMyR R7neGuasj2DI1hkZFGHbrhOnYuzsi6dY3hEB365wpaJNaJ/Tp4o/r5Kdq QBqUcMEF/ga+KsekoQvOeY+agPkM/lrSmP8ik543bVa7dSTPDL0eIyfsO zJ7JLocSbNnnvNPi3l32RO2We5pwjmTtRwci6r1WOxgpLLLD8B+Pjp8kU 6k1HMrthoFhYWyMGbu/62Xo4+s6rktC1grf1evxNDdUrKGmYnTCzD4sgK 2/FZnmCszYauR9RSqN14ZC3Ul8ON89OJBy3vTTN64RPizpG5A3XiLz5YI A==; X-CSE-ConnectionGUID: pM/TBslkQhyUJdPqN7jkkg== X-CSE-MsgGUID: npvFgd6IR5S/AR9wRzfY9Q== X-IronPort-AV: E=McAfee;i="6800,10657,11748"; a="76343388" X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="76343388" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:44 -0700 X-CSE-ConnectionGUID: EDEyMCCJRluNa2L6qU8EVA== X-CSE-MsgGUID: BYD5xNdCSvGkOVUjtwGJZA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="224121499" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:16 -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 v4 02/10] selftests/resctrl: Reduce interference from L2 occupancy during cache occupancy test Date: Fri, 3 Apr 2026 18:56:01 -0700 Message-ID: <00445fa64c251b86b86023f87220ee1ad8561460.1775266384.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 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 Reviewed-by: Ilpo J=C3=A4rvinen Link: https://lore.kernel.org/lkml/aO+7MeSMV29VdbQs@e133380.arm.com/ --- 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. Changes since v3: - Add Ilpo's RB 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.18]) (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 1FB5F2C21F1; Sat, 4 Apr 2026 01:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267809; cv=none; b=fRkQDAP4rlA8Tc6TetpySEX5qYEqARjejo+Fqq6xMzlsmleLAKNUU6HBDBCj5/7MY1yqA0xOqwdsRxluAVBV3GEJeJbn5ROkdixV8/0nMkANgnQOo71F6s7ATqxeiZQDtxmzhfp92RlriciUlQ+3OyxXl9PFhwTL3Na9ynDz2j0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267809; c=relaxed/simple; bh=5Qmoh1Ru8vMO1Nfg8X9L40uIhnik+WL6a07fapKwUMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cvuNPjY+lqc7wCmdnu4nGZQDl4hLQSahLy0D32mPC8sN+qhBHeaEZumReAvQ9PV4+jK3cueuV/MfIQsrMyKbayFfGcuF2IB570VgrJEF14tBcs+GVAvfH+Em6KtsqnHSxTM5fobz1qERKvsE23P1ff+Gc/1Zg4hIE7kAgGyYalk= 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=WWcYi8Yg; arc=none smtp.client-ip=198.175.65.18 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="WWcYi8Yg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775267807; x=1806803807; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5Qmoh1Ru8vMO1Nfg8X9L40uIhnik+WL6a07fapKwUMA=; b=WWcYi8YgE1qLDoPCIj9M9RoE8k+8PfvB7acN2WbKzt6wFbU4L3e9brkJ qTsaRuFMT/pBAKhjLYa1O5jecONIET/NtEIoxntvVrytUV7tbf3ROCJ1l jqZS2KGZfhZ192bVySrsuS/sLVHwI6DiOh6oUBGaB0QyB0WMb91RwDh8b ofkTwIet77OIaI8JWLDa33bQgWZh9L7fe5pMN0kBvsDMxlLdgSqewreeG Dw5z22zm6XtXULf19577IwPEZCnZbd2Ar16u1+QPlLO+5b8qq5NCHEg79 Sb6nUvDqQjDpTXFGfROfLUrF4+/dD5fiSlfuMWEU1ZmoYqkWQU5kNzSN/ Q==; X-CSE-ConnectionGUID: E+6Q2etjSiOVjOlK71qKWA== X-CSE-MsgGUID: YqLghbqESY6EA86cuJzhNg== X-IronPort-AV: E=McAfee;i="6800,10657,11748"; a="76343381" X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="76343381" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:44 -0700 X-CSE-ConnectionGUID: GcyMdMu6S9K1URP1/S6AFA== X-CSE-MsgGUID: Dikir7wlQBqP0Z41ZUEHuw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="224121502" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:17 -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 v4 03/10] selftests/resctrl: Do not store iMC counter value in counter config structure Date: Fri, 3 Apr 2026 18:56:02 -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-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.18]) (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 40F0B2D0614; Sat, 4 Apr 2026 01:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267808; cv=none; b=joqf3wWaojBWaOdPzeyrFQAZ4aBjkn5+/U6ySg50dZiOiE3qIKwccv0tiC+oIw94wt1oAJPar/Xp8s4UU2qYmPxA/f3+moiPo9qDh1ZMGohLCwzG5gL2XH1G9Z81K59F+vGZyc3crcdRA5oi2MB8cPrFY8iKRZZZ1F2YBrUk+d4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267808; c=relaxed/simple; bh=+e0ebtv/vNWs+rImF+Hmwl1LRUjj2AOg7Qf985TDIxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ax6WC1l1TGCJlFgP2+kkrXjhpzlh8K5c5Abub2y3vKYCquFpx8yD0uaA56b8CR8Bl+0TbuTZJRao+30PSBp4YJeFw7qdGHLy+4kp3Q6nmsM99Es2RWnhNao9pO+rR3u5YlLDyp2JcJYE16Jn2aktVwXzmdGzcL+OWl2/r4uuK9E= 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=ULhIqFK4; arc=none smtp.client-ip=198.175.65.18 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="ULhIqFK4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775267807; x=1806803807; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+e0ebtv/vNWs+rImF+Hmwl1LRUjj2AOg7Qf985TDIxU=; b=ULhIqFK4vzlUEZvocD8FkeG4dBtk4kSxvfCRYjylHTARuno9Nhs6iih3 GWrpYmziXmBPbA+SsrQHHFNDKlzjyQbpfQHYydo6SMIvPonGBqAxrzg7w BXJBWFN0L1RWAcoA8oZxSZQrhFyyXGceksL03jS+8kjuiwUQvlAG7Cgpx hwzZwtdT8mlwHryEHy/VcrXEqXLtxqRmPa7wtkDYyovr6HBsaEcpw8zjo tLjTLFo7d7JXuqF5wGM5/OcP+idJMFBX136M8K8QZUhSkZtpa6EpPbWbf OsxBm2meATI8ly/ewYvxNedLx+GHZ6nLx1Wj6scCisPXNNBipZYyKKSRv g==; X-CSE-ConnectionGUID: gMAvRPV9Q2yuJlc3CBEZsw== X-CSE-MsgGUID: E4NvYcaBQ/KklA/zF11anQ== X-IronPort-AV: E=McAfee;i="6800,10657,11748"; a="76343394" X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="76343394" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:44 -0700 X-CSE-ConnectionGUID: RxtRqjTBTvqX6MIq5nwRZA== X-CSE-MsgGUID: 5cUT8QuFRCare4ykTHjyDQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="224121538" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:17 -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 v4 04/10] selftests/resctrl: Prepare for parsing multiple events per iMC Date: Fri, 3 Apr 2026 18:56:03 -0700 Message-ID: <549e026d20af0381349e645c912e6470fce8bd7e.1775266384.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 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. Changes since v3: - Add Ilpo's RB 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.18]) (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 0384A2D9EC4; Sat, 4 Apr 2026 01:56:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267812; cv=none; b=kzsToDKdClBu9n7Za05O4rx0xmFqxFGgzLO1KA/H9Iavzw4DZb6YeaKIuDxA2WuHmkAoJ7DgHqaGUOmSnBAWs+pMxSUSbyWXZANzi5IFfugn4kXQnMH44oI4Xkqd4kP5xWS5ZowYcieHpAYXiU/Xj6sMipVZi+OXNw/q0WJQMyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267812; c=relaxed/simple; bh=+vVQmd16b7e2Ku5qlAzxOKUh9XuxhrBzZ88HMgk9Wlo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sxwncKmA9F3dD7VsKvxCgEbZMsrSWL/nFwc3s4X5wDhQpBzv3BzTIlb+mbRGLtgnUo3Rke5yeVKTlR2mkHul4SrTJKgrgtFOPQ5C5pkvcdFuGpYwZGtpnK7YPAK7B6RoVSUzitwcbtk0egFC0KqO5+lWVzPNpZVexgAM0issInE= 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=NLW3N4yn; arc=none smtp.client-ip=198.175.65.18 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="NLW3N4yn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775267809; x=1806803809; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+vVQmd16b7e2Ku5qlAzxOKUh9XuxhrBzZ88HMgk9Wlo=; b=NLW3N4yn7q1zHJ4XPWktBYKeiMa5nFPvKFIvEq5PBjeQ48G2DXZYyqqH WaUgGihHSAHIgOQRM1BiP8d8rJAT9Hp37E8qsrqDvKlnnbPKsC+otvb9X qobW4WqYgYagwUBUhK9iqhRt0Ko8P7i/Tnd1N7ZJssBrD38nM+rc2JxNW GhuG0OY91IsygzewJQrfqLf2FjW0nHyrqgv09dELg3E6sJrFnBELWl1Wc h5sTDwoKKq0AQ38ph/QN6sWkhhOfwsTa+bMskNvzWoCj9Y3UsraWKD0PC ZtM3LDnAQnVMDD0UjgkFbTf+cWeJa5SoEDuZn78Vb0OVbkouiGicSZAat Q==; X-CSE-ConnectionGUID: uhdJVIGyQwqzu13RlJnV0A== X-CSE-MsgGUID: Ne65rZnWTF+pPeb662DCmQ== X-IronPort-AV: E=McAfee;i="6800,10657,11748"; a="76343408" X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="76343408" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:44 -0700 X-CSE-ConnectionGUID: o57L4nMORgyktBfRYpq+SA== X-CSE-MsgGUID: E5XWa3lIQhaO/Z9rc6YTuA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="224121540" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:17 -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 v4 05/10] selftests/resctrl: Support multiple events associated with iMC Date: Fri, 3 Apr 2026 18:56:04 -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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Changes since v3: - Add Ilpo's RB 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.18]) (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 A0A1F2D8DD6; Sat, 4 Apr 2026 01:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267810; cv=none; b=W1fnzb5F0/3cjXVRngVA5RqKywHrOS4rBMlKoB8Si+/4wputkEn/rCRSO/YGtb545u8lhC4tisYe1Ishs9sJ2WyEw0xaXoVHsvPtdnen9qm/+3/KezzsrKzDm8ZUyJ2P1oewdzi4Ck5hMrWIs9950i4LJNiCjEcAHm3K7J27lds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267810; c=relaxed/simple; bh=NoaYUKVR4lY9sNUPm9mCjY1AAjwxHOVH15U9IBXNMGg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pkw2lzauadKkvrJ2Uj+si3j8PPZh+ZYxDbB0Se/nkvbr5dsiNbdKi0N4yVOT/nKiKSEf+r3R4jtSObOzh/lL44KoCMBqssPnN7/Zw8R7PueluXWz/kozSNG0gZC5Z+l4B8fLB/h3XQ0Ac+nW50nZI2d03YXIEFMoG1oADrsrtkQ= 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=amdLyw5v; arc=none smtp.client-ip=198.175.65.18 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="amdLyw5v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775267809; x=1806803809; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NoaYUKVR4lY9sNUPm9mCjY1AAjwxHOVH15U9IBXNMGg=; b=amdLyw5vdi1URFIAE3j+r2myOWP0qfDmuiCwKeU7w8gxhyww6Bn6CChb zbJsfCqfxWt/hApE1OEeXGmNjWHI42eB8Jc5VgiE9XgqYfMMc9UhnK1B+ X+p01CEhZ0Y7L1bRLGeyaR74BBWKeLdgkIrgVWZF7I8la9IQ87NVzYP5R Pc8E1z++yizGChlavlm5IV9b66FYHp0kDnGU3xJQIWk5IphV4b4qQ8qJh s/P65Km+UGj4q2MnTjG6oFzGNwQSxZE/2AWp/7f6Ls0ExvIBD9R6hBLWn KWBrABHbZyZXK+nIV9syt3enJL2hUv3I56k3XLK/XFCVkPZch5W1y1eW5 A==; X-CSE-ConnectionGUID: qdrOuLPcRPaHKcRryJLSLg== X-CSE-MsgGUID: xAn/QN/TTC2TkKCJuZjUjg== X-IronPort-AV: E=McAfee;i="6800,10657,11748"; a="76343401" X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="76343401" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:44 -0700 X-CSE-ConnectionGUID: TR0B63d7Q7+AwsKDqmyRxQ== X-CSE-MsgGUID: Y1InwMGzTo6hwV1e6P1mzg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="224121542" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:18 -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 v4 06/10] selftests/resctrl: Increase size of buffer used in MBM and MBA tests Date: Fri, 3 Apr 2026 18:56:05 -0700 Message-ID: <1bd4d8c5fc791234b0a9da94f29a3e278ba2f7ee.1775266384.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 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 Reviewed-by: Ilpo J=C3=A4rvinen 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] --- Changes since v2: - Add Chen Yu's tag. Changes since v3: - Add Ilpo's RB 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.18]) (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 E63472E7185; Sat, 4 Apr 2026 01:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267812; cv=none; b=cBY1uzex7TlS95COxLSUfBMPpdFKigsCZ0OxjfEagOrsEg4+hJotipVTKxsR+/1wF3Khx+ybD+YwlybhXlSD81Rj/Q4FtPXwxuHvWZH+p+NdmrT5/Eld/klIFfmMVgCL36EcniJpINIitjeW943qjgPXsDRUNfCdGF2gKv4G9y0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267812; c=relaxed/simple; bh=cRbJHEngvN7Z01nJA5XO8GqSctVY4W6GnAmvnR3EiLY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uE00U5a5CTJPbBXUZOqrfcHlLAlKpJV7MaRlJMZs551IooMYz90TpsetvQRFvcqeIQ1BSqgv4aSjbT6jmOszgqltsn2ijufnOWZQ26qjBDXiF0a0VKa2Hq4d3UWCp9vo4uxvRZrJVa3T6Up90TLITEmK8DnKlSUxDx3phXw9SKQ= 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=oEhTZ9tJ; arc=none smtp.client-ip=198.175.65.18 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="oEhTZ9tJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775267811; x=1806803811; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cRbJHEngvN7Z01nJA5XO8GqSctVY4W6GnAmvnR3EiLY=; b=oEhTZ9tJeX99VDDdpXJpMeszCaN5/Q0bZZtPplzL3DewGne5moNZ6BbI lxuGczyv5Xmdc7hRwp8/8VH3pIlHFLoKhflVPQexJ5MCmIz4HHMb/A/c6 DPwpIamfNRoWajnZncl9r5HPDY+YSfL428ap3rh+VAq8bdEySSP/jB5RK C0gyrT0wsEiGvrn7BRSPSf0ac0KABWBcKmlSaD2CPjDYZeozTF+zJJar8 UK14pioxsZqi6XvHHhsUAGBLlnn+FsTmy5tUGu0FsITMDIO/L4OV29Oix Fn+AduPfDch2siIVZxvwSoG4E+4D2nn3k6v0lpVlYAI1BLwkXgiW8mdzo g==; X-CSE-ConnectionGUID: 3T7TQnDNTcmzkvauAgj5Yw== X-CSE-MsgGUID: b4vH8BakSPmh6T9xh64MHA== X-IronPort-AV: E=McAfee;i="6800,10657,11748"; a="76343418" X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="76343418" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:45 -0700 X-CSE-ConnectionGUID: lLSUd3Z2QkWWpkEpY9Smeg== X-CSE-MsgGUID: Er5r7O4KTu6EZWIt17+ntA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="224121545" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:18 -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 v4 07/10] selftests/resctrl: Raise threshold at which MBM and PMU values are compared Date: Fri, 3 Apr 2026 18:56:06 -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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Changes since v3: - Start sentence in changelog with upper case. (Ilpo) - Add Ilpo's RB 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.18]) (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 214FA2DAFA9; Sat, 4 Apr 2026 01:56:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267810; cv=none; b=nazCFl+Q6gUHxAgfssHuogIhPcfon1Hu9i5DAt/FkF1uPI/V6N3XLSikOgqQgcMKOH4Za/oaE2pzZeZsDrteLue1Dnqt2AVJBbRIJRLYgz+x6DXc1xKUnoHCfY1naynT+o2QYUFDpCQuLh35BP18PjdcAz2hLE6TfL3aVQQvCfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267810; c=relaxed/simple; bh=lUjxt+hDZL+o4Rrc+j7qS62qkbC6Cn6HcahwNmT9Z3w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z1P+jVIsfAZtnA3Jcq/n6VpBdxDdHVxpT3LUpU0bD+ypVU3Ag26KcGwhNQxJDPGcewDvJ+nthI3WezZ2uGfcKsdphhXq4EEPwxcDQRNkFndgEwuR/6hP/5aJh3xMqbKbsyKEIQAAsMdXrwpg20D2MF0Ex3/emi4QpBBrnVnJnng= 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=hXvc50JZ; arc=none smtp.client-ip=198.175.65.18 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="hXvc50JZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775267809; x=1806803809; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lUjxt+hDZL+o4Rrc+j7qS62qkbC6Cn6HcahwNmT9Z3w=; b=hXvc50JZNCMbY5Xyb1YKIoILgeplX+LxxE5VxPYxQxpooeTkGFGnjVRr G5jTHU3rs3knmcidqsrazsxFUygU7+XCWZEylPvqsyOB6sg0uptYHsyUS iLHCrV++22dVndlmlmJvUIk52Cp3LBW+h8YuyCETMMw0d1OHMbqWUE0OX 83CFNqpL8rENBkN/9SFCPWtn72buMW8MuQf65z8SNsaeFzfy56RK3vqhm v6m+bixvG7tFLfUkkzPPUsB29M9BEn+dY4D3O4nuKZ2FEpegVwog+hLri CR0gkkP3xvfY3LniBaTyVwoYRhniYSpKCXB+OsBNdBFlIxE4268d5IQgo g==; X-CSE-ConnectionGUID: ykdn9ujMQK6msyVSk93f2w== X-CSE-MsgGUID: 6eZ28w3mRpKpb/TL36C/4A== X-IronPort-AV: E=McAfee;i="6800,10657,11748"; a="76343415" X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="76343415" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:45 -0700 X-CSE-ConnectionGUID: sSONFkpRQCSZL3lICQq0Ug== X-CSE-MsgGUID: t6bm+Mq/SuSvCph+5c1JIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="224121548" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:19 -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 v4 08/10] selftests/resctrl: Remove requirement on cache miss rate Date: Fri, 3 Apr 2026 18:56:07 -0700 Message-ID: <6de4da5486354c0f25fef0d194956470cb744041.1775266384.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 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. Changes since v3: - Add Ilpo's RB 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.18]) (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 48B5F2DF132; Sat, 4 Apr 2026 01:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267812; cv=none; b=KKjTwzj6SspFIR8o4z7UCYeEW4L0S1MJqauKVUEc+aLhr+WgNlzu+/JoxhYRftuEyi2pIHTdSdrWlzYurEIjrqAqQjY0m8qpFKkbvgtkfDHpjZjWVWEjS2ea4hQFB6tA/I1AxrUAuGHFD03dz5l4279z839UiGJTimsAhQ/1Seg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267812; c=relaxed/simple; bh=CyQqMUHLIJLOniMbFZD78eS2kKM4fFn2foPveBaayYE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CmZ8EFXmAneZgeznFng73BHb8vp2/LMBxJYRqz6qFucP8E9mlKlAYzbWof5199U9hzGqTI5irJRXlaNnb4pmp0GbXrsFFCRmM7U2DJN3Kt1xDvJd1NH23J7WThuleWt0UsvQ4fkT0arTfCrm8QNbAs+09hcd/R20SCPefZrm8is= 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=TT6fKHSm; arc=none smtp.client-ip=198.175.65.18 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="TT6fKHSm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775267810; x=1806803810; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CyQqMUHLIJLOniMbFZD78eS2kKM4fFn2foPveBaayYE=; b=TT6fKHSmSVvngQdROF2KTM2MkzwLnx0zVuI4hcg94/InSb0aBx0+ABSP L60grQUynMI+uZXr9QQhdjCbZVhsWrkZ+DNJ1FpZ79vxDSMVnXLg9zgzi e6EY7Ho+g52x2T23heRNtSyXiBZQ7DHUySvlSmq55/GLQ5Djm9HxLpOue dQIu4DPbjEoKcFioQ48LtsYIvJcgKQBI3iMasne8lAvBu8v6JBSZn+Qhl e7ZfKAsIBn4GBPRWzQ5We9+xy4zgULy0wAiV9k60NK5p/5CG/hqUAPIUb nnz6ngxb/1d4tTzCFFje1dbo7v/mtnACx99t4i9C4yhB0wZDqrHlBPAZy Q==; X-CSE-ConnectionGUID: J4ge8xcfRV2p/FsKsBSPZg== X-CSE-MsgGUID: P/AzphPVR7OBIvsgM7I4bw== X-IronPort-AV: E=McAfee;i="6800,10657,11748"; a="76343414" X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="76343414" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:45 -0700 X-CSE-ConnectionGUID: hVAtZnmcT4GRzUf00XeD/w== X-CSE-MsgGUID: JFmitjh2S6efCUVC5DnnRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="224121549" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:19 -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 v4 09/10] selftests/resctrl: Simplify perf usage in CAT test Date: Fri, 3 Apr 2026 18:56:08 -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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Changes since v3: - Add Ilpo's RB 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.18]) (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 7397A2F39C7; Sat, 4 Apr 2026 01:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267814; cv=none; b=pSZn3ediOnT5OAtAJASUs62DijVMWovvpQZ+2iXTFyY+fH8KhsmihUrV4qBZY02axUxr30RKRrqCTAh1RKbBAH9jYsVjPL8NVXnEDhBrZJcRKhFtLotNMtH+TYEH4jM5Greakl/9nXu4b6RJn1IcN3LgrBAmFQlCcwivuBWbQyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775267814; c=relaxed/simple; bh=TMYWBwczQQyNXGbZEwr5vrsjgD4HeYYTjcWXQ5+Sv5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pqUkaXp9bmwTfk79V/ihwuPPNCFKXgOiZn9Buhhi4wRndtMG1EfYiR18bcb0z3DLdTMmtjdPeyqNqH6txdfvPVo6LA8F6vm5ztPA8woxLpRGKTmcxy0GEWgPndZll11q0Zl8OWutT9LY4aTf8/+t5M38vjMeP9lI1pQjza/fscY= 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=M91mt9b4; arc=none smtp.client-ip=198.175.65.18 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="M91mt9b4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775267813; x=1806803813; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TMYWBwczQQyNXGbZEwr5vrsjgD4HeYYTjcWXQ5+Sv5s=; b=M91mt9b4XTuciLk7sXnugfHU+3EdRBtmICQG7etDXqOu0X4OmA9Ux/GK 9Zf9tuWr77B1/1XiT4HVej3N0XyMH77ysapGdCwS6mZleulsr/K5yqyJP 1LU/DAVlNrClepDq9WdwIjHdF0FDrR1RHPkFBM7JyQNqbwN5eCaNbx7XC /yijX4lkdHgP7eeuOqD2dRjVq9/YLeQoU7XZ4vOAj5BJlqpOaLJ0ewtnA BRp2REYQWuFjXTRhWCNzk3TavbauW8XePKiP1miJeGj63B42NDeffI94Y AeLjFWY/LcnCJ7D/TGemjivta+fTBIw8msd/ReXtwILNwvyVMkwOmgQNA w==; X-CSE-ConnectionGUID: ZI47sMo2TN2k67pnpxoebg== X-CSE-MsgGUID: XMd9O2DyTLWLDwIGK1CzlQ== X-IronPort-AV: E=McAfee;i="6800,10657,11748"; a="76343419" X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="76343419" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:45 -0700 X-CSE-ConnectionGUID: VWRYRkZaT8+CPdTF+Y0Raw== X-CSE-MsgGUID: TdQQh+obTtOK4eAOI9UkiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,158,1770624000"; d="scan'208";a="224121550" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2026 18:56:20 -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 v4 10/10] selftests/resctrl: Reduce L2 impact on CAT test Date: Fri, 3 Apr 2026 18:56:09 -0700 Message-ID: <1f5aad318889cd6d4f9a8d8b0fbe83e3848d41a9.1775266384.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 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. Changes since v3: - Add Ilpo's RB 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