]> xenbits.xensource.com Git - xen.git/commit
mm.h: add helper function to test-and-clear _PGC_allocated
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 16 Jul 2019 07:10:36 +0000 (09:10 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 16 Jul 2019 07:10:36 +0000 (09:10 +0200)
commitec83f8256276c6f99dfe13bb2b56d168c080f098
tree0ec11173047453331c64f2e3cc5592a02eb64112
parent3bfe102c16b0590d4f885250e82a2ef623867cf4
mm.h: add helper function to test-and-clear _PGC_allocated

The _PGC_allocated flag is set on a page when it is assigned to a domain
along with an initial reference count of at least 1. To clear this
'allocation' reference it is necessary to test-and-clear _PGC_allocated and
then only drop the reference if the test-and-clear succeeds. This is open-
coded in many places. It is also unsafe to test-and-clear _PGC_allocated
unless the caller holds an additional reference.

This patch adds a helper function, put_page_alloc_ref(), to replace all the
open-coded test-and-clear/put_page occurrences. That helper function
incorporates a check that an additional page reference is held and will
BUG() if it is not.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/arm/domain.c
xen/arch/x86/domain.c
xen/arch/x86/hvm/ioreq.c
xen/arch/x86/mm.c
xen/arch/x86/mm/mem_sharing.c
xen/arch/x86/mm/p2m-pod.c
xen/arch/x86/mm/p2m.c
xen/common/grant_table.c
xen/common/memory.c
xen/common/xenoprof.c
xen/include/xen/mm.h