aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinette Chatre <reinette.chatre@intel.com>2018-10-03 18:17:02 -0400
committerIngo Molnar <mingo@kernel.org>2018-10-09 02:50:43 -0400
commite5f3530c391105fdd6174852e3ea6136d073b45a (patch)
tree8a55ed74b927bbf64cabba9512b8e2d4c9c14660
parent521348b011d64cf3febb10b64ba5b472681bef94 (diff)
x86/intel_rdt: CBM overlap should also check for overlap with CDP peer
The CBM overlap test is used to manage the allocations of RDT resources where overlap is possible between resource groups. When a resource group is in exclusive mode then there should be no overlap between resource groups. The current overlap test only considers overlap between the same resources, for example, that usage of a RDT_RESOURCE_L2DATA resource in one resource group does not overlap with usage of a RDT_RESOURCE_L2DATA resource in another resource group. The problem with this is that it allows overlap between a RDT_RESOURCE_L2DATA resource in one resource group with a RDT_RESOURCE_L2CODE resource in another resource group - even if both resource groups are in exclusive mode. This is a problem because even though these appear to be different resources they end up sharing the same underlying hardware and thus does not fulfill the user's request for exclusive use of hardware resources. Fix this by including the CDP peer (if there is one) in every CBM overlap test. This does not impact the overlap between resources within the same exclusive resource group that is allowed. Fixes: 49f7b4efa110 ("x86/intel_rdt: Enable setting of exclusive mode") Reported-by: Jithu Joseph <jithu.joseph@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Jithu Joseph <jithu.joseph@intel.com> Acked-by: Fenghua Yu <fenghua.yu@intel.com> Cc: tony.luck@intel.com Cc: gavin.hindman@intel.com Cc: dave.hansen@intel.com Cc: hpa@zytor.com Link: https://lkml.kernel.org/r/e538b7f56f7ca15963dce2e00ac3be8edb8a68e1.1538603665.git.reinette.chatre@intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kernel/cpu/intel_rdt_rdtgroup.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index 9d59ee1c444e..49c479822844 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -983,10 +983,9 @@ static int rdtgroup_mode_show(struct kernfs_open_file *of,
983 * If a CDP peer was found, @r_cdp will point to the peer RDT resource 983 * If a CDP peer was found, @r_cdp will point to the peer RDT resource
984 * and @d_cdp will point to the peer RDT domain. 984 * and @d_cdp will point to the peer RDT domain.
985 */ 985 */
986static int __attribute__((unused)) rdt_cdp_peer_get(struct rdt_resource *r, 986static int rdt_cdp_peer_get(struct rdt_resource *r, struct rdt_domain *d,
987 struct rdt_domain *d, 987 struct rdt_resource **r_cdp,
988 struct rdt_resource **r_cdp, 988 struct rdt_domain **d_cdp)
989 struct rdt_domain **d_cdp)
990{ 989{
991 struct rdt_resource *_r_cdp = NULL; 990 struct rdt_resource *_r_cdp = NULL;
992 struct rdt_domain *_d_cdp = NULL; 991 struct rdt_domain *_d_cdp = NULL;
@@ -1033,7 +1032,7 @@ out:
1033} 1032}
1034 1033
1035/** 1034/**
1036 * rdtgroup_cbm_overlaps - Does CBM for intended closid overlap with other 1035 * __rdtgroup_cbm_overlaps - Does CBM for intended closid overlap with other
1037 * @r: Resource to which domain instance @d belongs. 1036 * @r: Resource to which domain instance @d belongs.
1038 * @d: The domain instance for which @closid is being tested. 1037 * @d: The domain instance for which @closid is being tested.
1039 * @cbm: Capacity bitmask being tested. 1038 * @cbm: Capacity bitmask being tested.
@@ -1052,8 +1051,8 @@ out:
1052 * 1051 *
1053 * Return: false if CBM does not overlap, true if it does. 1052 * Return: false if CBM does not overlap, true if it does.
1054 */ 1053 */
1055bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d, 1054static bool __rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d,
1056 unsigned long cbm, int closid, bool exclusive) 1055 unsigned long cbm, int closid, bool exclusive)
1057{ 1056{
1058 enum rdtgrp_mode mode; 1057 enum rdtgrp_mode mode;
1059 unsigned long ctrl_b; 1058 unsigned long ctrl_b;
@@ -1089,6 +1088,41 @@ bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d,
1089} 1088}
1090 1089
1091/** 1090/**
1091 * rdtgroup_cbm_overlaps - Does CBM overlap with other use of hardware
1092 * @r: Resource to which domain instance @d belongs.
1093 * @d: The domain instance for which @closid is being tested.
1094 * @cbm: Capacity bitmask being tested.
1095 * @closid: Intended closid for @cbm.
1096 * @exclusive: Only check if overlaps with exclusive resource groups
1097 *
1098 * Resources that can be allocated using a CBM can use the CBM to control
1099 * the overlap of these allocations. rdtgroup_cmb_overlaps() is the test
1100 * for overlap. Overlap test is not limited to the specific resource for
1101 * which the CBM is intended though - when dealing with CDP resources that
1102 * share the underlying hardware the overlap check should be performed on
1103 * the CDP resource sharing the hardware also.
1104 *
1105 * Refer to description of __rdtgroup_cbm_overlaps() for the details of the
1106 * overlap test.
1107 *
1108 * Return: true if CBM overlap detected, false if there is no overlap
1109 */
1110bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d,
1111 unsigned long cbm, int closid, bool exclusive)
1112{
1113 struct rdt_resource *r_cdp;
1114 struct rdt_domain *d_cdp;
1115
1116 if (__rdtgroup_cbm_overlaps(r, d, cbm, closid, exclusive))
1117 return true;
1118
1119 if (rdt_cdp_peer_get(r, d, &r_cdp, &d_cdp) < 0)
1120 return false;
1121
1122 return __rdtgroup_cbm_overlaps(r_cdp, d_cdp, cbm, closid, exclusive);
1123}
1124
1125/**
1092 * rdtgroup_mode_test_exclusive - Test if this resource group can be exclusive 1126 * rdtgroup_mode_test_exclusive - Test if this resource group can be exclusive
1093 * 1127 *
1094 * An exclusive resource group implies that there should be no sharing of 1128 * An exclusive resource group implies that there should be no sharing of