Handle paged-out pages for XENMEM_decrease_reservation memory op.
Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
---
tools/libxc/xc_domain.c | 38 ++++++++++++++++++++++++++------------
xen/common/memory.c | 4 ++++
2 files changed, 30 insertions(+), 12 deletions(-)
--- xen-unstable.hg-4.1.22155.orig/tools/libxc/xc_domain.c
+++ xen-unstable.hg-4.1.22155/tools/libxc/xc_domain.c
@@ -620,15 +620,15 @@ int xc_domain_memory_decrease_reservatio
xen_pfn_t *extent_start)
{
int err;
+ unsigned long delay = 0;
+ unsigned long start = 0;
+ unsigned long count= nr_extents;
struct xen_memory_reservation reservation = {
- .nr_extents = nr_extents,
.extent_order = extent_order,
.mem_flags = 0,
.domid = domid
};
- set_xen_guest_handle(reservation.extent_start, extent_start);
-
if ( extent_start == NULL )
{
DPRINTF("decrease_reservation extent_start is NULL!\n");
@@ -636,16 +636,30 @@ int xc_domain_memory_decrease_reservatio
return -1;
}
- err = xc_memory_op(xch, XENMEM_decrease_reservation, &reservation);
- if ( err == nr_extents )
- return 0;
+ while (1) {
+ set_xen_guest_handle(reservation.extent_start, extent_start + start);
+ reservation.nr_extents = count;
- if ( err >= 0 )
- {
- DPRINTF("Failed deallocation for dom %d: %ld extents of order %d\n",
- domid, nr_extents, extent_order);
- errno = EINVAL;
- err = -1;
+ err = xc_memory_op(xch, XENMEM_decrease_reservation, &reservation);
+ if ( err == count )
+ {
+ err = 0;
+ break;
+ }
+
+ if ( err > count || err <= 0 || delay > 1000 * 1000)
+ {
+ DPRINTF("Failed deallocation for dom %d: %ld extents of order %d:
0x%x\n",
+ domid, nr_extents, extent_order, err);
+ errno = EINVAL;
+ err = -1;
+ break;
+ }
+
+ start += err;
+ count -= err;
+ usleep(delay);
+ delay += 666; /* 1500 iterations, 12 seconds */
}
return err;
--- xen-unstable.hg-4.1.22155.orig/xen/common/memory.c
+++ xen-unstable.hg-4.1.22155/xen/common/memory.c
@@ -162,6 +162,10 @@ int guest_remove_page(struct domain *d,
#ifdef CONFIG_X86
mfn = mfn_x(gfn_to_mfn(p2m_get_hostp2m(d), gmfn, &p2mt));
+ if ( p2m_is_paged(p2mt) )
+ p2m_mem_paging_populate(p2m_get_hostp2m(d), gmfn);
+ if ( p2m_is_paging(p2mt) )
+ return -ENOENT;
#else
mfn = gmfn_to_mfn(d, gmfn);
#endif
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|