x86: Improve the efficiency of domain_relinquish_resources()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 20 Feb 2019 13:39:20 +0000 (13:39 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 22 Feb 2019 14:10:42 +0000 (14:10 +0000)
commit0dfffe01d5681ede6a50c6b57131320d9f4a3361
tree4ea5de91bdf25559753f417b9bd9fb609c0492bc
parentdb2af23d15077605f286d8ef86c8f5d9c1b8302a
x86: Improve the efficiency of domain_relinquish_resources()

pci_release_devices() takes the global PCI lock.  Once pci_release_devices()
has completed, it will be called redundantly each time paging_teardown() and
vcpu_destroy_pagetables() continue.

This is liable to be millions of times for a reasonably sized guest, and is a
serialising bottleneck now that domain_kill() can be run concurrently on
different domains.

Instead of propagating the opencoding of the relinquish state machine, take
the opportunity to clean it up.

Leave a proper set of comments explaining that domain_relinquish_resources()
implements a co-routine.  Introduce a documented PROGRESS() macro to avoid
latent bugs such as the RELMEM_xen case, and make the new PROG_* states
private to domain_relinquish_resources().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/arch/x86/domain.c
xen/include/asm-x86/domain.h