kernel/smp: Distinguish CPUSet::GetBit from GetBitAtomic.

I checked all invocations of GetBit; as far as I can tell,
only the two adjusted here in smp.cpp are done while the Set
may be concurrently modified, and even then I don't know
that they really need to be atomics, anyway.
This commit is contained in:
Augustin Cavalier
2026-03-09 20:58:54 -04:00
parent 97a65a027d
commit dd24eecac1
2 changed files with 11 additions and 2 deletions
+9
View File
@@ -54,6 +54,7 @@ public:
inline void ClearBitAtomic(int32 cpu);
inline bool GetBit(int32 cpu) const;
inline bool GetBitAtomic(int32 cpu) const;
inline bool Matches(const CPUSet& mask) const;
inline CPUSet And(const CPUSet& mask) const;
@@ -161,6 +162,14 @@ CPUSet::ClearBitAtomic(int32 cpu)
inline bool
CPUSet::GetBit(int32 cpu) const
{
int32* element = (int32*)&fBitmap[cpu / kArrayBits];
return ((uint32)*element & (1u << (cpu % kArrayBits))) != 0;
}
inline bool
CPUSet::GetBitAtomic(int32 cpu) const
{
int32* element = (int32*)&fBitmap[cpu / kArrayBits];
return ((uint32)atomic_get(element) & (1u << (cpu % kArrayBits))) != 0;