From nobody Fri Feb 13 06:07:45 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 D357115B96F for ; Fri, 31 May 2024 19:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717185458; cv=none; b=SekyVsyoYh2n9dp82v0H4ZWdCyvUlenpCgzT3HoalAJJDZH9WPJ5N7fs4vaCSMc48qcST0Pq3+iIGcQ3xiAx8v2h7O/2mS2cvBEEqz7dQFfz4zpIF0hd3R0N5JzCA2THdJfWFrAFYmkfkHB6ppwAj430L21rbnKVfUTj1NUspMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717185458; c=relaxed/simple; bh=o83mz7amY+OfaedT6o7+b/lkwfPSdChdBSbbCqdXIZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eri1nsW3pBH2YmODcqTBf66yWWmZDjA/Iuk4hFrrcGfOMKwwugzFZiJFbjX4B4E4tTvPpjzkVxu6hxr7saqkKL9jDaOWGAyRxu75qSwSjf9F2nCVUtZu6DvyFpLI0o2mJlqUm6734zw9t1/ZTyaZn33UQAtnWxdlTvWM+OcFXYc= 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=nFVZz6hR; arc=none smtp.client-ip=192.198.163.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="nFVZz6hR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717185455; x=1748721455; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o83mz7amY+OfaedT6o7+b/lkwfPSdChdBSbbCqdXIZU=; b=nFVZz6hRvLPw69GsKeQcygYVUFop9vakpCv3/pB/GHqgOnx9j9AR+43p sYZdNyBzjgSs2jQBEL+T1qLPwMp2YGSc/HdJq9nsJkROsdHtTDDH7agxU xHjURz/SBPgqEwD3vuPzIdNjMGOKTZpG4f7YVj9R6F+sy7GgdbSvBL1JI 1f4p5C+QVwG0Wcf54RFXT+2NzIv3LO2Li45b3iResIwEOxi+AvZLYuwjx /lY3ZCaG1FhdyOZ8NO1gXt1cp31ZekYlTQd/e/6Z6vtHN0O/6mGXHlnTQ gvNyDYwCj6qQHm91WRjgEDDOXD6MFCl4gKy7O+gl3xY3TmzlGIOnhafpA A==; X-CSE-ConnectionGUID: AI8M+UzeTSev+WmyT/bLrw== X-CSE-MsgGUID: HNyjTV2ZRqqmv1yqzwJVNA== X-IronPort-AV: E=McAfee;i="6600,9927,11089"; a="13501136" X-IronPort-AV: E=Sophos;i="6.08,205,1712646000"; d="scan'208";a="13501136" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 12:57:32 -0700 X-CSE-ConnectionGUID: Bxe7bMbyT9CbNwD0OsZ/Tw== X-CSE-MsgGUID: qpP2GZ2DQUezfaQV8RgBSw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,205,1712646000"; d="scan'208";a="59438870" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 12:57:32 -0700 From: Tony Luck To: Greg Kroah-Hartman , Andrew Morton , Thomas Gleixner , Borislav Petkov Cc: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 1/3] cacheinfo: Add function to get cacheinfo for a given (cpu, cachelevel) Date: Fri, 31 May 2024 12:57:18 -0700 Message-ID: <20240531195720.232561-2-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240531195720.232561-1-tony.luck@intel.com> References: <20240531195720.232561-1-tony.luck@intel.com> 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" Resctrl code open codes a search for information about a given cache level in a couple of places (and more are on the way). Provide a new inline function get_cpu_cacheinfo_level() in to do the search and return a pointer to the cacheinfo structure. Simplify the existing get_cpu_cacheinfo_id() by using this new function to do the search. Signed-off-by: Tony Luck --- include/linux/cacheinfo.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h index 2cb15fe4fe12..301b0b24f446 100644 --- a/include/linux/cacheinfo.h +++ b/include/linux/cacheinfo.h @@ -113,10 +113,10 @@ int acpi_get_cache_info(unsigned int cpu, const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_= leaf); =20 /* - * Get the id of the cache associated with @cpu at level @level. + * Get the cacheinfo structure for cache associated with @cpu at level @le= vel. * cpuhp lock must be held. */ -static inline int get_cpu_cacheinfo_id(int cpu, int level) +static inline struct cacheinfo *get_cpu_cacheinfo_level(int cpu, int level) { struct cpu_cacheinfo *ci =3D get_cpu_cacheinfo(cpu); int i; @@ -124,12 +124,23 @@ static inline int get_cpu_cacheinfo_id(int cpu, int l= evel) for (i =3D 0; i < ci->num_leaves; i++) { if (ci->info_list[i].level =3D=3D level) { if (ci->info_list[i].attributes & CACHE_ID) - return ci->info_list[i].id; - return -1; + return &ci->info_list[i]; + return NULL; } } =20 - return -1; + return NULL; +} + +/* + * Get the id of the cache associated with @cpu at level @level. + * cpuhp lock must be held. + */ +static inline int get_cpu_cacheinfo_id(int cpu, int level) +{ + struct cacheinfo *ci =3D get_cpu_cacheinfo_level(cpu, level); + + return ci ? ci->id : -1; } =20 #ifdef CONFIG_ARM64 --=20 2.45.0 From nobody Fri Feb 13 06:07:45 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 5C80617CA09 for ; Fri, 31 May 2024 19:57:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717185456; cv=none; b=CGEGqiJVyGcc7YFyIoX08SfaT3ltTZrt29RgD5QGkfSSqWSDHNdZ77rP9X2fJgCrnRELNsEW7VMR5U9GtGAD5dYTYSoAv2/Yf+m35Sy2F0uJ/Lqva31sK3ubsnaIpEpmhbA8r0svPG40MApa/aXtdJsW6iV5H4SA17T7wlWag6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717185456; c=relaxed/simple; bh=RsqO07LtaR/1pQ294RLwenEBg2L8jtETbGsARD5fAjo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fl4tkIPqfLxwwesXQL4BErp29qriyskuCGPkirgTrZ8zaqQQ0Fb8NUyfzviBO85Wk7ryUcLH6wCazNZEycTdKdXOSBiol7KPken9pdXOHR3P1qSMJyFo0Vtx8n2aMYLa6+8PDPrXA4FhAGO0nESfA+JSD4+rlTr6lsNLP41+2Vg= 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=ZJKlGeh2; arc=none smtp.client-ip=192.198.163.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="ZJKlGeh2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717185455; x=1748721455; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RsqO07LtaR/1pQ294RLwenEBg2L8jtETbGsARD5fAjo=; b=ZJKlGeh21J6/yGuI58Pxh+Tkd7vnoEwCxXprd4CMeslZinmxkyo0uvH+ pnaLPG8B9RWDq2y675QqDdieg96pW5qycCMLtrpSa8pgLaLm3CKc8eabY pu9NGTMGrjGkyWaRsHT5NIQB/N1q2k5lGfz1BBYg2UAklgkyJfzqK+Po5 qGDn/Mjs1y8xaFAWku8f4AdckrUmXBdwZot4dV8TnLTO9cQmHc47+QLt1 ba7yttIp1NKELUomcsMwhkV2fc0+PlinAfgoYrrbLq+Gb5FnJ02v7BzCU /rVYHdwub1qwyqfpJnZCuGIECqiRc6sQHlIkOyID8LX5IIRBuSDAs4isu Q==; X-CSE-ConnectionGUID: XbLATo1ITHCowp7eofFzGQ== X-CSE-MsgGUID: p+iOPmpsTCu1pIdV+TC4vg== X-IronPort-AV: E=McAfee;i="6600,9927,11089"; a="13501146" X-IronPort-AV: E=Sophos;i="6.08,205,1712646000"; d="scan'208";a="13501146" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 12:57:33 -0700 X-CSE-ConnectionGUID: KoVO3zmHRBm5PSLOFDbLfA== X-CSE-MsgGUID: /Lt1zt62TxGKKJVhQXyUeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,205,1712646000"; d="scan'208";a="59438873" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 12:57:32 -0700 From: Tony Luck To: Greg Kroah-Hartman , Andrew Morton , Thomas Gleixner , Borislav Petkov Cc: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 2/3] x86/resctrl: Replace open code cacheinfo search in pseudo_lock_region_init() Date: Fri, 31 May 2024 12:57:19 -0700 Message-ID: <20240531195720.232561-3-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240531195720.232561-1-tony.luck@intel.com> References: <20240531195720.232561-1-tony.luck@intel.com> 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" Use get_cpu_cacheinfo_level() instead of open coded search. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cp= u/resctrl/pseudo_lock.c index aacf236dfe3b..1bbfd3c1e300 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -292,9 +292,8 @@ static void pseudo_lock_region_clear(struct pseudo_lock= _region *plr) */ static int pseudo_lock_region_init(struct pseudo_lock_region *plr) { - struct cpu_cacheinfo *ci; + struct cacheinfo *ci; int ret; - int i; =20 /* Pick the first cpu we find that is associated with the cache. */ plr->cpu =3D cpumask_first(&plr->d->cpu_mask); @@ -306,15 +305,11 @@ static int pseudo_lock_region_init(struct pseudo_lock= _region *plr) goto out_region; } =20 - ci =3D get_cpu_cacheinfo(plr->cpu); - - plr->size =3D rdtgroup_cbm_to_size(plr->s->res, plr->d, plr->cbm); - - for (i =3D 0; i < ci->num_leaves; i++) { - if (ci->info_list[i].level =3D=3D plr->s->res->cache_level) { - plr->line_size =3D ci->info_list[i].coherency_line_size; - return 0; - } + ci =3D get_cpu_cacheinfo_level(plr->cpu, plr->s->res->cache_level); + if (ci) { + plr->line_size =3D ci->coherency_line_size; + plr->size =3D rdtgroup_cbm_to_size(plr->s->res, plr->d, plr->cbm); + return 0; } =20 ret =3D -1; --=20 2.45.0 From nobody Fri Feb 13 06:07:45 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 E74CA17D8B0 for ; Fri, 31 May 2024 19:57:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717185458; cv=none; b=mL3vM2mbjZSyIWlSfoZgOKrg4Mo+POGoEOwyBu8ODFaNSdVxV37PwQUi2f97C//bqNnZeiNLrjdxGHX6/gTYaXSoCHNrhiELpEweMGHZYjf7sdUvkb7MCTY1vnxCaYYydhU0Vp983MFqQI7RNtAACQxz+/lo4gJ84FF+u1EKMaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717185458; c=relaxed/simple; bh=waO47AVKQXebwki+vP6AIbp5ruc9+vs3ozpJycT6ARA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t9pl5SBc6JO0BFeBXveDE87KbETbomPMk90SF+iJgH8xKwKfVxQ5VzMPnQys1t8/wWhv70+inArICNoZD4alJkyG/aJmvUCaBbl38zQfA3jwQtX50EyaMdsUVx8u+V94l9J3REBo7FGszlVVJQvXizzIvEFRpdTpjN8JKvQGcKk= 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=SdsRnDqn; arc=none smtp.client-ip=192.198.163.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="SdsRnDqn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717185457; x=1748721457; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=waO47AVKQXebwki+vP6AIbp5ruc9+vs3ozpJycT6ARA=; b=SdsRnDqngIY/gjuwLjQHTaAEYGSlrWwhYxK27cycQkDKi8AIMzwQDw0u 92Rhd189cGUk3zV4GeSX1rsWyefdy+6JpDBkuO8uA4ebzBJvDgnUjAEAN EenGxak5rZZ4R+kktrJHsy4GYImlEvdjgidUafqm/9MwJjCfDZfrxL3d2 JmnSXVyOgCBo43huKKzmnt5dRnFQ/wcwCcQofQnOJqDdlHIxasY6a8AhQ 6eEQHjbNuIa4Vr993F0upzOOqQdseUBTaL59knz0kDaOBpN/q1aYzgrMB PqlqBuGbvN1kHKCDtqNrvvEJAXVNNj4pla55m5xxKwY9UixhOhtyDTYEZ w==; X-CSE-ConnectionGUID: ulTfKwJpS0S+Q+av3a/eTA== X-CSE-MsgGUID: Aojv2MvKTKSSd/CRU7UqcA== X-IronPort-AV: E=McAfee;i="6600,9927,11089"; a="13501156" X-IronPort-AV: E=Sophos;i="6.08,205,1712646000"; d="scan'208";a="13501156" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 12:57:33 -0700 X-CSE-ConnectionGUID: /+Q61v0/Q8CNZEn5CRgApA== X-CSE-MsgGUID: ArwkRCBhT3WOD32XSQ+O9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,205,1712646000"; d="scan'208";a="59438876" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2024 12:57:32 -0700 From: Tony Luck To: Greg Kroah-Hartman , Andrew Morton , Thomas Gleixner , Borislav Petkov Cc: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 3/3] x86/resctrl: Replace open code cacheinfo search in rdtgroup_cbm_to_size() Date: Fri, 31 May 2024 12:57:20 -0700 Message-ID: <20240531195720.232561-4-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240531195720.232561-1-tony.luck@intel.com> References: <20240531195720.232561-1-tony.luck@intel.com> 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" Use get_cpu_cacheinfo_level() instead of open coded search. Signed-off-by: Tony Luck Reviewed-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 02f213f1c51c..4a5ab0f6a412 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1450,18 +1450,14 @@ static ssize_t rdtgroup_mode_write(struct kernfs_op= en_file *of, unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_domain *d, unsigned long cbm) { - struct cpu_cacheinfo *ci; + struct cacheinfo *ci; unsigned int size =3D 0; - int num_b, i; + int num_b; =20 num_b =3D bitmap_weight(&cbm, r->cache.cbm_len); - ci =3D get_cpu_cacheinfo(cpumask_any(&d->cpu_mask)); - for (i =3D 0; i < ci->num_leaves; i++) { - if (ci->info_list[i].level =3D=3D r->cache_level) { - size =3D ci->info_list[i].size / r->cache.cbm_len * num_b; - break; - } - } + ci =3D get_cpu_cacheinfo_level(cpumask_any(&d->cpu_mask), r->cache_level); + if (ci) + size =3D ci->size / r->cache.cbm_len * num_b; =20 return size; } --=20 2.45.0