Re: Why a “barrier()” is enough for disabling or enabling the preemption?
Doug Wilson
doug.lkml at gmail.com
Mon Nov 30 04:36:21 EST 2015
> #define preempt_disable() barrier()
> ......
> #define preempt_enable() barrier()
Let me try answering this with a limited knowledge I have about barriers.
barrier() essentially was added so that compiler reordering does not happen.
In the code above, since the compiler does not know/understand the
specialty of preempt_[enable/disable], the compiler might decide to change
the ordering.
In this case, where the code is disabling/enabling preemption, barrier() tells
the compiler that it can't move stuff around.
I hope this helps.
- Doug
More information about the Kernelnewbies
mailing list