From 58965b69802b5f7b7b68709a468a0fb1d9899c8e Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Fri, 24 Jan 2025 14:57:33 +0000 Subject: [PATCH] CP-53335, topology: Avoid distances with NaN among NUMA nodes These could be created accidentally by dividing by 0. Signed-off-by: Pau Ruiz Safont --- ocaml/xenopsd/lib/topology.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ocaml/xenopsd/lib/topology.ml b/ocaml/xenopsd/lib/topology.ml index 54f47ff5ae..7928bdf1ad 100644 --- a/ocaml/xenopsd/lib/topology.ml +++ b/ocaml/xenopsd/lib/topology.ml @@ -169,7 +169,10 @@ module NUMA = struct (* We want to minimize maximum distance first, and average distance next. When running the VM we don't know which pCPU it'll end up using, and want to limit the worst case performance. *) - ((max_dist, float sum_dist /. float count), nodes) + if Seq.is_empty nodes then + None + else + Some ((max_dist, float sum_dist /. float count), nodes) let dist_cmp (a1, _) (b1, _) = compare a1 b1 @@ -207,7 +210,7 @@ module NUMA = struct else valid_nodes |> seq_all_subsets - |> Seq.map (node_distances d) + |> Seq.filter_map (node_distances d) |> seq_append single_nodes in nodes