-
Notifications
You must be signed in to change notification settings - Fork 81
sem_wait/trywait: retry again if fail but old still same. #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
If atomic_try_cmpxchg_xxxx runs on LL/SC architectures (e.g.ARMv7, ARMv8, RISC-V), the weak CAS expands to a single LDREX/STREX pair. If the CPU takes an IRQ/FIQ/SVC between the two instructions, hardware performs an implicit CLREX and the following STREX returns 1, therefore atomic_try_cmpxchg_xxxx return failure even though *addr* still holds the expected value. So let's retry atomic_try_cmpxchg_xxxx in this case. Signed-off-by: buxiasen <[email protected]>
|
Hi jasonbu, Hi jasonbu, |
hi, Try_wait API should be performance sensitive, exchange_weak should able to cover most scene. |
Hi jasonbu,感谢您在 openvela 仓库中对 在仔细查看您提交中使用 核心背景:
|
Summary
If atomic_try_cmpxchg_xxxx runs on LL/SC architectures (e.g.ARMv7, ARMv8, RISC-V), the weak CAS expands to a single LDREX/STREX pair.
If the CPU takes an IRQ/FIQ/SVC between the two instructions, hardware performs an implicit CLREX and the following STREX returns 1, therefore atomic_try_cmpxchg_xxxx return failure even though addr still holds the expected value.
So let's retry atomic_try_cmpxchg_xxxx in this case.
Impact
Before patch, will abort by ostest especially if we disabled the tickless and a loop for try wait.
After patch, will no longer abort by try-wait case.
Testing
CI-test, arm-v8m board test.
在ostest循环压测的时候如果没有开启tickless, 会偶现第一次 mutex init之后就wait失败,经过分析rootcause是部分arch的CAS指令会被中断打断。
修改之后问题不再复现
问题在 #267 同样被提及。
该patch用于修复该问题。后续patch会继续针对信号量/互斥量进行继续优化。