mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-28 12:31:04 +00:00
Merge pull request #5984 from dcantah/schedcore-nonlinux
schedcore: Make buildable on !linux
This commit is contained in:
commit
31abe170fc
@ -5,10 +5,6 @@
|
|||||||
|
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PidType is the type of provided pid value and how it should be treated
|
// PidType is the type of provided pid value and how it should be treated
|
||||||
type PidType int
|
type PidType int
|
||||||
|
|
||||||
@ -24,13 +20,3 @@ const (
|
|||||||
// ProcessGroup affects all processes in the group
|
// ProcessGroup affects all processes in the group
|
||||||
ProcessGroup PidType = pidTypeProcessGroupId
|
ProcessGroup PidType = pidTypeProcessGroupId
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create a new sched core domain
|
|
||||||
func Create(t PidType) error {
|
|
||||||
return unix.Prctl(unix.PR_SCHED_CORE, unix.PR_SCHED_CORE_CREATE, 0, uintptr(t), 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ShareFrom shares the sched core domain from the provided pid
|
|
||||||
func ShareFrom(pid uint64, t PidType) error {
|
|
||||||
return unix.Prctl(unix.PR_SCHED_CORE, unix.PR_SCHED_CORE_SHARE_FROM, uintptr(pid), uintptr(t), 0)
|
|
||||||
}
|
|
||||||
|
20
src/runtime/pkg/utils/schedcore_linux.go
Normal file
20
src/runtime/pkg/utils/schedcore_linux.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (c) 2023 Apple Inc.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create a new sched core domain
|
||||||
|
func Create(t PidType) error {
|
||||||
|
return unix.Prctl(unix.PR_SCHED_CORE, unix.PR_SCHED_CORE_CREATE, 0, uintptr(t), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShareFrom shares the sched core domain from the provided pid
|
||||||
|
func ShareFrom(pid uint64, t PidType) error {
|
||||||
|
return unix.Prctl(unix.PR_SCHED_CORE, unix.PR_SCHED_CORE_SHARE_FROM, uintptr(pid), uintptr(t), 0)
|
||||||
|
}
|
22
src/runtime/pkg/utils/schedcore_other.go
Normal file
22
src/runtime/pkg/utils/schedcore_other.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (c) 2023 Apple Inc.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
//go:build !linux
|
||||||
|
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create a new sched core domain
|
||||||
|
func Create(t PidType) error {
|
||||||
|
return errors.New("schedcore not available on non-Linux platforms")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShareFrom shares the sched core domain from the provided pid
|
||||||
|
func ShareFrom(pid uint64, t PidType) error {
|
||||||
|
return errors.New("schedcore not available on non-Linux platforms")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user