Skip to content

Commit 29ab6b6

Browse files
authored
CA-408339: Respect xenopsd's NUMA-placement-policy default (#6368)
Xenopsd has an experimental feature that aims to optimise NUMA placement. This used to be configured by adding `numa-placement=true` to the file /etc/xenopsd.conf, which tells xenopsd to enable the feature. Later, an actual API was added to configure this: `host.set_numa_affinity_policy`. The expectation was that, while this new API should be preferred, the old xenopsd.conf option would still work for backwards compatibility reasons. This is particularly important for hosts that are upgraded to the new version. Unfortunately, while code exists in xenopsd to read and use the config option when it starts up, when xapi starts up immediately after xenopsd, it always overrides the NUMA config based its own DB field. The field type actually has a "default" option, but this gets translated to "any" (= no NUMA). By default, this means means that the experimental feature is disabled, no matter what the config file says, and can only be enabled through the API. The fix is for xapi to not assign a default value itself, but let xenopsd decide on the default policy. And xenopsd uses its config file to do so, as before.
2 parents e39ab6f + 3608e9d commit 29ab6b6

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

ocaml/idl/datamodel_lifecycle.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ let prototyped_of_message = function
206206
| "VTPM", "create" ->
207207
Some "22.26.0"
208208
| "host", "disable_ssh" ->
209-
Some "25.12.0-next"
209+
Some "25.13.0"
210210
| "host", "enable_ssh" ->
211-
Some "25.12.0-next"
211+
Some "25.13.0"
212212
| "host", "emergency_clear_mandatory_guidance" ->
213213
Some "24.10.0"
214214
| "host", "apply_recommended_guidances" ->
@@ -228,9 +228,9 @@ let prototyped_of_message = function
228228
| "VM", "set_groups" ->
229229
Some "24.19.1"
230230
| "pool", "disable_ssh" ->
231-
Some "25.12.0-next"
231+
Some "25.13.0"
232232
| "pool", "enable_ssh" ->
233-
Some "25.12.0-next"
233+
Some "25.13.0"
234234
| "pool", "get_guest_secureboot_readiness" ->
235235
Some "24.17.0"
236236
| "pool", "set_ext_auth_cache_expiry" ->

ocaml/xapi-idl/xen/xenops_interface.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ module Host = struct
501501
(** best effort placement on the smallest number of NUMA nodes where possible *)
502502
[@@deriving rpcty]
503503

504+
type numa_affinity_policy_opt = numa_affinity_policy option [@@deriving rpcty]
505+
504506
type guest_agent_feature_list = guest_agent_feature list [@@deriving rpcty]
505507
end
506508

@@ -657,7 +659,7 @@ module XenopsAPI (R : RPC) = struct
657659
let numa_affinity_policy_p =
658660
Param.mk
659661
~description:["Host NUMA affinity policy"]
660-
~name:"numa_affinity_policy" Host.numa_affinity_policy
662+
~name:"numa_affinity_policy" Host.numa_affinity_policy_opt
661663
in
662664
declare "HOST.set_numa_affinity_policy"
663665
["Sets the host's NUMA aware VM scheduling policy"]

ocaml/xapi/xapi_xenops.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3098,11 +3098,11 @@ let set_numa_affinity_policy ~__context ~value =
30983098
let open Xenops_interface.Host in
30993099
match value with
31003100
| `any ->
3101-
Any
3101+
Some Any
31023102
| `best_effort ->
3103-
Best_effort
3103+
Some Best_effort
31043104
| `default_policy ->
3105-
Any
3105+
None
31063106
in
31073107
Client.HOST.set_numa_affinity_policy dbg value
31083108

ocaml/xenopsd/lib/xenops_server.ml

+14-1
Original file line numberDiff line numberDiff line change
@@ -3398,8 +3398,13 @@ module VIF = struct
33983398
()
33993399
end
34003400

3401+
let default_numa_affinity_policy = ref Xenops_interface.Host.Any
3402+
34013403
let numa_placement = ref Xenops_interface.Host.Any
34023404

3405+
let string_of_numa_affinity_policy =
3406+
Xenops_interface.Host.(function Any -> "any" | Best_effort -> "best-effort")
3407+
34033408
module HOST = struct
34043409
let stat _ dbg =
34053410
Debug.with_thread_associated dbg
@@ -3413,7 +3418,15 @@ module HOST = struct
34133418
let set_numa_affinity_policy _ dbg =
34143419
Debug.with_thread_associated dbg @@ fun policy ->
34153420
debug "HOST.set_numa_affinity_policy" ;
3416-
numa_placement := policy
3421+
match policy with
3422+
| None ->
3423+
info "Enforcing default NUMA affinity policy (%s)"
3424+
(string_of_numa_affinity_policy !default_numa_affinity_policy) ;
3425+
numa_placement := !default_numa_affinity_policy
3426+
| Some p ->
3427+
info "Enforcing '%s' NUMA affinity policy"
3428+
(string_of_numa_affinity_policy p) ;
3429+
numa_placement := p
34173430

34183431
let get_console_data _ dbg =
34193432
Debug.with_thread_associated dbg

ocaml/xenopsd/xc/xenops_server_xen.ml

+4-1
Original file line numberDiff line numberDiff line change
@@ -5148,8 +5148,11 @@ let init () =
51485148
{Xs_protocol.ACL.owner= 0; other= Xs_protocol.ACL.READ; acl= []}
51495149
) ;
51505150
Device.Backend.init () ;
5151-
Xenops_server.numa_placement :=
5151+
Xenops_server.default_numa_affinity_policy :=
51525152
if !Xenopsd.numa_placement_compat then Best_effort else Any ;
5153+
info "Default NUMA affinity policy is '%s'"
5154+
Xenops_server.(string_of_numa_affinity_policy !default_numa_affinity_policy) ;
5155+
Xenops_server.numa_placement := !Xenops_server.default_numa_affinity_policy ;
51535156
Domain.numa_init () ;
51545157
debug "xenstore is responding to requests" ;
51555158
let () = Watcher.create_watcher_thread () in

0 commit comments

Comments
 (0)