kernel/thread: Fix behavior of {get|set}_thread_affinity.
* Handle threads without masks: this means they can run on any CPU. * Return only enabled CPUs from get_thread_affinity. * Clear the user mask's extra bits. * Allow masks with more CPUs set than are active, same as Linux, but disallow masks with no intersection with the active CPUs. * If setting to all enabled CPUs, clear the mask, so that if more CPUs are enabled in the future, this can run on them too. * Add permissions checks. Fixes #20251. (cherry picked from commit f46b3483057b149179dda7abdcc2dde38994a8cc) Change-Id: Ib8649cb0a252fc8d9cfca691c2e03748561db741 Reviewed-on: https://review.haiku-os.org/c/haiku/+/11529 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
a08764fd75
commit
c12c2d4488
@@ -58,10 +58,12 @@ public:
|
||||
|
||||
inline bool Matches(const CPUSet& mask) const;
|
||||
inline CPUSet And(const CPUSet& mask) const;
|
||||
inline bool operator==(const CPUSet& other) const;
|
||||
|
||||
inline bool IsEmpty() const;
|
||||
|
||||
inline uint32 Bits(uint32 index) const { return fBitmap[index];}
|
||||
|
||||
private:
|
||||
static const int kArrayBits = 32;
|
||||
static const int kArraySize = ROUNDUP(SMP_MAX_CPUS, kArrayBits) / kArrayBits;
|
||||
@@ -199,6 +201,18 @@ CPUSet::Matches(const CPUSet& mask) const
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
CPUSet::operator==(const CPUSet& other) const
|
||||
{
|
||||
for (int i = 0; i < kArraySize; i++) {
|
||||
if (fBitmap[i] != other.fBitmap[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
CPUSet::IsEmpty() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user