Skip to content

Commit 79a0ab5

Browse files
committed
Add 'threads_per_core' in 'Host.cpu_info'
Discussed here: #5462 Signed-off-by: Benjamin Reis <benjamin.reis@vates.tech>
1 parent 34dabdf commit 79a0ab5

File tree

7 files changed

+14
-2
lines changed

7 files changed

+14
-2
lines changed

ocaml/tests/common/test_common.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ let default_cpu_info =
4242
* localhost to be counted *)
4343
("cpu_count", "0")
4444
; ("socket_count", "0")
45+
; ("threads_per_core", "0")
4546
; ("vendor", "Abacus")
4647
; ("speed", "")
4748
; ("modelname", "")
@@ -77,6 +78,7 @@ let make_localhost ~__context ?(features = Features.all_features) () =
7778
{
7879
cpu_count= 1
7980
; socket_count= 1
81+
; threads_per_core= 1
8082
; vendor= ""
8183
; speed= ""
8284
; modelname= ""

ocaml/xapi-idl/xen/xenops_interface.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ module Host = struct
461461
type cpu_info = {
462462
cpu_count: int
463463
; socket_count: int
464+
; threads_per_core: int
464465
; vendor: string
465466
; speed: string
466467
; modelname: string

ocaml/xapi/cpuid_helpers.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ let cpu_count = Map_check.(field "cpu_count" int)
4343

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

46+
let threads_per_core = Map_check.(field "threads_per_core" int)
47+
4648
let vendor = Map_check.(field "vendor" string)
4749

4850
let get_flags_for_vm ~__context vm cpu_info =

ocaml/xapi/cpuid_helpers.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ val cpu_count : int Map_check.field
2828

2929
val socket_count : int Map_check.field
3030

31+
val threads_per_core : int Map_check.field
32+
3133
val features : [`vm] Xenops_interface.CPU_policy.t Map_check.field
3234

3335
val features_pv : [`host] Xenops_interface.CPU_policy.t Map_check.field

ocaml/xapi/create_misc.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ let create_host_cpu ~__context host_info =
567567
[
568568
("cpu_count", string_of_int cpu_info.cpu_count)
569569
; ("socket_count", string_of_int cpu_info.socket_count)
570+
; ("threads_per_core", string_of_int cpu_info.threads_per_core)
570571
; ("vendor", cpu_info.vendor)
571572
; ("speed", cpu_info.speed)
572573
; ("modelname", cpu_info.modelname)
@@ -592,10 +593,11 @@ let create_host_cpu ~__context host_info =
592593
let old_cpu_info = Db.Host.get_cpu_info ~__context ~self:host in
593594
debug
594595
"create_host_cpuinfo: setting host cpuinfo: socket_count=%d, \
595-
cpu_count=%d, features_hvm=%s, features_pv=%s, features_hvm_host=%s, \
596-
features_pv_host=%s"
596+
cpu_count=%d, threads_per_core=%d, features_hvm=%s, features_pv=%s, \
597+
features_hvm_host=%s, features_pv_host=%s"
597598
(Map_check.getf socket_count cpu)
598599
(Map_check.getf cpu_count cpu)
600+
(Map_check.getf threads_per_core cpu)
599601
(Map_check.getf features_hvm cpu |> CPU_policy.to_string)
600602
(Map_check.getf features_pv cpu |> CPU_policy.to_string)
601603
(Map_check.getf features_hvm_host cpu |> CPU_policy.to_string)

ocaml/xenopsd/lib/xenops_server_skeleton.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module HOST = struct
2626
{
2727
Host.cpu_count= 0
2828
; socket_count= 0
29+
; threads_per_core= 0
2930
; vendor= "unknown"
3031
; speed= ""
3132
; modelname= ""

ocaml/xenopsd/xc/xenops_server_xen.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,7 @@ module HOST = struct
985985
let socket_count =
986986
p.nr_cpus / (p.threads_per_core * p.cores_per_socket)
987987
in
988+
let threads_per_core = p.threads_per_core in
988989
let features = get_cpu_featureset xc Featureset_host in
989990
(* this is Default policy in Xen's terminology, used on boot for new VMs *)
990991
let features_pv_host = get_cpu_featureset xc Featureset_pv in
@@ -1012,6 +1013,7 @@ module HOST = struct
10121013
{
10131014
Host.cpu_count
10141015
; socket_count
1016+
; threads_per_core
10151017
; vendor
10161018
; speed
10171019
; modelname

0 commit comments

Comments
 (0)