[Qemu-devel] [PATCH] xen-mapcache: don't unmap locked entry during mapcache invalidation

2012-03-15 Thread Julien Grall

When an IOREQ_TYPE_INVALIDATE is sent to QEMU, it invalidates all entry
of the map cache even if it's locked.

QEMU is not able to know that entry was invalidated, so when an IO
access is requested a segfault occured.

Signed-off-by: Julien Grall julien.gr...@citrix.com
---
 xen-mapcache.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/xen-mapcache.c b/xen-mapcache.c
index 585b559..6e7e5ab 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -370,6 +370,9 @@ void xen_invalidate_map_cache(void)
 continue;
 }
+   if (entry-lock  0)
+   continue;
+
 if (munmap(entry-vaddr_base, entry-size) != 0) {
 perror(unmap fails);
 exit(-1);
--
Julien Grall




Re: [Qemu-devel] [PATCH] xen-mapcache: don't unmap locked entry during mapcache invalidation

2012-03-15 Thread Stefano Stabellini
On Thu, 15 Mar 2012, Julien Grall wrote:
 When an IOREQ_TYPE_INVALIDATE is sent to QEMU, it invalidates all entry
 of the map cache even if it's locked.
 
 QEMU is not able to know that entry was invalidated, so when an IO
 access is requested a segfault occured.

The problem here is the long term mappings in QEMU that cannot easily be
re-created.
I am not sure whether this can cause any trouble to things like
xenpaging.


 Signed-off-by: Julien Grall julien.gr...@citrix.com
 ---
   xen-mapcache.c |3 +++
   1 files changed, 3 insertions(+), 0 deletions(-)
 
 diff --git a/xen-mapcache.c b/xen-mapcache.c
 index 585b559..6e7e5ab 100644
 --- a/xen-mapcache.c
 +++ b/xen-mapcache.c
 @@ -370,6 +370,9 @@ void xen_invalidate_map_cache(void)
   continue;
   }
 + if (entry-lock  0)
 + continue;
 +
   if (munmap(entry-vaddr_base, entry-size) != 0) {
   perror(unmap fails);
   exit(-1);
 
CODING_STYLE



Re: [Qemu-devel] [PATCH] xen-mapcache: don't unmap locked entry during mapcache invalidation

2012-03-15 Thread Andres Lagar-Cavilla
 On Thu, 15 Mar 2012, Julien Grall wrote:
 When an IOREQ_TYPE_INVALIDATE is sent to QEMU, it invalidates all entry
 of the map cache even if it's locked.

 QEMU is not able to know that entry was invalidated, so when an IO
 access is requested a segfault occured.

 The problem here is the long term mappings in QEMU that cannot easily be
 re-created.
 I am not sure whether this can cause any trouble to things like
 xenpaging.

This is a performance optimization for xenpaging: it cannot page out pages
that are mapped by qemu, so it asks qemu to drop the mappings. If denied
(partially or fully) xenpaging won't crash, and the VM won't crash.
xenpaging will just have to keep trying to find other candidates for
paging out.

Andres



 Signed-off-by: Julien Grall julien.gr...@citrix.com
 ---
   xen-mapcache.c |3 +++
   1 files changed, 3 insertions(+), 0 deletions(-)

 diff --git a/xen-mapcache.c b/xen-mapcache.c
 index 585b559..6e7e5ab 100644
 --- a/xen-mapcache.c
 +++ b/xen-mapcache.c
 @@ -370,6 +370,9 @@ void xen_invalidate_map_cache(void)
   continue;
   }
 +if (entry-lock  0)
 +continue;
 +
   if (munmap(entry-vaddr_base, entry-size) != 0) {
   perror(unmap fails);
   exit(-1);

 CODING_STYLE






Re: [Qemu-devel] [PATCH] xen-mapcache: don't unmap locked entry during mapcache invalidation

2012-03-15 Thread Olaf Hering
On Thu, Mar 15, Stefano Stabellini wrote:

 On Thu, 15 Mar 2012, Julien Grall wrote:
  When an IOREQ_TYPE_INVALIDATE is sent to QEMU, it invalidates all entry
  of the map cache even if it's locked.
  
  QEMU is not able to know that entry was invalidated, so when an IO
  access is requested a segfault occured.
 
 The problem here is the long term mappings in QEMU that cannot easily be
 re-created.
 I am not sure whether this can cause any trouble to things like
 xenpaging.

Yes, I was wondering about this as well. If the request is made, then
its expected that all mappings disappear because they can point to
ballooned gfns. IF that case is safe, then all is fine.

In case of xenpaging its not an issue because xenpaging just asks qemu
to release mappings so that the usage count of mfns drops to 1, so that
they can be nominated for eviction. If that fails, not a big deal as it
just means that no more pages can be evicted. xenpaging will retry.

Olaf



Re: [Qemu-devel] [PATCH] xen-mapcache: don't unmap locked entry during mapcache invalidation

2012-03-15 Thread Stefano Stabellini
On Thu, 15 Mar 2012, Olaf Hering wrote:
 On Thu, Mar 15, Stefano Stabellini wrote:
 
  On Thu, 15 Mar 2012, Julien Grall wrote:
   When an IOREQ_TYPE_INVALIDATE is sent to QEMU, it invalidates all entry
   of the map cache even if it's locked.
   
   QEMU is not able to know that entry was invalidated, so when an IO
   access is requested a segfault occured.
  
  The problem here is the long term mappings in QEMU that cannot easily be
  re-created.
  I am not sure whether this can cause any trouble to things like
  xenpaging.
 
 Yes, I was wondering about this as well. If the request is made, then
 its expected that all mappings disappear because they can point to
 ballooned gfns. IF that case is safe, then all is fine.

The long lived mappings shouldn't involve any ballooned gfns, unless
something went terribly wrong.


 In case of xenpaging its not an issue because xenpaging just asks qemu
 to release mappings so that the usage count of mfns drops to 1, so that
 they can be nominated for eviction. If that fails, not a big deal as it
 just means that no more pages can be evicted. xenpaging will retry.

Great, sounds like there is no problem then.