]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
x86/intel_rdt: Add utilities to test pseudo-locked region possibility
authorReinette Chatre <reinette.chatre@intel.com>
Fri, 22 Jun 2018 22:42:19 +0000 (15:42 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Sat, 23 Jun 2018 11:03:49 +0000 (13:03 +0200)
A pseudo-locked region does not have a class of service associated with
it and thus not tracked in the array of control values maintained as
part of the domain. Even so, when the user provides a new bitmask for
another resource group it needs to be checked for interference with
existing pseudo-locked regions.

Additionally only one pseudo-locked region can be created in any cache
hierarchy.

Introduce two utilities in support of above scenarios: (1) a utility
that can be used to test if a given capacity bitmask overlaps with any
pseudo-locked regions associated with a particular cache instance, (2) a
utility that can be used to test if a pseudo-locked region exists within
a particular cache hierarchy.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: fenghua.yu@intel.com
Cc: tony.luck@intel.com
Cc: vikas.shivappa@linux.intel.com
Cc: gavin.hindman@intel.com
Cc: jithu.joseph@intel.com
Cc: dave.hansen@intel.com
Cc: hpa@zytor.com
Link: https://lkml.kernel.org/r/b8e31dbdcf22ddf71df46072647b47e7558abb32.1529706536.git.reinette.chatre@intel.com
arch/x86/kernel/cpu/intel_rdt.h
arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c

index 338fe47396a5e87cbab049fed67b8f7ce90ab0d4..b5d3ddfa94e66069723c50f74e7954ee91c42bd4 100644 (file)
@@ -503,6 +503,8 @@ enum rdtgrp_mode rdtgroup_mode_by_closid(int closid);
 int rdtgroup_tasks_assigned(struct rdtgroup *r);
 int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp);
 int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp);
+bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, u32 _cbm);
+bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d);
 struct rdt_domain *get_domain_from_cpu(int cpu, struct rdt_resource *r);
 int update_domains(struct rdt_resource *r, int closid);
 void closid_free(int closid);
index ce8243c87877d27e0b456933d7b37611f009f0c4..b145a7386b10b322c6ceb8da3e888efdc4c21aef 100644 (file)
@@ -299,3 +299,77 @@ int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp)
        pseudo_lock_free(rdtgrp);
        return 0;
 }
+
+/**
+ * rdtgroup_cbm_overlaps_pseudo_locked - Test if CBM or portion is pseudo-locked
+ * @d: RDT domain
+ * @_cbm: CBM to test
+ *
+ * @d represents a cache instance and @_cbm a capacity bitmask that is
+ * considered for it. Determine if @_cbm overlaps with any existing
+ * pseudo-locked region on @d.
+ *
+ * Return: true if @_cbm overlaps with pseudo-locked region on @d, false
+ * otherwise.
+ */
+bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, u32 _cbm)
+{
+       unsigned long *cbm = (unsigned long *)&_cbm;
+       unsigned long *cbm_b;
+       unsigned int cbm_len;
+
+       if (d->plr) {
+               cbm_len = d->plr->r->cache.cbm_len;
+               cbm_b = (unsigned long *)&d->plr->cbm;
+               if (bitmap_intersects(cbm, cbm_b, cbm_len))
+                       return true;
+       }
+
+       return false;
+}
+
+/**
+ * rdtgroup_pseudo_locked_in_hierarchy - Pseudo-locked region in cache hierarchy
+ * @d: RDT domain under test
+ *
+ * The setup of a pseudo-locked region affects all cache instances within
+ * the hierarchy of the region. It is thus essential to know if any
+ * pseudo-locked regions exist within a cache hierarchy to prevent any
+ * attempts to create new pseudo-locked regions in the same hierarchy.
+ *
+ * Return: true if a pseudo-locked region exists in the hierarchy of @d or
+ *         if it is not possible to test due to memory allocation issue,
+ *         false otherwise.
+ */
+bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d)
+{
+       cpumask_var_t cpu_with_psl;
+       struct rdt_resource *r;
+       struct rdt_domain *d_i;
+       bool ret = false;
+
+       if (!zalloc_cpumask_var(&cpu_with_psl, GFP_KERNEL))
+               return true;
+
+       /*
+        * First determine which cpus have pseudo-locked regions
+        * associated with them.
+        */
+       for_each_alloc_enabled_rdt_resource(r) {
+               list_for_each_entry(d_i, &r->domains, list) {
+                       if (d_i->plr)
+                               cpumask_or(cpu_with_psl, cpu_with_psl,
+                                          &d_i->cpu_mask);
+               }
+       }
+
+       /*
+        * Next test if new pseudo-locked region would intersect with
+        * existing region.
+        */
+       if (cpumask_intersects(&d->cpu_mask, cpu_with_psl))
+               ret = true;
+
+       free_cpumask_var(cpu_with_psl);
+       return ret;
+}