On 12/01/17 19:28, Stephen Boyd wrote:
[...]
@@ -475,20 +578,6 @@ void *thread_body(void *arg) /* Get the 1st phase's data */ pdata = &data->phases[0];
- /* Set thread affinity */
- if (data->cpuset != NULL)
- {
log_notice("[%d] setting cpu affinity to CPU(s) %s", data->ind,
data->cpuset_str);
ret = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t),
data->cpuset);
if (ret < 0) {
s/ret < 0/ret != 0/ ?
[...]
diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c index 83794f35fe97..63f69b0c3a15 100644 --- a/src/rt-app_parse_config.c +++ b/src/rt-app_parse_config.c @@ -631,15 +631,44 @@ parse_thread_phase_data(struct json_object *obj, } } +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);
This allows for situations where the "cpus" field specifies cpus which are not available on the system. A "cpus": [15, 16, 17] on my 16 core systems is not detected as a faulty .json file. We should probe the max core # and compare it within the for loop and bail if we out of range. I guess using a json file on another platform with different topology is a quite common case.
cpuset = json_object_get_array(cpuset_obj);
cpuset is initialized here but never used. Just sent out a patch to fix this on master.
[...]
diff --git a/src/rt-app_types.h b/src/rt-app_types.h index 5b8345fcf6aa..918a2ccc616c 100644 --- a/src/rt-app_types.h +++ b/src/rt-app_types.h @@ -123,10 +123,17 @@ typedef struct _event_data_t { int count; } event_data_t; +typedef struct _cpu_data_t {
- cpu_set_t *cpuset;
- char *cpuset_str;
- size_t cpusetsize;
+} cpu_data_t;
Can we not call this structure _cpuset_data_t since it only contains cpuset related data.
[...]