From nobody Wed Feb 11 01:25:57 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 E43B530CD80; Tue, 10 Feb 2026 16:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741389; cv=none; b=jj/tiCT6fDoyKzVN2lgS5tS80D4LC+dJioROal56CovQPIUCMJotLxL+ljjAOoxWyYm8LrmM+W7nlHOP3aPtyXX4qWJOD163aoHle1xsOLWBt2+FGrlpso/cbJ0CfyKYqI7sa5WuFGfsQif2Atu3nCJU8BClX54kKA2s2q3xFRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741389; c=relaxed/simple; bh=3ef+JIZyk1BCpaoxZjYIa2McjH4xu833l3yMdDsAq/Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PYw/VbayyGMeSm9SFl0kfho2B27yVCJfMTkZSj3z9ezQ3MWN8Pg3D26m0+yIgkSjJyl5Uc6dcZGIopdAG8AQcftYjUZlLLD/FqhEGjC4t5eKOJuZJAb9GhJULaRxHKWq2c8bQ18+x9QldWKhTmuZhEfF7OZGn/6HNDpcAu31e80= 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=ld8iDx7d; arc=none smtp.client-ip=192.198.163.13 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="ld8iDx7d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770741388; x=1802277388; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3ef+JIZyk1BCpaoxZjYIa2McjH4xu833l3yMdDsAq/Y=; b=ld8iDx7do3zfDvJlXVC8j987GDK0vSOpML18L8QCBcwlk+iLmk5tOKTC gl6BumWL6hxu1+IV/17r8E55aHgZojrnYUAYFDyQ0jxFO6UgK+oNDdDEV semuY4rMtvQSFLn8guFUISEkhAGW47Fg82nNz9aTWtqmRzpxJUGRpQqON 72gfhflKzSa9Z/UpucaNEpl3HQZDJLVK4QV9aHfq1L7xd/TdO1xGkuFxA 4MNspO6xLVKdbSRk7OVHAzl2USPgoCHewqs8YhPaLUIkq9LC1MmY/GmXi PIMF5FOc7/NsFw0hlUazwk6buur43xSmByyQjk/7NF9628Vmkr1cdEmue A==; X-CSE-ConnectionGUID: 5xDPU6fBT8aP15AJve4qIA== X-CSE-MsgGUID: Dsb1LQQPS3Osg5wsKIa/ew== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="74476822" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="74476822" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:27 -0800 X-CSE-ConnectionGUID: YMCSJ/bjSEeqsKMHZ8nHqg== X-CSE-MsgGUID: cavmhqYVSBW8yQyiAUPhgQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="212003454" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:26 -0800 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, peternewman@google.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: zide.chen@intel.com, dapeng1.mi@linux.intel.com, fenghuay@nvidia.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 1/8] selftests/resctrl: Do not store iMC counter value in counter config structure Date: Tue, 10 Feb 2026 08:50:40 -0800 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 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 local variable for use during event reading. Signed-off-by: Reinette Chatre --- 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..2cc22f61a1f8 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 return_value; 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, &return_value, sizeof(return_value)) =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 return_value.time_enabled; + __u64 r_time_running =3D return_value.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 return_value.value * of_mul_read * SCALE; } =20 *bw_imc =3D reads; --=20 2.50.1 From nobody Wed Feb 11 01:25:57 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 7AB4E30F80D; Tue, 10 Feb 2026 16:36:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741390; cv=none; b=FG8m4FyCCNN5F2bhAFH/iSHPI/7nw0qv47DPlW9kMa9OHz2fp+lkukQw/PECnOH86boseVodQV1OsfIPXUqkpZnQ3VOtIz5choaJ5eBCZXH+1uZnzs4Nw7jS8n6HasT3W3F+21gBc3QApwI6hyTUdz/iUOWKSwckbij69qjkuas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741390; c=relaxed/simple; bh=csCR9gx8yv/fc2Aby1rqXyh7H8QFmIbhJUVXdRA8sQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GscLgeekO0DfV1/aplN9ipCSrg0O943g8bopBYY/UFjeXamrEMS4Hs5KuL8XibwbuoKVZmcSQ39XO7AeNPJ3vnCAzNUeRru/NS6kBO3EeKGUTMO5Q/DPjRjqKK0bfzJ6VV71UDTeigoPFdLGZapofC2z3gwsB9qL2obZBRZG3NU= 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=Z+zTzStd; arc=none smtp.client-ip=192.198.163.13 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="Z+zTzStd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770741390; x=1802277390; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=csCR9gx8yv/fc2Aby1rqXyh7H8QFmIbhJUVXdRA8sQM=; b=Z+zTzStdq1h3jHiZ+kpOYCwJIRTMryUR1MGvQ8RuGNITbhT90XrNu5b3 1W89T+PfXlkQyvRDSZFIBeg+ixtz3CwXkMbFVAJnX35nDR/lFYMy9T8dL vFsVF0fZdqnCccQGtIuH3aFt4DJHzx/8PAg0+DPFPx2iD1xYQ/Bnp+1W/ 5PS5j+ImgfrF2hJdM0Rh4F74zfCMeBTfLZ2WO+7yZb6UZByx+y0r4HY4X 6CJOlwoDzoi2iY/CherZb06nlZ35aQXRLEC0yDS+8tYbprVNK+qT/z9QQ S3PCpxPN5hN/rOZ0NHqU5MnrL9vkVSFvtl4CYkVuwsV5j1rKrwAFZjtkm Q==; X-CSE-ConnectionGUID: kfLPQcltQSyNgwa5AvaWcg== X-CSE-MsgGUID: dHh2rpq4RuKw7pkE5dRcig== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="74476829" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="74476829" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:27 -0800 X-CSE-ConnectionGUID: obyf5qVbTla5y8bEgCljxQ== X-CSE-MsgGUID: T2LlLqEITSq9s4OMXgWg6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="212003457" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:26 -0800 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, peternewman@google.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: zide.chen@intel.com, dapeng1.mi@linux.intel.com, fenghuay@nvidia.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 2/8] selftests/resctrl: Prepare for parsing multiple events per iMC Date: Tue, 10 Feb 2026 08:50:41 -0800 Message-ID: <3ab21be3fcd9a85e1e204d4e28443fbe984998e1.1770406608.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 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 --- 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 2cc22f61a1f8..25c8101631e0 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 Wed Feb 11 01:25:57 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 7CDDD30CDB0; Tue, 10 Feb 2026 16:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741392; cv=none; b=rUDDlw++wIiyRyfoG8fDAh90rgGhqwvks2hy9sm02ul7PBl7160i3q+5g0N59d4wAqOMyPkk5T4AGAOT31LqTVvfFMD5/FmhdkJ5kuOnuDVW5ksoiIL7en6+zEqvXnyKsIV/Tla/JDNyv3KUCN/QSu1Cvj/52oFExDYA2renF0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741392; c=relaxed/simple; bh=TWvK61e4m2WC5DvKyQbhX3+UlBDW7zjZ9gwsvmLgMhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PEwqQkOPYtvMG3CYFxIN7MJJLpoH0E85ze1pUdfS18r1ZidcG+EeRU4/qgV1co8xIPnfhcyPgZn9d9JFnTs5aYDFLVGf03kVUr3TA4yyAItYaNF09dBry4X3ZO3cVOKu+2pMDjuD3HxT7yFoRuvLYja9lxt+Zbkxlfs0JY0JenM= 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=Ep3F+q6I; arc=none smtp.client-ip=192.198.163.13 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="Ep3F+q6I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770741391; x=1802277391; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TWvK61e4m2WC5DvKyQbhX3+UlBDW7zjZ9gwsvmLgMhM=; b=Ep3F+q6Ixi6RdxXj3FzOPcMnSu03G9WyM22FYC7WeP9z/3wswrLiHL5F dVeOijrOudWtaPyhArCmwhIM3C5FkOoMc4VqNOt/M4V6ruiMO+9zwTlSC be7YZ5PdtWHFqbVAKfZAfK3w+Qxoci+ObLj3rmZF2HThCQf8JXr9gyeZh xSfyKmWKN839iRhE4USQ0+0X+dZr0sqQ5EaihEkzFXjGipjNpzBIanobV Vehm9ONc4V041U4im7sDjmdsWSSJp9sRaocKOnivJcEMCERdri730G7Fu 5twHFdcF14xL2HrgClCuoAt8KhaZjBtKCeFUKLUkbDAvvdm5hy6tnXUE1 w==; X-CSE-ConnectionGUID: 0nDZoY62QyyP+n9XRfw15Q== X-CSE-MsgGUID: Rfnfti6XSKm3tbiVoqbJ9Q== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="74476836" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="74476836" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:27 -0800 X-CSE-ConnectionGUID: 2ymCO60MTi20wDcjUsHO1g== X-CSE-MsgGUID: HBOUw0OsQ6iKvscWzwcE8w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="212003460" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:26 -0800 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, peternewman@google.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: zide.chen@intel.com, dapeng1.mi@linux.intel.com, fenghuay@nvidia.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 3/8] selftests/resctrl: Support multiple events associated with iMC Date: Tue, 10 Feb 2026 08:50:42 -0800 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. 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. Ensure there is enough room in imc_counters_config[] before attempting to add an entry. Signed-off-by: Reinette Chatre --- tools/testing/selftests/resctrl/resctrl_val.c | 112 ++++++++++++++---- 1 file changed, 90 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index 25c8101631e0..7aae0cc5aee9 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,21 +109,102 @@ static int open_perf_read_event(int i, int cpu_no) return 0; } =20 +static int parse_imc_read_bw_events(char *imc_dir, unsigned int type, + unsigned int *count) +{ + char imc_events[1024], imc_counter_cfg[1024], cas_count_cfg[1024]; + unsigned int org_count =3D *count; + struct dirent *ep; + int path_len; + int ret =3D -1; + FILE *fp; + DIR *dp; + + path_len =3D snprintf(imc_events, sizeof(imc_events), "%sevents", imc_dir= ); + if (path_len >=3D sizeof(imc_events)) { + ksft_print_msg("Unable to create path to %sevents\n", imc_dir); + return -1; + } + dp =3D opendir(imc_events); + if (dp) { + 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, ep->d_name); + if (path_len >=3D sizeof(imc_counter_cfg)) { + ksft_print_msg("Unable to create path to %s/%s\n", + imc_events, 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; + } + if (fscanf(fp, "%1023s", cas_count_cfg) <=3D 0) { + ksft_perror("Could not get iMC cas count read"); + fclose(fp); + goto out_close; + } + fclose(fp); + if (*count >=3D MAX_IMCS) { + ksft_print_msg("Maximum iMC count exceeded\n"); + goto out_close; + } + + 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; + } + if (*count =3D=3D org_count) { + ksft_print_msg("Unable to find events in %s\n", imc_events); + goto out_close; + } + } else { + ksft_perror("Unable to open PMU events directory"); + goto out; + } + ret =3D 0; +out_close: + closedir(dp); +out: + return ret; +} + /* Get type and config of an iMC counter's read event. */ 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]; + char imc_counter_type[1024]; + unsigned int type; + int path_len; FILE *fp; + int ret; =20 /* Get type of iMC counter */ - sprintf(imc_counter_type, "%s%s", imc_dir, "type"); + 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; + } fp =3D fopen(imc_counter_type, "r"); if (!fp) { ksft_perror("Failed to open iMC counter type file"); =20 return -1; } - if (fscanf(fp, "%u", &imc_counters_config[*count].type) <=3D 0) { + if (fscanf(fp, "%u", &type) <=3D 0) { ksft_perror("Could not get iMC type"); fclose(fp); =20 @@ -131,24 +212,11 @@ static int read_from_imc_dir(char *imc_dir, unsigned = int *count) } fclose(fp); =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"); - - return -1; - } - if (fscanf(fp, "%1023s", cas_count_cfg) <=3D 0) { - ksft_perror("Could not get iMC cas count read"); - fclose(fp); - - 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; } - fclose(fp); - - get_read_event_and_umask(cas_count_cfg, *count); - *count +=3D 1; =20 return 0; } --=20 2.50.1 From nobody Wed Feb 11 01:25:57 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 A7C4D3128A3; Tue, 10 Feb 2026 16:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741392; cv=none; b=M0sWbkrZxqAyY9rM4zLiAXKLcDs/lRWFXKeXUA5UPvWJsaAYs3TtgGlm9iJJ8rep3Cet5SqrRbWuvtGro52eVz8VcwggFlnQMJrgKMS04/r2k+Fln3wieMTfsFiRwhCiBFNT9P4xNQHzFjEBA5eDZHyZjsdFsQJs2NlQHtADffY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741392; c=relaxed/simple; bh=aYBwxsXexDx1wpURXe2fS8HHTkWNax3PozdPsyGor0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DufT+VagveLa/97YKuMejVQd8X6KHN7FhdW8KpK1kbmVj2Qb9kNokGzT4GG6cviloD6cZQi9VPgqcKrlYNwGC26BDLlnhSnvhOy1QE0t8KyWk3cZMqJ0K1XtcQKTjqcyQ4K1QVAEGYA3Wu62o7SwF5arExl3R51akg5EA0iZVkE= 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=BZqYQVX4; arc=none smtp.client-ip=192.198.163.13 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="BZqYQVX4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770741391; x=1802277391; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aYBwxsXexDx1wpURXe2fS8HHTkWNax3PozdPsyGor0A=; b=BZqYQVX4UkwKy9N9Fk/slC+K1vxB1cKAdkYc3ctFZoKm1BxELZJKvAYu boqlU4NlbGJBdwY/q/saq/pIA4rXe0CghoDoNgbsecraoUna0yegdJa8m smOXarWxupQO5/G+FdqEAbQMGJOLBOcBJ6atnlW6kzCHCn0O46nfI062s rgtpPSXC+vYLJFgjOKsExjGteguePLZKC/IvFdqJY3OdiAJ50R13ie47c aj8ShafpsjpDH94VTNx5O9MPNFBgwqZ0BXOKcvhqj0QlHSGzk2msF/OGx CKInuVZTOSSb6B7T/x5dypcTFhhK0r+mGc3h4yIbQ6vibKjZPnmCN7TPl w==; X-CSE-ConnectionGUID: YVO8CRCCRWWXAHYP56fX6Q== X-CSE-MsgGUID: 4kZrp4SzT3eX+R1QdLQT1Q== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="74476844" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="74476844" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:28 -0800 X-CSE-ConnectionGUID: XzwkwnOAQMiCaAWCwzCMaA== X-CSE-MsgGUID: V+DCmGD4QXiSe4HwU8rtPA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="212003463" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:26 -0800 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, peternewman@google.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: zide.chen@intel.com, dapeng1.mi@linux.intel.com, fenghuay@nvidia.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 4/8] selftests/resctrl: Increase size of buffer used in MBM and MBA tests Date: Tue, 10 Feb 2026 08:50:43 -0800 Message-ID: <7bc3153a34e2736d389e94a12762ede4460873fe.1770406608.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 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] --- 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 Wed Feb 11 01:25:57 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 C1F6A3176EB; Tue, 10 Feb 2026 16:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741392; cv=none; b=cbr9cLDPth+wFoj68cZ57U3p6annmgtilnIBZqhDSZitr7XCn0C9TC18lFtobSFEWj4Tc7zyHvXeChTle6LKeuWqREVQXP7pTgckqw3jDu+45o1EY0nUsEkJuntqpPe7kVIPR1YJdGoPj0mdB3vnBR0QE8OUHc36FnB6RnxZcWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741392; c=relaxed/simple; bh=uBBHGG+Pb79Ww3RCSOJRUJ3SLe13CGVilpi6FeCHHrg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OtnZmcdYCXv4kl5YIsllPou4BMtcCy+E26eXS1j+15Z1UwkfKPFh1RCH3Ktcjt3fmnK8bQjhQiwbWJigk4w2T6cmM9qvG7hVh8aBMLi3yvBWFzDUtJmUfVKblim/67jPj4RkylfQr19o3EjsplNLr3/0xnxC0wAMJAvgw1Cwlcg= 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=LuNheeOk; arc=none smtp.client-ip=192.198.163.13 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="LuNheeOk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770741391; x=1802277391; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uBBHGG+Pb79Ww3RCSOJRUJ3SLe13CGVilpi6FeCHHrg=; b=LuNheeOkdSpKMlhE4nhYF4RpzLN653aL8SHEmuPi+Y5WQihe7Mt4O31S G+L1mKdeNionW/Dj3GfDzlwkPmtI2zJ5ilnrImrcJOQegYmylSm6soxjQ bnAQ63pHZslNomsE5oS4hPQw+intU0azTf37GU68I33oMLUWbPzPdYY2D ChfTKE662Bo7ucN6bSPlk/RW5kqNVW6ofPlbRwWI8N+sSmvMZBLvx/IBB UZaq/7G45ae7UTQDYoWhZ6dT8OxCF4rVkxh+JtYPZLjg4XKKzbrdRP6P1 eV66eezrVVJMHy8ykMOfIwsezj9FecYC/QTUAxcwExcHvvGQNim4aHnpp w==; X-CSE-ConnectionGUID: t3xzOuUTSxy0agGTpNp+ig== X-CSE-MsgGUID: mQM6B0zST2uA8Q6xqlCczw== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="74476852" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="74476852" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:28 -0800 X-CSE-ConnectionGUID: kgqoaQyeSpGwLmoIF7R/5w== X-CSE-MsgGUID: 9pKWE1k5SQGIXVZN5pI9QQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="212003466" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:27 -0800 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, peternewman@google.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: zide.chen@intel.com, dapeng1.mi@linux.intel.com, fenghuay@nvidia.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 5/8] selftests/resctrl: Raise threshold at which MBM and PMU values are compared Date: Tue, 10 Feb 2026 08:50:44 -0800 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" 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 --- 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 c72045c74ac4..861bf25f2f28 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 Wed Feb 11 01:25:57 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 28FA531B825; Tue, 10 Feb 2026 16:36:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741393; cv=none; b=hpI5F9xR5C492uJp+tpf7+sNXVaA13fLIMQQnF2tej7WH1vm5pzeP6E3DwUGRpwcOjPVpvl6M7tj7viB1Nr8gre3U5Ub9llqLfj35TolMyYO9bWsh3XxmDEgvFiTEn6s7wtdztkGMdSuvw0A+1+Ht+/prLoxaKO++H58pIIImJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741393; c=relaxed/simple; bh=p4hBr88k1cRQj/oM4nrRI2Q/ltvVnJYt8NL4L6JrEo8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dMYrYFYMRAvMS09xRQ+M4hkPoLNafBCnpnNOXjJle0iehKMB1X1ac49iULjVCqGQrLaoc8DkdT93yW14cJMTjHmg9xyIKi/ZOYXq4cauOb9ec913MkblMchIxJADi2qEBepox/MK7AMKg+6w+Ij7XyJ7DsiFLH9Ou9ow9+YbBcc= 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=H6pDVx1l; arc=none smtp.client-ip=192.198.163.13 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="H6pDVx1l" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770741392; x=1802277392; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p4hBr88k1cRQj/oM4nrRI2Q/ltvVnJYt8NL4L6JrEo8=; b=H6pDVx1l9UgybQTxhsMrcYalZ5Nm9KnXBCeNOWLeWDlrxk5ulpPD9r6U 2gUsRsjyKUo3iAtSUYgJ9IeV4dUknZq+AVRtk+nz8DgIsvJivrfAtHhxx GiIN2GlCqsu+0ygO9DRaIk8eE4tsX+eb5OdYxiLwddGjPx6+N4//OzK3g BI3FA0ty2gK12Pbgq/fVBPkHTwpfTrs8dAAVYfd29x8GPTf31hfac/RaL Eus5yWk58p3msRpKMPt+9ZSRZRYvxESqKXrEkzMaojurtz7T+nK0PFyEg uJTW77AuXF0PGTfQHZgbzYPjbP0xcEXlOAYpxFsZpfTQdCPQTxJ2HI9K3 Q==; X-CSE-ConnectionGUID: UoldxiVCSf+J62Q8fSS11g== X-CSE-MsgGUID: mDW7W8U+RJm3bxgurC/OfA== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="74476860" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="74476860" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:28 -0800 X-CSE-ConnectionGUID: t7bUpeyeRKe7qPgrcnZODg== X-CSE-MsgGUID: 4gLRrIuXSaCRC1PybS138w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="212003469" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:27 -0800 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, peternewman@google.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: zide.chen@intel.com, dapeng1.mi@linux.intel.com, fenghuay@nvidia.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 6/8] selftests/resctrl: Remove requirement on cache miss rate Date: Tue, 10 Feb 2026 08:50:45 -0800 Message-ID: <1730081d5b8c88d6c7f2696a9cce1eae34f6f810.1770406608.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 --- 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 Wed Feb 11 01:25:57 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 2D98531D367; Tue, 10 Feb 2026 16:36:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741393; cv=none; b=HODCmrj0aPVDAzQzKznJwyOOOYb6GFwd3Flmar+qx1swR5pk9jz/LFbOQYF1bN131Wgv+pELBzLZDwYb7KNfbQ1SSz2/B1PIAxseB30QzhrA9FOgxsVyXhmaxKbJ5Q1ahGe39TbmBapBABHF6WHHSiE2n+FqgazGiWtepCDng8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741393; c=relaxed/simple; bh=cBIUYkcTaLcFGaaS2gjR42fcrLXFw9Kcvy5bKM/KiC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H104t1wP81fc/g6+flSVEe+9BXrIB4D1h5krZF/lLaPPAXV4g6iTDOkU8Y6vUh9KZGSAQth8DW/mNiFiyTLOj5LnKMnw0+jWoPKiEBDGnvPj4y0EKG3oX2NCQf7QL5F/pJretcyMAo3OgI0wZjzW6jFIpDQlrqFJHgRbCwZOW2I= 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=TK+pYUu+; arc=none smtp.client-ip=192.198.163.13 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="TK+pYUu+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770741392; x=1802277392; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cBIUYkcTaLcFGaaS2gjR42fcrLXFw9Kcvy5bKM/KiC8=; b=TK+pYUu+hYyRtU3j2svR4NSEWPFnAvZsioz8PSNcbQ/udA8qDfwBwN25 SEg5R2OED4pwTA4UOBBnZZ8DLd+V2KUmh0KStvuSpxElEXBfC0XjXIdkP 7OLPf7BQhyS6RzuluVE9xc6Sqd+xTIUjGIi7cFdjZoNy2TW/SjVOS6G9O 6VFuvyraQN1dZrb33ckJkcGNQ1YBRLatlFNg4WGct4vpB9LLa/mRyJRgU hyZ6zoqpPcIYul7YI/DsJb/uLa91jhggtapQUtag/KNi6rE4mMLYoGBdW l28tiHvFEdSAdTfrVgabhS+Y5pR4U9dMCgUXqXsrRBaaKmdMBEEvpwV9Q Q==; X-CSE-ConnectionGUID: QyZHVqGnRjiTI/pG1uei3w== X-CSE-MsgGUID: bIKr8KV9Tle2FqFlNZ4fsQ== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="74476869" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="74476869" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:28 -0800 X-CSE-ConnectionGUID: gZ3iTbvxRuitsUhPZv0/Rw== X-CSE-MsgGUID: cTFfAn+WSxG7NVUEaID47Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="212003472" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:27 -0800 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, peternewman@google.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: zide.chen@intel.com, dapeng1.mi@linux.intel.com, fenghuay@nvidia.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 7/8] selftests/resctrl: Simplify perf usage in CAT test Date: Tue, 10 Feb 2026 08:50:46 -0800 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 --- 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 1ff1104e6575..03313a5ff905 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 861bf25f2f28..e04b313dd7f7 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); 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 Wed Feb 11 01:25:57 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 4F3E53203BC; Tue, 10 Feb 2026 16:36:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741394; cv=none; b=f+bubNyLX/2qID97FIw40vNzdJXdCLE8sPjYv3uS+la0TB/DUQCKZTqyH2PgasvBlt8IzwrumX9JpqoRQwXv/t7M5HuWKygwMk6+YNL7c+mMPYh34cBd5e0XrFBTkl/1NB0bdlRy+g19eepoyOKjxP+peGsodK1Vwqvw1wgZzZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770741394; c=relaxed/simple; bh=kH8up4x2qXh5qYwxKPcjYKankJXfqnKuAMLBmbTJGVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tCwIhEyjQ6LXGgZl9zRkgAOzFAaWeoroDDKHrmIKT3pAtg/IHnaX0zpybNfxj1W9ucNIQfXHfXnSaKuPBBB5F0QwPNaNpO8ycDFDbc4BEX0umqAHbnMDbfzdZAKFLg0SXDso6YdjmO3XpN83vaW7hwKDFUfIDIsVRH+9tK4DNYE= 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=Jy3nidyg; arc=none smtp.client-ip=192.198.163.13 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="Jy3nidyg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770741392; x=1802277392; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kH8up4x2qXh5qYwxKPcjYKankJXfqnKuAMLBmbTJGVg=; b=Jy3nidygf0t9gdgnZtIOsP47aadx0NlKQ2VTpw4Ne0efk+I7NDksqCft MXlBC3bWG88+qND6tcHtGNSPjQdKtJfx0F/+q07fmw7nW+I0mNyD56Lfe MMnD2nILus/ObtyC+ER8ib2LCKPzGfAhNENmO/0D3WTiY+RPCGel56BjF cQk7QIVQZyYeDIgQaAI7b5clLyLzU2LNXX3SOTEsEzZQrU/Y5VDj/IK0Q Isei/k/E36jdh3+WsZfg+uh6wohWsoZvIUNHxoSTVrRRLfuGrfyrdxF+C lbeUZxeSvds5yOPzGib4ZmyEp0uYmqhLfrCfNcU2faKuqwqOkz9YrKDYT Q==; X-CSE-ConnectionGUID: iQWkREixQ3i6d8BQzsizow== X-CSE-MsgGUID: EsEWwTteRUO9LTlX3zm7Tw== X-IronPort-AV: E=McAfee;i="6800,10657,11697"; a="74476875" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="74476875" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:28 -0800 X-CSE-ConnectionGUID: NOIld8ofTJ+0evx5IeyRZQ== X-CSE-MsgGUID: A0od80nmTva5r78fUeHwnw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="212003475" Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2026 08:36:27 -0800 From: Reinette Chatre To: shuah@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, tony.luck@intel.com, peternewman@google.com, babu.moger@amd.com, ilpo.jarvinen@linux.intel.com Cc: zide.chen@intel.com, dapeng1.mi@linux.intel.com, fenghuay@nvidia.com, reinette.chatre@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 8/8] selftests/resctrl: Reduce L2 impact on CAT test Date: Tue, 10 Feb 2026 08:50:47 -0800 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 --- tools/testing/selftests/resctrl/cat_test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/sel= ftests/resctrl/cat_test.c index 6aac03147d41..26062684a9f4 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -157,6 +157,12 @@ static int cat_test(const struct resctrl_test *test, if (ret) goto reset_affinity; =20 + if (!strcmp(test->resource, "L3") && resctrl_resource_exists("L2")) { + ret =3D write_schemata(param->ctrlgrp, "0x1", uparams->cpu, "L2"); + 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