Skip to content

Commit

Permalink
CP-53335, topology: Avoid distances with NaN among NUMA nodes
Browse files Browse the repository at this point in the history
These could be created accidentally by dividing by 0.

Signed-off-by: Pau Ruiz Safont <[email protected]>
  • Loading branch information
psafont committed Jan 24, 2025
1 parent 2e641ef commit f4d3e9e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ocaml/xenopsd/lib/topology.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f4d3e9e

Please sign in to comment.