[RFC PATCH 14/20] x86/intel_rdt: Enable testing for pseudo-locked region

From: Reinette Chatre
Date: Mon Nov 13 2017 - 19:43:00 EST


Introduce a new test that can be used to determine if a provided CBM
intersects with an existing pseudo-locked region of cache domain.

Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
---
arch/x86/kernel/cpu/intel_rdt.h | 1 +
arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)

diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h
index b4426a997516..529fe535b357 100644
--- a/arch/x86/kernel/cpu/intel_rdt.h
+++ b/arch/x86/kernel/cpu/intel_rdt.h
@@ -457,6 +457,7 @@ void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms);
void cqm_handle_limbo(struct work_struct *work);
bool has_busy_rmid(struct rdt_resource *r, struct rdt_domain *d);
void __check_limbo(struct rdt_domain *d, bool force_free);
+bool cbm_pseudo_locked(unsigned long cbm, struct rdt_domain *d);
int rdt_pseudo_lock_fs_init(struct kernfs_node *root);
void rdt_pseudo_lock_fs_remove(void);
int rdt_pseudo_lock_mkdir(const char *name, umode_t mode);
diff --git a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c
index c859ff7dea6e..9c0f002c08ea 100644
--- a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c
+++ b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c
@@ -273,6 +273,25 @@ static void pseudo_lock_region_kn_unlock(struct kernfs_node *kn)
}

/**
+ * cbm_pseudo_locked - Test if all or portion of CBM is pseudo-locked
+ * @cbm: bitmask to be tested
+ * @d: rdt_domain for which @cbm was provided
+ *
+ * RETURNS:
+ * True if bits from @cbm intersects with what has been pseudo-locked in
+ * rdt_domain @d, false otherwise.
+ */
+bool cbm_pseudo_locked(unsigned long cbm, struct rdt_domain *d)
+{
+ if (d->plr &&
+ bitmap_intersects(&cbm, (unsigned long *)&d->plr->cbm,
+ d->plr->r->cache.cbm_len))
+ return true;
+
+ return false;
+}
+
+/**
* pseudo_lock_avail_get - return bitmask of cache available for locking
* @r: resource to which this cache instance belongs
* @d: domain representing the cache instance
--
2.13.5