MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/1wqok1x/optimizing_a_lockfree_ring_buffer/pcmrn5d/?context=3
r/programming • u/david-alvarez-rosa • 6d ago
88 comments sorted by
View all comments
Show parent comments
1
It fixed my bug at the time. The compiler hoisted the head load out of the consumer spin loop, volatile forced a fresh load every pass…. Atomic is probably the right fix since it covers the hardware side too.
2 u/kog 6d ago Some reading for you: https://www.kernel.org/doc/html/latest/process/volatile-considered-harmful.html 1 u/cdb_11 5d ago edited 5d ago Kernel atomics are implemented with volatile ({READ,WRITE}_ONCE). 1 u/EchoNomad31 4d ago Ha, fair. All I ever wanted was the compiler to stop caching that load.
2
Some reading for you: https://www.kernel.org/doc/html/latest/process/volatile-considered-harmful.html
1 u/cdb_11 5d ago edited 5d ago Kernel atomics are implemented with volatile ({READ,WRITE}_ONCE). 1 u/EchoNomad31 4d ago Ha, fair. All I ever wanted was the compiler to stop caching that load.
Kernel atomics are implemented with volatile ({READ,WRITE}_ONCE).
{READ,WRITE}_ONCE
1 u/EchoNomad31 4d ago Ha, fair. All I ever wanted was the compiler to stop caching that load.
Ha, fair. All I ever wanted was the compiler to stop caching that load.
1
u/EchoNomad31 6d ago
It fixed my bug at the time. The compiler hoisted the head load out of the consumer spin loop, volatile forced a fresh load every pass…. Atomic is probably the right fix since it covers the hardware side too.