r2.12 cherry-pick: 890a846bdc2 "[xla:gpu] Create a non-atomically upgradeable reader mutex lock that acquires and releases the lock via RAII"
Refer to the original commit: https://github.com/tensorflow/tensorflow/commit/890a846bdc26e0e1e66120adb1e2fb2aa33c7323