Skip to content

Commit

Permalink
Add 'threads_per_core' in 'Host.cpu_info'
Browse files Browse the repository at this point in the history
Discussed here: xapi-project#5462

Signed-off-by: Benjamin Reis <[email protected]>
  • Loading branch information
benjamreis committed Feb 21, 2024
1 parent 34dabdf commit 79a0ab5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ocaml/tests/common/test_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ let default_cpu_info =
* localhost to be counted *)
("cpu_count", "0")
; ("socket_count", "0")
; ("threads_per_core", "0")
; ("vendor", "Abacus")
; ("speed", "")
; ("modelname", "")
Expand Down Expand Up @@ -77,6 +78,7 @@ let make_localhost ~__context ?(features = Features.all_features) () =
{
cpu_count= 1
; socket_count= 1
; threads_per_core= 1
; vendor= ""
; speed= ""
; modelname= ""
Expand Down
1 change: 1 addition & 0 deletions ocaml/xapi-idl/xen/xenops_interface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ module Host = struct
type cpu_info = {
cpu_count: int
; socket_count: int
; threads_per_core: int
; vendor: string
; speed: string
; modelname: string
Expand Down
2 changes: 2 additions & 0 deletions ocaml/xapi/cpuid_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ let cpu_count = Map_check.(field "cpu_count" int)

let socket_count = Map_check.(field "socket_count" int)

let threads_per_core = Map_check.(field "threads_per_core" int)

let vendor = Map_check.(field "vendor" string)

let get_flags_for_vm ~__context vm cpu_info =
Expand Down
2 changes: 2 additions & 0 deletions ocaml/xapi/cpuid_helpers.mli
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ val cpu_count : int Map_check.field

val socket_count : int Map_check.field

val threads_per_core : int Map_check.field

val features : [`vm] Xenops_interface.CPU_policy.t Map_check.field

val features_pv : [`host] Xenops_interface.CPU_policy.t Map_check.field
Expand Down
6 changes: 4 additions & 2 deletions ocaml/xapi/create_misc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ let create_host_cpu ~__context host_info =
[
("cpu_count", string_of_int cpu_info.cpu_count)
; ("socket_count", string_of_int cpu_info.socket_count)
; ("threads_per_core", string_of_int cpu_info.threads_per_core)
; ("vendor", cpu_info.vendor)
; ("speed", cpu_info.speed)
; ("modelname", cpu_info.modelname)
Expand All @@ -592,10 +593,11 @@ let create_host_cpu ~__context host_info =
let old_cpu_info = Db.Host.get_cpu_info ~__context ~self:host in
debug
"create_host_cpuinfo: setting host cpuinfo: socket_count=%d, \
cpu_count=%d, features_hvm=%s, features_pv=%s, features_hvm_host=%s, \
features_pv_host=%s"
cpu_count=%d, threads_per_core=%d, features_hvm=%s, features_pv=%s, \
features_hvm_host=%s, features_pv_host=%s"
(Map_check.getf socket_count cpu)
(Map_check.getf cpu_count cpu)
(Map_check.getf threads_per_core cpu)
(Map_check.getf features_hvm cpu |> CPU_policy.to_string)
(Map_check.getf features_pv cpu |> CPU_policy.to_string)
(Map_check.getf features_hvm_host cpu |> CPU_policy.to_string)
Expand Down
1 change: 1 addition & 0 deletions ocaml/xenopsd/lib/xenops_server_skeleton.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module HOST = struct
{
Host.cpu_count= 0
; socket_count= 0
; threads_per_core= 0
; vendor= "unknown"
; speed= ""
; modelname= ""
Expand Down
2 changes: 2 additions & 0 deletions ocaml/xenopsd/xc/xenops_server_xen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ module HOST = struct
let socket_count =
p.nr_cpus / (p.threads_per_core * p.cores_per_socket)
in
let threads_per_core = p.threads_per_core in
let features = get_cpu_featureset xc Featureset_host in
(* this is Default policy in Xen's terminology, used on boot for new VMs *)
let features_pv_host = get_cpu_featureset xc Featureset_pv in
Expand Down Expand Up @@ -1012,6 +1013,7 @@ module HOST = struct
{
Host.cpu_count
; socket_count
; threads_per_core
; vendor
; speed
; modelname
Expand Down

0 comments on commit 79a0ab5

Please sign in to comment.