WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 08/22] Extend the grant tables implementation with an

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 08/22] Extend the grant tables implementation with an improved allocation batching mechanism.
From: <steven.smith@xxxxxxxxxx>
Date: Sun, 4 Oct 2009 16:04:01 +0100
Cc: keir.fraser@xxxxxxxxxx, Steven Smith <steven.smith@xxxxxxxxxx>, jean.guyader@xxxxxxxxxx
Delivery-date: Sun, 04 Oct 2009 08:17:22 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <cover.1254666837.git.ssmith@xxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <cover.1254666837.git.ssmith@xxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
The current batched allocation mechanism only allows grefs to be
withdrawn from the pre-allocated pool one at a time; the new scheme
allows them to be withdrawn in groups.  There aren't currently any
users of this facility, but it will simplify some of the NC2 logic
(coming up shortly).

Signed-off-by: Steven Smith <steven.smith@xxxxxxxxxx>
---
 drivers/xen/core/gnttab.c |   35 +++++++++++++++++++++++++++++++++++
 include/xen/gnttab.h      |    5 +++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/drivers/xen/core/gnttab.c b/drivers/xen/core/gnttab.c
index 02790fe..d5caf21 100644
--- a/drivers/xen/core/gnttab.c
+++ b/drivers/xen/core/gnttab.c
@@ -518,6 +518,41 @@ void gnttab_free_grant_references(grant_ref_t head)
 }
 EXPORT_SYMBOL_GPL(gnttab_free_grant_references);
 
+int gnttab_suballoc_grant_references(u16 count, grant_ref_t *old_head,
+                                    grant_ref_t *new_head)
+{
+       grant_ref_t cursor;
+       unsigned nr_allocated;
+
+       *new_head = cursor = *old_head;
+       if (cursor == GNTTAB_LIST_END)
+               return -ENOSPC;
+       nr_allocated = 1;
+       while (nr_allocated < count) {
+               cursor = gnttab_entry(cursor);
+               if (cursor == GNTTAB_LIST_END)
+                       return -ENOSPC;
+               nr_allocated++;
+       }
+       *old_head = gnttab_entry(cursor);
+       gnttab_entry(cursor) = GNTTAB_LIST_END;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(gnttab_suballoc_grant_references);
+
+void gnttab_subfree_grant_references(grant_ref_t head, grant_ref_t *pool)
+{
+       grant_ref_t cursor;
+
+       for (cursor = head;
+            gnttab_entry(cursor) != GNTTAB_LIST_END;
+            cursor = gnttab_entry(cursor))
+               ;
+       gnttab_entry(cursor) = *pool;
+       *pool = head;
+}
+EXPORT_SYMBOL_GPL(gnttab_subfree_grant_references);
+
 int gnttab_alloc_grant_references(u16 count, grant_ref_t *head)
 {
        int h = get_free_entries(count);
diff --git a/include/xen/gnttab.h b/include/xen/gnttab.h
index 30be437..b4610d9 100644
--- a/include/xen/gnttab.h
+++ b/include/xen/gnttab.h
@@ -97,10 +97,15 @@ int gnttab_query_foreign_access(grant_ref_t ref);
  */
 int gnttab_alloc_grant_references(u16 count, grant_ref_t *pprivate_head);
 
+int gnttab_suballoc_grant_references(u16 count, grant_ref_t *old_head,
+                                    grant_ref_t *new_head);
+
 void gnttab_free_grant_reference(grant_ref_t ref);
 
 void gnttab_free_grant_references(grant_ref_t head);
 
+void gnttab_subfree_grant_references(grant_ref_t head, grant_ref_t *pool);
+
 int gnttab_empty_grant_references(const grant_ref_t *pprivate_head);
 
 int gnttab_claim_grant_reference(grant_ref_t *pprivate_head);
-- 
1.6.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>