From 2d1f750000dc65ed6dd60a1ce8dd53c3bf3d59a5 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Thu, 13 Oct 2011 12:21:10 +0100 Subject: xenpaging: handle evict failures Evict of a nominated gfn must fail if some other process mapped the page without checking the p2mt of that gfn first. Add a check to cancel eviction if the page usage count is not 1. Handle the possible eviction failure in the page-in paths. After nominate and before evict, something may check the p2mt and call populate. Handle this case and let the gfn enter the page-in path. The gfn may still be connected to a mfn, so there is no need to allocate a new page in prep. Adjust do_mmu_update to return -ENOENT only if the gfn has entered the page-in path and if it is not yet connected to a mfn. Otherwise linux_privcmd_map_foreign_bulk() may loop forever. Add MEM_EVENT_FLAG_EVICT_FAIL to inform pager that a page-in request for a possible not-evicted page was sent. xenpaging does currently not need that flag because failure to evict a gfn will be caught. Signed-off-by: Olaf Hering Acked-by: Tim Deegan Committed-by: Tim Deegan --- tools/xenpaging/xenpaging.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tools/xenpaging') diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c index 1ab756efb2..7fbb177c70 100644 --- a/tools/xenpaging/xenpaging.c +++ b/tools/xenpaging/xenpaging.c @@ -734,10 +734,12 @@ int main(int argc, char *argv[]) } else { - DPRINTF("page already populated (domain = %d; vcpu = %d;" - " gfn = %"PRIx64"; paused = %d)\n", - paging->mem_event.domain_id, req.vcpu_id, - req.gfn, req.flags & MEM_EVENT_FLAG_VCPU_PAUSED); + DPRINTF("page %s populated (domain = %d; vcpu = %d;" + " gfn = %"PRIx64"; paused = %d; evict_fail = %d)\n", + req.flags & MEM_EVENT_FLAG_EVICT_FAIL ? "not" : "already", + paging->mem_event.domain_id, req.vcpu_id, req.gfn, + !!(req.flags & MEM_EVENT_FLAG_VCPU_PAUSED) , + !!(req.flags & MEM_EVENT_FLAG_EVICT_FAIL) ); /* Tell Xen to resume the vcpu */ /* XXX: Maybe just check if the vcpu was paused? */ -- cgit v1.2.3