commit 5da8e47d849d3d37b14129f038782a095b9ad049
Author: Jeffy Chen<jeffy.chen@xxxxxxxxxxxxxx>
Date: Tue Jun 27 17:34:44 2017 +0800
Bluetooth: hidp: fix possible might sleep error in hidp_session_thread
that*some* kind of barrier was stuck in there simply as a response to
comments like this, that were going away:
- *
- * Note: set_current_state() performs any necessary
- * memory-barriers for us.
*/
- set_current_state(TASK_INTERRUPTIBLE);
+ /* Ensure session->terminate is updated */
+ smp_mb__before_atomic();
It was probably an attempt to fill in the gap for the
set_current_state() (and comment) which was being removed. I believe
Jeffy originally added more barriers in other places, but I convinced
him not to.
I have to say, I'm not really up-to-speed on the use of manual barriers
in Linux (it's much preferable when they're wrapped into higher-level
data structures already), but I believe the main intention here is to
ensure that any change to 'terminate' that happened during the previous
"wait_woken()" would be visible to our atomic_read().
Looking into wait_woken(), I'm feeling like none of these additional
barriers are necessary at all. I believe wait_woken() handles the
visibility issues we care about (that if we were woken for termination,
we'll see the terminating condition).