mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-29 13:26:45 -04:00
unix: add CPUSetDynamic for systems with more than 1024 CPUs
The existing CPUSet type is a fixed-size array limited to 1024 CPUs, which makes it problematic to use for large systems (such as Google's X4 instances with 1440 and 1920 vCPUs), see e.g. https://github.com/opencontainers/runc/issues/5023. Introduce CPUSetDynamic type and NewCPUSet constructor to support large systems. The bit-managing routines (set/clear/isset/fill/count) are separated and reused. Add variants of SchedGetaffinity, SchedSetaffinity and SetMemPolicy that accept the new type. Amend the documentation for CPUSet. Amend the existing TestSchedSetaffinity to: - test set.Fill; - use t.Cleanup to restore the affinity. Add tests for new functionality (mostly a copy of existing tests). This is an alternative to CL 727540 / CL 727541. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Change-Id: I51bba0305b8dfa7a88a4e7fb8758d73f798574f1 Reviewed-on: https://go-review.googlesource.com/c/sys/+/735380 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
committed by
Kirill Kolyshkin
co-authored by
Claude Sonnet 4.5
parent
f33a730cd0
commit
690c91f6ec
@@ -2644,8 +2644,12 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) {
|
||||
//sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error)
|
||||
//sys Mseal(b []byte, flags uint) (err error)
|
||||
|
||||
//sys setMemPolicy(mode int, mask *CPUSet, size int) (err error) = SYS_SET_MEMPOLICY
|
||||
//sys setMemPolicy(mode int, mask unsafe.Pointer, size uintptr) (err error) = SYS_SET_MEMPOLICY
|
||||
|
||||
func SetMemPolicy(mode int, mask *CPUSet) error {
|
||||
return setMemPolicy(mode, mask, _CPU_SETSIZE)
|
||||
return setMemPolicy(mode, unsafe.Pointer(mask), _CPU_SETSIZE)
|
||||
}
|
||||
|
||||
func SetMemPolicyDynamic(mode int, mask CPUSetDynamic) error {
|
||||
return setMemPolicy(mode, mask.pointer(), mask.size())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user