Hi Dietmar,
On 17-01-19 17:54:19, Dietmar Eggemann wrote:
Hi Olav and Stephen,
I'm using a similar implementation for restricting the cpuset per phase. I ran your patch on https://github.com/scheduler-tools/rt-app.git master.
On 12/01/17 19:28, Stephen Boyd wrote:
From: Olav Haugan ohaugan@codeaurora.org
Allow setting of cpusets at all levels of the spec.
Signed-off-by: Olav Haugan ohaugan@codeaurora.org Signed-off-by: Stephen Boyd stephen.boyd@linaro.org
[...]
+static void set_thread_affinity(thread_data_t *data, cpu_data_t *cpu_data) +{
- int ret;
- cpu_data_t *actual_cpu_data = &data->cpu_data;
- if (data->def_cpu_data.cpuset == NULL) {
/* Get default affinity */
cpu_set_t cpuset;
unsigned int cpu_count;
unsigned int cpu = 0;
ret = pthread_getaffinity_np(pthread_self(),
sizeof(cpu_set_t), &cpuset);
if (ret != 0) {
errno = ret;
perror("pthread_get_affinity");
exit(EXIT_FAILURE);
}
cpu_count = CPU_COUNT(&cpuset);
data->def_cpu_data.cpusetsize = CPU_ALLOC_SIZE(cpu_count);
data->def_cpu_data.cpuset = CPU_ALLOC(cpu_count);
memcpy(data->def_cpu_data.cpuset, &cpuset,
data->def_cpu_data.cpusetsize);
create_cpuset_str(&data->def_cpu_data);
data->curr_cpu_data = &data->def_cpu_data;
- }
- /* Order of preference:
* 1. Phase cpuset
* 2. Global cpuset
* 3. Default cpuset
Does Global mean here "global" config or "tasks" level? When I use
{ "global": { "calibration": 329, "duration": -1, "cpus": [1], }, "tasks": { "task0": { "loop": 2, "phases": { "p1": { "loop": 10, "run": 1000, "timer": { "period": 16000, "ref": "task0" } }, "p2": { "loop": 10, "run": 8000, "cpus": [8], "timer": { "period": 16000, "ref": "task0" } }, }, } } }
I get
root@juno:/# rt-app ~/test2.json [rt-app] <notice> pLoad = 329ns [rt-app] <notice> [0] Using SCHED_OTHER policy with priority 0 [rt-app] <notice> [0] starting thread ...
[rt-app] <notice> [0] setting cpu affinity to CPU(s) [ 8 ] [rt-app] <notice> [0] setting cpu affinity to CPU(s) [ 0, 1, 2, 3, 4, 5 ] [rt-app] <notice> [0] setting cpu affinity to CPU(s) [ 8 ] [rt-app] <notice> [0] Exiting.
But when I use:
{ "global": { "calibration": 329, "duration": -1, }, "tasks": { "task0": { "loop": 2, "cpus": [2], "phases": { "p1": { "loop": 10, "run": 1000, "timer": { "period": 16000, "ref": "task0" } }, "p2": { "loop": 10, "run": 8000, "cpus": [8], "timer": { "period": 16000, "ref": "task0" } }, }, } } }
I get:
root@juno:/# rt-app ~/test2.json [rt-app] <notice> pLoad = 329ns [rt-app] <notice> [0] Using SCHED_OTHER policy with priority 0 [rt-app] <notice> [0] starting thread ...
[rt-app] <notice> [0] setting cpu affinity to CPU(s) [ 2 ] [rt-app] <notice> [0] setting cpu affinity to CPU(s) [ 8 ] [rt-app] <notice> [0] setting cpu affinity to CPU(s) [ 2 ] [rt-app] <notice> [0] setting cpu affinity to CPU(s) [ 8 ] [rt-app] <notice> [0] Exiting.
[...]
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?
1. phase cpuset 2. task level cpuset 3. Default cpuset