summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8be4f03)
raw | patch | inline | side by side (parent: 8be4f03)
author | spshykX <serhiyx.pshyk@intel.com> | |
Tue, 21 Mar 2017 10:13:55 +0000 (10:13 +0000) | ||
committer | spshykX <serhiyx.pshyk@intel.com> | |
Tue, 21 Mar 2017 10:13:55 +0000 (10:13 +0000) |
Change-Id: Ia009635c93e1cecd9852326b01c62fc6d2b090b5
Signed-off-by: Serhiy Pshyk <serhiyx.pshyk@intel.com>
Signed-off-by: Serhiy Pshyk <serhiyx.pshyk@intel.com>
src/intel_rdt.c | patch | blob | history |
diff --git a/src/intel_rdt.c b/src/intel_rdt.c
index e2e2e3940260580bb640dfec4da764f710821e0c..fc2a5f1791e49775370b792fbfb3bdac9f16461c 100644 (file)
--- a/src/intel_rdt.c
+++ b/src/intel_rdt.c
* `item' Config option containing core groups.
* `groups' Table of core groups to set values in.
* `max_groups' Maximum number of core groups allowed.
- * `max_core' Maximum allowed core value.
*
* RETURN VALUE
* On success, the number of core groups set up. On error, appropriate
* negative error value.
*/
static int oconfig_to_cgroups(oconfig_item_t *item, rdt_core_group_t *groups,
- size_t max_groups, uint64_t max_core) {
+ size_t max_groups) {
int index = 0;
assert(groups != NULL);
return (-EINVAL);
}
- for (int i = 0; i < n; i++) {
- if (cores[i] > max_core) {
- ERROR(RDT_PLUGIN ": Core group (%s) contains invalid core id (%d)",
- item->values[j].value.string, (int)cores[i]);
- return (-EINVAL);
- }
- }
-
/* set core group info */
ret = cgroup_set(&groups[index], item->values[j].value.string, cores, n);
if (ret < 0)
return g_rdt->pqos_cpu->num_cores;
}
+static int rdt_is_core_id_valid(int core_id) {
+
+ for (int i = 0; i < g_rdt->pqos_cpu->num_cores; i++)
+ if (core_id == g_rdt->pqos_cpu->cores[i].lcore)
+ return 1;
+
+ return 0;
+}
+
static int rdt_config_cgroups(oconfig_item_t *item) {
int n = 0;
enum pqos_mon_event events = 0;
DEBUG(RDT_PLUGIN ": [%d]: %s", j, item->values[j].value.string);
}
- n = oconfig_to_cgroups(item, g_rdt->cgroups, RDT_MAX_CORES,
- g_rdt->pqos_cpu->num_cores - 1);
+ n = oconfig_to_cgroups(item, g_rdt->cgroups, g_rdt->pqos_cpu->num_cores);
if (n < 0) {
rdt_free_cgroups();
ERROR(RDT_PLUGIN ": Error parsing core groups configuration.");
return (-EINVAL);
}
+ /* validate configured core id values */
+ for (int group_idx = 0; group_idx < n; group_idx++) {
+ for (int core_idx = 0; core_idx < g_rdt->cgroups[group_idx].num_cores;
+ core_idx++) {
+ if (!rdt_is_core_id_valid(g_rdt->cgroups[group_idx].cores[core_idx])) {
+ ERROR(RDT_PLUGIN ": Core group '%s' contains invalid core id '%d'",
+ g_rdt->cgroups[group_idx].desc,
+ (int)g_rdt->cgroups[group_idx].cores[core_idx]);
+ rdt_free_cgroups();
+ return (-EINVAL);
+ }
+ }
+ }
+
if (n == 0) {
/* create default core groups if "Cores" config option is empty */
n = rdt_default_cgroups();