-
Notifications
You must be signed in to change notification settings - Fork 5
barrier: Add smp_cond_load_*_timeout() #6232
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: bpf-next_base
Are you sure you want to change the base?
barrier: Add smp_cond_load_*_timeout() #6232
Conversation
|
Upstream branch: f9db3a3 |
2991dd5 to
583dec7
Compare
|
Upstream branch: 8842732 |
1306e5f to
f0affdf
Compare
|
Upstream branch: 8842732 |
f0affdf to
92c4c09
Compare
583dec7 to
e224139
Compare
|
Upstream branch: 23f852d |
92c4c09 to
a38b0d2
Compare
e224139 to
1f11231
Compare
|
Upstream branch: 54c134f |
a38b0d2 to
fc13004
Compare
1f11231 to
2563a04
Compare
|
Upstream branch: 9f317bd |
fc13004 to
c34cb06
Compare
2563a04 to
b8a9697
Compare
|
Upstream branch: 54c134f |
c34cb06 to
31faea3
Compare
b8a9697 to
0ff1d70
Compare
Add smp_cond_load_relaxed_timeout(), which extends smp_cond_load_relaxed() to allow waiting for a duration. The waiting loop uses cpu_poll_relax() to wait on the condition variable with a periodic evaluation of a time-check. cpu_poll_relax() unless overridden by the arch code, amounts to a cpu_relax(). The number of times we spin is defined by SMP_TIMEOUT_POLL_COUNT (chosen to be 200 by default) which, assuming each cpu_poll_relax() iteration takes around 20-30 cycles (measured on a variety of x86 platforms), for a total of ~4000-6000 cycles. Cc: Arnd Bergmann <[email protected]> Cc: Will Deacon <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Reviewed-by: Catalin Marinas <[email protected]> Reviewed-by: Haris Okanovic <[email protected]> Tested-by: Haris Okanovic <[email protected]> Signed-off-by: Ankur Arora <[email protected]> Reviewed-by: Christoph Lameter (Ampere) <[email protected]>
Support waiting in smp_cond_load_relaxed_timeout() via __cmpwait_relaxed(). Limit this to when the event-stream is enabled, to ensure that we wake from WFE periodically and don't block forever if there are no stores to the cacheline. In the unlikely event that the event-stream is unavailable, fallback to spin-waiting. Also set SMP_TIMEOUT_POLL_COUNT to 1 so we do the time-check for each iteration in smp_cond_load_relaxed_timeout(). Cc: [email protected] Cc: Catalin Marinas <[email protected]> Suggested-by: Will Deacon <[email protected]> Signed-off-by: Ankur Arora <[email protected]>
…ait() In preparation for defining smp_cond_load_acquire_timeout(), remove the private copy. Lacking this, the rqspinlock code falls back to using smp_cond_load_acquire(). Cc: Kumar Kartikeya Dwivedi <[email protected]> Cc: Alexei Starovoitov <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Reviewed-by: Haris Okanovic <[email protected]> Signed-off-by: Ankur Arora <[email protected]>
|
Upstream branch: e2e668b |
Add the acquire variant of smp_cond_load_relaxed_timeout(). This reuses the relaxed variant, with an additional LOAD->LOAD ordering. Cc: Arnd Bergmann <[email protected]> Cc: Will Deacon <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Reviewed-by: Catalin Marinas <[email protected]> Reviewed-by: Haris Okanovic <[email protected]> Tested-by: Haris Okanovic <[email protected]> Signed-off-by: Ankur Arora <[email protected]>
Add atomic load wrappers, atomic_cond_read_*_timeout() and atomic64_cond_read_*_timeout() for the cond-load timeout interfaces. Cc: Will Deacon <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Boqun Feng <[email protected]> Signed-off-by: Ankur Arora <[email protected]>
Switch out the conditional load interfaces used by rqspinlock to atomic_cond_read_acquire_timeout(), and smp_cond_read_acquire_timeout(). Both these handle the timeout and amortize as needed, so use check_timeout() directly. Also, when using spin-wait implementations, redefine SMP_TIMEOUT_POLL_COUNT to be 16k to be similar to the spin-count used in RES_CHECK_TIMEOUT(). Cc: Kumar Kartikeya Dwivedi <[email protected]> Cc: Alexei Starovoitov <[email protected]> Signed-off-by: Ankur Arora <[email protected]>
The inner loop in poll_idle() polls over the thread_info flags, waiting to see if the thread has TIF_NEED_RESCHED set. The loop exits once the condition is met, or if the poll time limit has been exceeded. To minimize the number of instructions executed in each iteration, the time check is done only intermittently (once every POLL_IDLE_RELAX_COUNT iterations). In addition, each loop iteration executes cpu_relax() which on certain platforms provides a hint to the pipeline that the loop busy-waits, allowing the processor to reduce power consumption. This is close to what smp_cond_load_relaxed_timeout() provides. So, restructure the loop and fold the loop condition and the timeout check in smp_cond_load_relaxed_timeout(). Cc: "Rafael J. Wysocki" <[email protected]> Cc: Daniel Lezcano <[email protected]> Signed-off-by: Ankur Arora <[email protected]> Reviewed-by: Christoph Lameter (Ampere) <[email protected]>
31faea3 to
2771a34
Compare
75ba762 to
385f65b
Compare
Pull request for series with
subject: barrier: Add smp_cond_load_*_timeout()
version: 7
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1016554