On 21/01/17 01:32, Olav Haugan wrote:
Hi Dietmar,
On 17-01-19 17:54:19, Dietmar Eggemann wrote:
Hi Olav and Stephen,
[...]
Realized that "global" is not the right description. By global I meant at the task level. So you can specify either inside the phase (not supported before) or at task level (existing behavior). The example above is what I intended to support. Do you want me to change the description to say task level?
- phase cpuset
- task level cpuset
- Default cpuset
Would be nice. BTW, where do we document these changes for the humble rt-app user?
Another thing, by default we spit out a <notice> level log for each phase we change the affinity. Can we make this less noisy?
Couldn't you call parse_cpuset_data() from inside parse_thread_phase_data() instead of parse_thread_data() (for each phases or phase0)?
diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c index 63f69b0c3a15..e58f62982e50 100644 --- a/src/rt-app_parse_config.c +++ b/src/rt-app_parse_config.c @@ -596,6 +596,36 @@ obj_is_event(char *name) return 0; }
+static void parse_cpuset_data(struct json_object *obj, cpu_data_t *data) +{ + struct json_object *cpuset_obj, *cpu; + + /* cpuset */ + cpuset_obj = get_in_object(obj, "cpus", TRUE); + if (cpuset_obj) { + struct array_list *cpuset; + unsigned int i; + unsigned int cpu_idx; + + assure_type_is(cpuset_obj, obj, "cpus", json_type_array); + data->cpuset_str = strdup(json_object_to_json_string(cpuset_obj)); + data->cpusetsize = sizeof(cpu_set_t); + data->cpuset = malloc(data->cpusetsize); + cpuset = json_object_get_array(cpuset_obj); + CPU_ZERO(data->cpuset); + for (i = 0; i < json_object_array_length(cpuset_obj); i++) { + cpu = json_object_array_get_idx(cpuset_obj, i); + cpu_idx = json_object_get_int(cpu); + CPU_SET(cpu_idx, data->cpuset); + } + } else { + data->cpuset_str = strdup("-"); + data->cpuset = NULL; + data->cpusetsize = 0; + } + log_info(PIN "key: cpus %s", data->cpuset_str); +} + static void parse_thread_phase_data(struct json_object *obj, phase_data_t *data, rtapp_options_t *opts, long tag) @@ -629,36 +659,9 @@ parse_thread_phase_data(struct json_object *obj, i++; } } -} - -static void parse_cpuset_data(struct json_object *obj, cpu_data_t *data) -{ - struct json_object *cpuset_obj, *cpu;
/* cpuset */ - cpuset_obj = get_in_object(obj, "cpus", TRUE); - if (cpuset_obj) { - struct array_list *cpuset; - unsigned int i; - unsigned int cpu_idx; - - assure_type_is(cpuset_obj, obj, "cpus", json_type_array); - data->cpuset_str = strdup(json_object_to_json_string(cpuset_obj)); - data->cpusetsize = sizeof(cpu_set_t); - data->cpuset = malloc(data->cpusetsize); - cpuset = json_object_get_array(cpuset_obj); - CPU_ZERO(data->cpuset); - for (i = 0; i < json_object_array_length(cpuset_obj); i++) { - cpu = json_object_array_get_idx(cpuset_obj, i); - cpu_idx = json_object_get_int(cpu); - CPU_SET(cpu_idx, data->cpuset); - } - } else { - data->cpuset_str = strdup("-"); - data->cpuset = NULL; - data->cpusetsize = 0; - } - log_info(PIN "key: cpus %s", data->cpuset_str); + parse_cpuset_data(obj, &data->cpu_data); }
static void @@ -742,7 +745,6 @@ parse_thread_data(char *name, struct json_object *obj, int index, foreach(phases_obj, entry, key, val, idx) { log_info(PIN "Parsing phase %s", key); parse_thread_phase_data(val, &data->phases[idx], opts, (long)data); - parse_cpuset_data(val, &data->phases[idx].cpu_data); }
/* Get loop number */ @@ -752,7 +754,6 @@ parse_thread_data(char *name, struct json_object *obj, int index, data->nphases = 1; data->phases = malloc(sizeof(phase_data_t) * data->nphases); parse_thread_phase_data(obj, &data->phases[0], opts, (long)data); - parse_cpuset_data(obj, &data->phases[0].cpu_data); /* Get loop number */ data->loop = 1; }