[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] gnttab: mark maptrack free list tail with an explicit terminator


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Wed, 30 May 2012 13:22:18 +0000
  • Delivery-date: Wed, 30 May 2012 13:22:44 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Jan Beulich <JBeulich@xxxxxxxx>
# Date 1338366171 -3600
# Node ID ccd920a43730b9759c0cb2d9aa0f26db76794888
# Parent  c6ec3ab4fc75b1729fc0dfc7c5ad79e62f10e407
gnttab: mark maptrack free list tail with an explicit terminator

... instead of using the mutable current limit.

This also addresses an apparent off-by-one mistake when checking for
exhaustion of the maptrack table.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Tested-by: Andrew Thomas <andrew.thomas@xxxxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r c6ec3ab4fc75 -r ccd920a43730 xen/common/grant_table.c
--- a/xen/common/grant_table.c  Wed May 30 09:22:17 2012 +0100
+++ b/xen/common/grant_table.c  Wed May 30 09:22:51 2012 +0100
@@ -107,6 +107,8 @@ static unsigned inline int max_nr_maptra
     return (max_nr_grant_frames * MAX_MAPTRACK_TO_GRANTS_RATIO);
 }
 
+#define MAPTRACK_TAIL (~0u)
+
 #define SHGNT_PER_PAGE_V1 (PAGE_SIZE / sizeof(grant_entry_v1_t))
 #define shared_entry_v1(t, e) \
     ((t)->shared_v1[(e)/SHGNT_PER_PAGE_V1][(e)%SHGNT_PER_PAGE_V1])
@@ -198,7 +200,7 @@ __get_maptrack_handle(
     struct grant_table *t)
 {
     unsigned int h;
-    if ( unlikely((h = t->maptrack_head) == (t->maptrack_limit - 1)) )
+    if ( unlikely((h = t->maptrack_head) == MAPTRACK_TAIL) )
         return -1;
     t->maptrack_head = maptrack_entry(t, h).ref;
     return h;
@@ -239,8 +241,10 @@ get_maptrack_handle(
 
         new_mt_limit = lgt->maptrack_limit + MAPTRACK_PER_PAGE;
 
-        for ( i = lgt->maptrack_limit; i < new_mt_limit; i++ )
-            new_mt[i % MAPTRACK_PER_PAGE].ref = i + 1;
+        for ( i = 1; i < MAPTRACK_PER_PAGE; i++ )
+            new_mt[i - 1].ref = lgt->maptrack_limit + i;
+        new_mt[i - 1].ref = lgt->maptrack_head;
+        lgt->maptrack_head = lgt->maptrack_limit;
 
         lgt->maptrack[nr_frames] = new_mt;
         smp_wmb();
@@ -2577,9 +2581,10 @@ grant_table_create(
     if ( (t->maptrack[0] = alloc_xenheap_page()) == NULL )
         goto no_mem_3;
     clear_page(t->maptrack[0]);
-    t->maptrack_limit = PAGE_SIZE / sizeof(struct grant_mapping);
-    for ( i = 0; i < t->maptrack_limit; i++ )
-        t->maptrack[0][i].ref = i+1;
+    t->maptrack_limit = MAPTRACK_PER_PAGE;
+    for ( i = 1; i < MAPTRACK_PER_PAGE; i++ )
+        t->maptrack[0][i - 1].ref = i;
+    t->maptrack[0][i - 1].ref = MAPTRACK_TAIL;
 
     /* Shared grant table. */
     if ( (t->shared_raw = xzalloc_array(void *, max_nr_grant_frames)) == NULL )

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.