[roll] Roll fuchsia [thread_sampler] Fix cmp_exch loop for write_state_

Fix up two cmp exchange loops.

1) In SetPendingWrite, we need to recompute `desired` each time, else
   we could end up accidentally set the kPendingTimer bit in the
   following scenario:

- SetPendingWrite reads write_state_ as kPendingTimer | kWritesEnabled
- SetPendingWrite computes `desired` as `kPendingTimer | kWritesEnabled | kPendingWrite`
- << Other Thread >> Something resets kPendingTimer
- SendPendingWrite fails the cmpexchange, reloads write_state, but
  doesn't recompute `desired`, causing it to write an incorrect value.

2) SetTimer has a similar issue where it doesn't recompute `desired`.

However, I do not believe that these are the direct cause of the linked
bug.

SetTimer and SetPendingWrite must run on the same CPU,
SetPendingWrite is only called with interrupts disabled, and SetTimer also is only called during interrupt context. Those are
the only locations that set the kPendingWrite bit (every other location that writes write_state_ does a fetch_or bitmask with a different bit offset). Thus, I don't see how either of these issues could cause a race setting the kPendingWrite bit.

However, putting this up regardless since the code is, if not incorrect, a footgun waiting to happen, and fixing this will help reduce uncertainty about the actual cause of the bug.

Original-Bug: 392888672
Original-Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1243124
Original-Revision: 570efcc22bb857ca38cfa26b39f9084458be4c3c
GitOrigin-RevId: 0b748bff54f895b4198a56d5064e75228563e7c3
Change-Id: I6d17883adfa08bd92e38f6e43684e1e81c315fff
1 file changed
tree: 942bb1e676b0e19d27b6cbf6bec5fb431795772d
  1. ctf/
  2. git-hooks/
  3. infra/
  4. third_party/
  5. cts
  6. firmware
  7. flower
  8. jiri.lock
  9. MILESTONE
  10. minimal
  11. prebuilts
  12. README.md
  13. stem
  14. test_durations
  15. toolchain
README.md

Integration

This repository contains Fuchsia's Global Integration manifest files.

Making changes

All changes should be made to the internal version of this repository. Our infrastructure automatically updates this version when the internal one changes.

Currently all changes must be made by a Google employee. Non-Google employees wishing to make a change can ask for assistance in one of the communication channels documented at get involved.

Obtaining the source

First install Jiri.

Next run:

$ jiri init
$ jiri import minimal https://fuchsia.googlesource.com/integration
$ jiri update

Third party

Third party projects should have their own subdirectory in ./third_party.