diff options
author | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2013-05-13 15:29:11 -0400 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2013-05-14 10:01:50 +0100 |
commit | bec8f17e48439ee5b8370f4e431ccd9a9514bee7 (patch) | |
tree | 59b77ff052dcef3826e1f54a5eb183ae5ceac18a /xen/common | |
parent | abf04cf04f5b6f2ce22e9f7966d63303b9487d81 (diff) | |
download | xen-bec8f17e48439ee5b8370f4e431ccd9a9514bee7.tar.gz xen-bec8f17e48439ee5b8370f4e431ccd9a9514bee7.tar.bz2 xen-bec8f17e48439ee5b8370f4e431ccd9a9514bee7.zip |
hypervisor/xen/tools: Remove the XENMEM_get_oustanding_pages and provide the data via xc_phys_info
During the review of the patches it was noticed that there exists
a race wherein the 'free_memory' value consists of information from
two hypercalls. That is the XEN_SYSCTL_physinfo and XENMEM_get_outstanding_pages.
The free memory the host has available for guest is the difference between
the 'free_pages' (from XEN_SYSCTL_physinfo) and 'outstanding_pages'. As they
are two hypercalls many things can happen in between the execution of them.
This patch resolves this by eliminating the XENMEM_get_outstanding_pages
hypercall and providing the free_pages and outstanding_pages information
via the xc_phys_info structure.
It also removes the XSM hooks and adds locking as needed.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir.xen@gmail.com>
Diffstat (limited to 'xen/common')
-rw-r--r-- | xen/common/memory.c | 8 | ||||
-rw-r--r-- | xen/common/page_alloc.c | 7 | ||||
-rw-r--r-- | xen/common/sysctl.c | 3 |
3 files changed, 7 insertions, 11 deletions
diff --git a/xen/common/memory.c b/xen/common/memory.c index 3239d53978..06a0d0ac4c 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -737,14 +737,6 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) break; - case XENMEM_get_outstanding_pages: - rc = xsm_xenmem_get_outstanding_pages(XSM_PRIV); - - if ( !rc ) - rc = get_outstanding_claims(); - - break; - default: rc = arch_memory_op(op, arg); break; diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 203f77a485..2162ef14d4 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -380,9 +380,12 @@ out: return ret; } -long get_outstanding_claims(void) +void get_outstanding_claims(uint64_t *free_pages, uint64_t *outstanding_pages) { - return outstanding_claims; + spin_lock(&heap_lock); + *outstanding_pages = outstanding_claims; + *free_pages = avail_domheap_pages(); + spin_unlock(&heap_lock); } static unsigned long init_node_heap(int node, unsigned long mfn, diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index 31f9650ecc..117e095a35 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -264,7 +264,8 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) pi->max_node_id = MAX_NUMNODES-1; pi->max_cpu_id = nr_cpu_ids - 1; pi->total_pages = total_pages; - pi->free_pages = avail_domheap_pages(); + /* Protected by lock */ + get_outstanding_claims(&pi->free_pages, &pi->outstanding_pages); pi->scrub_pages = 0; pi->cpu_khz = cpu_khz; arch_do_physinfo(pi); |