Skip to content

Commit

Permalink
cherry pick some bugfix to release1.4 (#1969)
Browse files Browse the repository at this point in the history
* [numa-aware]fix concurrent map read and map write

Signed-off-by: huone1 <huwanxing@huawei.com>

* try to fixed fatal error: concurrent map writes

Signed-off-by: 刘毅(Jason Liu) <liuyi03@qiyi.com>

Co-authored-by: 刘毅(Jason Liu) <liuyi03@qiyi.com>
  • Loading branch information
huone1 and 刘毅(Jason Liu) authored Jan 18, 2022
1 parent 8b6572a commit 329b706
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/scheduler/plugins/numaaware/numaaware.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package numaaware
import (
"context"
"fmt"
"sync"

"volcano.sh/volcano/pkg/scheduler/plugins/util"

Expand Down Expand Up @@ -46,6 +47,7 @@ const (
)

type numaPlugin struct {
sync.Mutex
// Arguments given for the plugin
pluginArguments framework.Arguments
hintProviders []policy.HintProvider
Expand Down Expand Up @@ -143,6 +145,8 @@ func (pp *numaPlugin) OnSessionOpen(ssn *framework.Session) {
}
}

pp.Lock()
defer pp.Unlock()
if _, ok := pp.assignRes[task.UID]; !ok {
pp.assignRes[task.UID] = make(map[string]api.ResNumaSets)
}
Expand Down Expand Up @@ -225,9 +229,12 @@ func filterNodeByPolicy(task *api.TaskInfo, node *api.NodeInfo, nodeResSets map[

func getNodeNumaNumForTask(nodeInfo []*api.NodeInfo, resAssignMap map[string]api.ResNumaSets) map[string]int64 {
nodeNumaNumMap := make(map[string]int64)
var mx sync.RWMutex
workqueue.ParallelizeUntil(context.TODO(), 16, len(nodeInfo), func(index int) {
node := nodeInfo[index]
assignCpus := resAssignMap[node.Name][string(v1.ResourceCPU)]
mx.Lock()
defer mx.Unlock()
nodeNumaNumMap[node.Name] = int64(getNumaNodeCntForcpuID(assignCpus, node.NumaSchedulerInfo.CPUDetail))
})

Expand Down

0 comments on commit 329b706

Please sign in to comment.