Skip to content

Commit

Permalink
attempt2
Browse files Browse the repository at this point in the history
Signed-off-by: Kirtana Ashok <[email protected]>
  • Loading branch information
kiashok committed Jun 12, 2024
1 parent a952a6a commit bf85e4f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions internal/hcsoci/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"os"
"path/filepath"
"strconv"
"unsafe"

"github.com/Microsoft/go-winio/pkg/guid"
"github.com/Microsoft/hcsshim/internal/cow"
Expand Down Expand Up @@ -331,7 +330,8 @@ func setCPUAffinityOnJobObject(ctx context.Context, spec *specs.Spec, computeSys
info := make([]winapi.JOBOBJECT_CPU_GROUP_AFFINITY, len(spec.Windows.Resources.CPU.AffinityCPUs))

for i, cpu := range spec.Windows.Resources.CPU.AffinityCPUs {
info[i].CpuMask = (uintptr)(unsafe.Pointer(&cpu.CPUMask))
info[i].CpuMask = cpu.CPUMask
//(uintptr)(unsafe.Pointer(&cpu.CPUMask))
info[i].CpuGroup = (uint16)(cpu.CPUGroup)
//info[i].Reserved = [3]uint32{0, 0, 0}
}
Expand Down
7 changes: 3 additions & 4 deletions internal/jobobject/jobobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,14 @@ func isJobSilo(h windows.Handle) bool {
}

func (job *JobObject) SetInformationJobObject(affinityCPUs []winapi.JOBOBJECT_CPU_GROUP_AFFINITY) error {
//len := len(affinityCPUs)
//sizeOfGroupAffinity := unsafe.Sizeof(winapi.JOBOBJECT_CPU_GROUP_AFFINITY{})
len := len(affinityCPUs)
sizeOfGroupAffinity := unsafe.Sizeof(winapi.JOBOBJECT_CPU_GROUP_AFFINITY{})
_, err := windows.SetInformationJobObject(
job.handle,
winapi.JobObjectGroupInformationEx,
//uintptr(unsafe.Pointer(affinityCPUs)),
uintptr(unsafe.Pointer(&affinityCPUs[0])),
//uint32(unsafe.Sizeof(affinityCPUs)),
uint32(unsafe.Sizeof(affinityCPUs)*2),
uint32(uintptr(len)*sizeOfGroupAffinity),
)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/winapi/jobobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ type JOBOBJECT_ASSOCIATE_COMPLETION_PORT struct {

// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-group_affinity
type JOBOBJECT_CPU_GROUP_AFFINITY struct {
CpuMask uintptr
CpuMask uint64
CpuGroup uint16
Reserved [3]uint16
}
Expand Down

0 comments on commit bf85e4f

Please sign in to comment.