From 4fec14bc26bc9a9185c58dd483085f6c893bbde7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AF=85=EF=BC=88Jason=20Liu=EF=BC=89?= Date: Tue, 23 Nov 2021 11:50:48 +0800 Subject: [PATCH] try to fixed fatal error: concurrent map writes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘毅(Jason Liu) --- pkg/scheduler/plugins/numaaware/numaaware.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/scheduler/plugins/numaaware/numaaware.go b/pkg/scheduler/plugins/numaaware/numaaware.go index 824faa6c6e..a77571b363 100644 --- a/pkg/scheduler/plugins/numaaware/numaaware.go +++ b/pkg/scheduler/plugins/numaaware/numaaware.go @@ -19,6 +19,7 @@ package numaaware import ( "context" "fmt" + "sync" "volcano.sh/volcano/pkg/scheduler/plugins/util" @@ -225,9 +226,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)) })