Commit 322f530f authored by Reinette Chatre's avatar Reinette Chatre Committed by Greg Kroah-Hartman

x86/intel_rdt: CBM overlap should also check for overlap with CDP peer

[ Upstream commit e5f3530c ]

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: 49f7b4ef ("x86/intel_rdt: Enable setting of exclusive mode")
Reported-by: default avatarJithu Joseph <jithu.joseph@intel.com>
Signed-off-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Tested-by: default avatarJithu Joseph <jithu.joseph@intel.com>
Acked-by: default avatarFenghua 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.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 36cf9131
...@@ -987,8 +987,7 @@ static int rdtgroup_mode_show(struct kernfs_open_file *of, ...@@ -987,8 +987,7 @@ static int rdtgroup_mode_show(struct kernfs_open_file *of,
* If a CDP peer was found, @r_cdp will point to the peer RDT resource * If a CDP peer was found, @r_cdp will point to the peer RDT resource
* and @d_cdp will point to the peer RDT domain. * and @d_cdp will point to the peer RDT domain.
*/ */
static int __attribute__((unused)) rdt_cdp_peer_get(struct rdt_resource *r, static int rdt_cdp_peer_get(struct rdt_resource *r, struct rdt_domain *d,
struct rdt_domain *d,
struct rdt_resource **r_cdp, struct rdt_resource **r_cdp,
struct rdt_domain **d_cdp) struct rdt_domain **d_cdp)
{ {
...@@ -1037,7 +1036,7 @@ static int __attribute__((unused)) rdt_cdp_peer_get(struct rdt_resource *r, ...@@ -1037,7 +1036,7 @@ static int __attribute__((unused)) rdt_cdp_peer_get(struct rdt_resource *r,
} }
/** /**
* rdtgroup_cbm_overlaps - Does CBM for intended closid overlap with other * __rdtgroup_cbm_overlaps - Does CBM for intended closid overlap with other
* @r: Resource to which domain instance @d belongs. * @r: Resource to which domain instance @d belongs.
* @d: The domain instance for which @closid is being tested. * @d: The domain instance for which @closid is being tested.
* @cbm: Capacity bitmask being tested. * @cbm: Capacity bitmask being tested.
...@@ -1056,7 +1055,7 @@ static int __attribute__((unused)) rdt_cdp_peer_get(struct rdt_resource *r, ...@@ -1056,7 +1055,7 @@ static int __attribute__((unused)) rdt_cdp_peer_get(struct rdt_resource *r,
* *
* Return: false if CBM does not overlap, true if it does. * Return: false if CBM does not overlap, true if it does.
*/ */
bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d, static bool __rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d,
unsigned long cbm, int closid, bool exclusive) unsigned long cbm, int closid, bool exclusive)
{ {
enum rdtgrp_mode mode; enum rdtgrp_mode mode;
...@@ -1092,6 +1091,41 @@ bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d, ...@@ -1092,6 +1091,41 @@ bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d,
return false; return false;
} }
/**
* rdtgroup_cbm_overlaps - Does CBM overlap with other use of hardware
* @r: Resource to which domain instance @d belongs.
* @d: The domain instance for which @closid is being tested.
* @cbm: Capacity bitmask being tested.
* @closid: Intended closid for @cbm.
* @exclusive: Only check if overlaps with exclusive resource groups
*
* Resources that can be allocated using a CBM can use the CBM to control
* the overlap of these allocations. rdtgroup_cmb_overlaps() is the test
* for overlap. Overlap test is not limited to the specific resource for
* which the CBM is intended though - when dealing with CDP resources that
* share the underlying hardware the overlap check should be performed on
* the CDP resource sharing the hardware also.
*
* Refer to description of __rdtgroup_cbm_overlaps() for the details of the
* overlap test.
*
* Return: true if CBM overlap detected, false if there is no overlap
*/
bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d,
unsigned long cbm, int closid, bool exclusive)
{
struct rdt_resource *r_cdp;
struct rdt_domain *d_cdp;
if (__rdtgroup_cbm_overlaps(r, d, cbm, closid, exclusive))
return true;
if (rdt_cdp_peer_get(r, d, &r_cdp, &d_cdp) < 0)
return false;
return __rdtgroup_cbm_overlaps(r_cdp, d_cdp, cbm, closid, exclusive);
}
/** /**
* rdtgroup_mode_test_exclusive - Test if this resource group can be exclusive * rdtgroup_mode_test_exclusive - Test if this resource group can be exclusive
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment