A problem regarding SMP
Thanks for your reply!
By using a barrier to synchronize all evl kthreads, I did achieve the effect of multiple processes running in parallel. My solution is in the next patch, and the branch I tried on is the latest v5.13-evl-rebase.
But I still ran into two other problems while trying this solution.
The first problem is that evl_flag cann't solve the problem. The wait condition in evl_wait_flag_timeout is evl_read_flag, in which the flag is set to false as soon as the flag is found to be raised in evl_raise_flag, so evl_raise_flag can only wake up one waiting process at a time. And it's not possible to wake up more processes by calling evl_raise_flag multiple times, because it's not possible to determine the time when processes are woken up in the SMP environment. If we did, it's possible to have a situation where two processes are woken up at the same time after the flag was raised twice, and then only one of them can be woken up at the same time. So in light of this, I defined two new functions, evl_wait_flag_same and evl_wait_flag_timeout_same, to read flags using evl_peek_flag.
The second problem is that after using barrier, load balancing is no longer possible when creating processes using kthread_run, which is called in evl_run_kthread. The phenomenon is that all processes are created on the same CPU. Therefore, I can only specify CPUs manually for load balancing purpose by calling evl_run_kthread_on_cpu.
The code I tried is available in the next patch. Is there anything we can do about these two problems?
Best regards,
Jiajun
Quoted 9 lines · JiajunDu
Thanks for your reply!
By using a barrier to synchronize all evl kthreads, I did achieve the effect of multiple processes running in parallel. My solution is in the next patch, and the branch I tried on is the latest
v5.13-evl-rebase.But I still ran into two other problems while trying this solution.
Quoted 12 lines
The first problem is that
evl_flagcann't solve the problem. The wait condition inevl_wait_flag_timeoutisevl_read_flag, in which the flag is set to false as soon as the flag is found to be raised inevl_raise_flag, soevl_raise_flagcan only wake up one waiting process at a time. And it's not possible to wake up more processes by callingevl_raise_flagmultiple times, because it's not possible to determine the time when processes are woken up in the SMP environment. If we did, it's possible to have a situation where two processes are woken up at the same time after the flag was raised twice, and then only one of them can be woken up at the same time. So in light of this, I defined two new functions,evl_wait_flag_sameandevl_wait_flag_timeout_same, to read flags usingevl_peek_flag.
The semantics you are looking for are available from evl_wait_queue, which basically implements a condition variable.
Quoted 6 lines
The second problem is that after using barrier, load balancing is no longer possible when creating processes using
kthread_run, which is called inevl_run_kthread. The phenomenon is that all processes are created on the same CPU. Therefore, I can only specify CPUs manually for load balancing purpose by callingevl_run_kthread_on_cpu.
Which is not an issue, is it? Since dynamic load balancing is not supported by design by evl (or any earlier xenomai cores for that matter), static pinning is the way. So evl_run_kthread_on_cpu should indeed be used. Another option would be that each spawned kthread pins itself to the right CPU when emerging (set_cpus_allowed).
Quoted 6 lines
The code I tried is available in the next patch. Is there anything we can do about these two problems?
Best regards,
Jiajun
Signature · 1 line
Philippe.
Quoted 24 lines · Philippe Gerum
Quoted 9 lines · JiajunDu
Thanks for your reply!
By using a barrier to synchronize all evl kthreads, I did achieve the effect of multiple processes running in parallel. My solution is in the next patch, and the branch I tried on is the latest
v5.13-evl-rebase.But I still ran into two other problems while trying this solution.
Quoted 12 lines
The first problem is that
evl_flagcann't solve the problem. The wait condition inevl_wait_flag_timeoutisevl_read_flag, in which the flag is set to false as soon as the flag is found to be raised inevl_raise_flag, soevl_raise_flagcan only wake up one waiting process at a time. And it's not possible to wake up more processes by callingevl_raise_flagmultiple times, because it's not possible to determine the time when processes are woken up in the SMP environment. If we did, it's possible to have a situation where two processes are woken up at the same time after the flag was raised twice, and then only one of them can be woken up at the same time. So in light of this, I defined two new functions,evl_wait_flag_sameandevl_wait_flag_timeout_same, to read flags usingevl_peek_flag.
Quoted 2 lines
The semantics you are looking for are available from
evl_wait_queue, which basically implements a condition variable.
This said, I agree that the current implementation of evl_wait_flag() prevents broadcast, which is wrong.
Signature · 1 line
Philippe.
Ok, thanks for your reply. Now I understand.
Best regards,
Jiajun
Quoted 4 lines · JiajunDu
Ok, thanks for your reply. Now I understand.
Best regards,
Jiajun
You do have another option beyond the flag which is restricted to unicast for the time being, which is using an evl (kernel) semaphore, depleted at init:
evl_init_ksem(&ksem, 0);
...evl_down(&ksem); /* kthread */
...evl_broadcast(&ksem); /* master (spawner) */
Signature · 1 line
Philippe.