Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[arch][riscv] general riscv spinlock cleanup
-Hard set the spinlock type to uint32_t to be clearer -Switch the free/held value to a simple 0 or 1 Previously, was writing the current cpu number into the spinlock, which was only useful for debugging purposes. However, since the atomic operation was an amoswap instead of a proper CAS, it would end up overwriting the old cpu number with the new cpu number when it tried to take it. It would still work as a spinlock, since the value was !0, but it was falsely tracking which cpu actually held it. To keep it simple, just switch to 0/1 and stick with the amoswap instruction, which is much more efficient than a LR/SC pair to implement CAS on riscv. Internally still use an unsigned long for the old value, since the amoswap instruction overwrites the entire Rd register, and thus keeps the codegen efficient since it wont try to sign extend it for any comparisons afterwards. Thanks @loqoman ([email protected]) for catching this one.
- Loading branch information