mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-26 14:17:26 -04:00
smp: Make control dependencies work on Alpha, improve documentation
The current formulation of control dependencies fails on DEC Alpha, which does not respect dependencies of any kind unless an explicit memory barrier is provided. This means that the current fomulation of control dependencies fails on Alpha. This commit therefore creates a READ_ONCE_CTRL() that has the same overhead on non-Alpha systems, but causes Alpha to produce the needed ordering. This commit also applies READ_ONCE_CTRL() to the one known use of control dependencies. Use of READ_ONCE_CTRL() also has the beneficial effect of adding a bit of self-documentation to control dependencies. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
This commit is contained in:
parent
81e701e437
commit
5af4692a75
3 changed files with 50 additions and 23 deletions
|
@ -252,6 +252,22 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
|
|||
#define WRITE_ONCE(x, val) \
|
||||
({ typeof(x) __val = (val); __write_once_size(&(x), &__val, sizeof(__val)); __val; })
|
||||
|
||||
/**
|
||||
* READ_ONCE_CTRL - Read a value heading a control dependency
|
||||
* @x: The value to be read, heading the control dependency
|
||||
*
|
||||
* Control dependencies are tricky. See Documentation/memory-barriers.txt
|
||||
* for important information on how to use them. Note that in many cases,
|
||||
* use of smp_load_acquire() will be much simpler. Control dependencies
|
||||
* should be avoided except on the hottest of hotpaths.
|
||||
*/
|
||||
#define READ_ONCE_CTRL(x) \
|
||||
({ \
|
||||
typeof(x) __val = READ_ONCE(x); \
|
||||
smp_read_barrier_depends(); /* Enforce control dependency. */ \
|
||||
__val; \
|
||||
})
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue