xen/page-alloc: Clamp get_free_buddy() to online nodes
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 24 Jun 2019 15:38:36 +0000 (16:38 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 31 Jul 2019 13:18:31 +0000 (14:18 +0100)
commit1ae0db5e48106498dcb3b9fe2dd3e74830e284c4
treef32ccb6ff6607ac5007f001d658a8aa79f28afbb
parentdd48840683a3222e0f2aeade6d36da477b949909
xen/page-alloc: Clamp get_free_buddy() to online nodes

d->node_affinity defaults to NODE_MASK_ALL which has bits set outside of
node_online_map.  This in turn causes the loop in get_free_buddy() to waste
effort iterating over offline nodes.

Always clamp d->node_affinity to node_online_map.

This in turn requires ensuring that d->node_affinity intersects with
node_online_map, and there is one case via XEN_DOMCTL_setnodeaffinity where a
disjoint mask can end up being specified.

Tighten up the hypercall check, because there is no plausible reason to select
a node affinity which is disjoint with the system, and leave get_free_buddy()
with an assertion to the same effect, but with a runtime-safe fallback to the
full online node map.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/domain.c
xen/common/page_alloc.c