diff options
author | Andres Lagar-Cavilla <andres@lagarcavilla.org> | 2012-02-02 12:22:34 +0000 |
---|---|---|
committer | Andres Lagar-Cavilla <andres@lagarcavilla.org> | 2012-02-02 12:22:34 +0000 |
commit | 58fdfc4602dafc7bd0d20b11cc2ad74680f50e74 (patch) | |
tree | 1d14ba933aa3ba28091cdf696264c7a2c81e11be /xen | |
parent | 4b9686b36f778d0c97fc64fad9592a03207aabc8 (diff) | |
download | xen-58fdfc4602dafc7bd0d20b11cc2ad74680f50e74.tar.gz xen-58fdfc4602dafc7bd0d20b11cc2ad74680f50e74.tar.bz2 xen-58fdfc4602dafc7bd0d20b11cc2ad74680f50e74.zip |
x86/mm: Fix paging stats
There are several corner cases in which a page is paged back in, not by paging,
and the stats are not properly updated.
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
Diffstat (limited to 'xen')
-rw-r--r-- | xen/arch/x86/mm/mem_sharing.c | 6 | ||||
-rw-r--r-- | xen/arch/x86/mm/p2m.c | 12 | ||||
-rw-r--r-- | xen/common/memory.c | 2 | ||||
-rw-r--r-- | xen/include/asm-x86/p2m.h | 6 |
4 files changed, 21 insertions, 5 deletions
diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index ed2bc063ff..7b089a0a64 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -878,8 +878,12 @@ int mem_sharing_add_to_physmap(struct domain *sd, unsigned long sgfn, shr_handle ret = -ENOENT; mem_sharing_gfn_destroy(cd, gfn_info); put_page_and_type(spage); - } else + } else { ret = 0; + /* There is a chance we're plugging a hole where a paged out page was */ + if ( p2m_is_paging(cmfn_type) && (cmfn_type != p2m_ram_paging_out) ) + atomic_dec(&cd->paged_pages); + } atomic_inc(&nr_saved_mfns); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index ded33853dc..ab0fcbf89a 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -499,6 +499,11 @@ guest_physmap_add_entry(struct domain *d, unsigned long gfn, /* Count how man PoD entries we'll be replacing if successful */ pod_count++; } + else if ( p2m_is_paging(ot) && (ot != p2m_ram_paging_out) ) + { + /* We're plugging a hole in the physmap where a paged out page was */ + atomic_dec(&d->paged_pages); + } } /* Then, look for m->p mappings for this range and deal with them */ @@ -856,7 +861,8 @@ int p2m_mem_paging_evict(struct domain *d, unsigned long gfn) * released by the guest. The pager is supposed to drop its reference of the * gfn. */ -void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn) +void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn, + p2m_type_t p2mt) { mem_event_request_t req; @@ -875,6 +881,10 @@ void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn) req.flags = MEM_EVENT_FLAG_DROP_PAGE; mem_event_put_request(d, &d->mem_event->paging, &req); + + /* Update stats unless the page hasn't yet been evicted */ + if ( p2mt != p2m_ram_paging_out ) + atomic_dec(&d->paged_pages); } /** diff --git a/xen/common/memory.c b/xen/common/memory.c index 53886cea3b..8793894b3f 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -166,7 +166,7 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) if ( unlikely(p2m_is_paging(p2mt)) ) { guest_physmap_remove_page(d, gmfn, mfn, 0); - p2m_mem_paging_drop_page(d, gmfn); + p2m_mem_paging_drop_page(d, gmfn, p2mt); put_gfn(d, gmfn); return 1; } diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index daa3d15ba1..168f5d4cb1 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -475,7 +475,8 @@ int p2m_mem_paging_nominate(struct domain *d, unsigned long gfn); /* Evict a frame */ int p2m_mem_paging_evict(struct domain *d, unsigned long gfn); /* Tell xenpaging to drop a paged out frame */ -void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn); +void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn, + p2m_type_t p2mt); /* Start populating a paged out frame */ void p2m_mem_paging_populate(struct domain *d, unsigned long gfn); /* Prepare the p2m for paging a frame in */ @@ -483,7 +484,8 @@ int p2m_mem_paging_prep(struct domain *d, unsigned long gfn, uint64_t buffer); /* Resume normal operation (in case a domain was paused) */ void p2m_mem_paging_resume(struct domain *d); #else -static inline void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn) +static inline void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn, + p2m_type_t p2mt) { } static inline void p2m_mem_paging_populate(struct domain *d, unsigned long gfn) { } |