Skip to content

Commit

Permalink
try to fix error: numa nome set once for process. Now numa node is re…
Browse files Browse the repository at this point in the history
…set on idle.
  • Loading branch information
Pavel Safonov committed Jan 9, 2025
1 parent bf754dc commit e3c8dcc
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pkg/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package pkg

import (
"fmt"
"sort"

"github.com/pnsafonov/pind/pkg/config"
"github.com/pnsafonov/pind/pkg/numa"
"github.com/pnsafonov/pind/pkg/utils/core_utils"
"github.com/pnsafonov/pind/pkg/utils/math_utils"
"github.com/prometheus/procfs"
log "github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
"sort"
)

type ThreadSelection int
Expand Down Expand Up @@ -340,6 +341,9 @@ func (x *PinState) PinIdle() error {
// is not used in idle
procInfo.NotSelected.Zero()
}

// reset node when idle
procInfo.Node = nil
}

return err
Expand Down
66 changes: 65 additions & 1 deletion pkg/pool_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package pkg

import (
"github.com/pnsafonov/pind/pkg/numa"
"testing"

"github.com/pnsafonov/pind/pkg/numa"
)

type isMaskInSetTestCase0 struct {
Expand Down Expand Up @@ -76,3 +77,66 @@ func TestIsMaskInSet0(t *testing.T) {
}

}

// type testPool struct {
// Nodes []*PoolNodeInfo
// NodeIndex int
// }

// func getAvailableCoresCountAlgo0(map0 map[int]*PoolCore) int {
// return 0
// }

// func (x *testPool) algo0(requiredCountPhys int, requiredCount int) (*PoolNodeInfo, bool) {
// l0 := len(x.Nodes)
// var freeNode *PoolNodeInfo
// counter := 0
// i := x.NodeIndex
// for {
// if i >= l0 {
// i = 0
// }
// if counter >= l0 {
// break
// }

// node := x.Nodes[i]
// freeCountPhys := len(node.LoadFree)
// freeCount := getAvailableCoresCountAlgo0(node.LoadFree)
// if freeCountPhys >= requiredCountPhys && freeCount >= requiredCount {
// freeNode = node
// i++
// break
// }

// i++
// counter++
// }
// x.NodeIndex = i
// return freeNode, freeNode != nil
// }

// func TestAlgo0(t *testing.T) {
// node0 := &PoolNodeInfo{}

// node1 := &PoolNodeInfo{}

// nodes0 := []*PoolNodeInfo{
// node0, node1,
// }

// pool0 := &testPool{
// Nodes: nodes0,
// NodeIndex: 1,
// }

// pool0.algo0(2, 2)
// pool0.algo0(2, 2)
// pool0.algo0(2, 2)
// pool0.algo0(2, 2)
// pool0.algo0(2, 2)
// pool0.algo0(2, 2)
// pool0.algo0(2, 2)
// pool0.algo0(2, 2)
// pool0.algo0(2, 2)
// }

0 comments on commit e3c8dcc

Please sign in to comment.