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 07/17] Extend the grant tables implementation with an

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 07/17] Extend the grant tables implementation with an improved allocation batching mechanism.
From: <steven.smith@xxxxxxxxxx>
Date: Sun, 4 Oct 2009 16:04:23 +0100
Cc: Steven Smith <steven.smith@xxxxxxxxxx>, keir.frasier@xxxxxxxxxx, jeremy@xxxxxxxx, joserenato.santos@xxxxxx
Delivery-date: Sun, 04 Oct 2009 08:24:59 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <cover.1254667618.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.1254667618.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/grant-table.c |   35 +++++++++++++++++++++++++++++++++++
 include/xen/grant_table.h |    5 +++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 3a437a0..4384cef 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -520,6 +520,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/grant_table.h b/include/xen/grant_table.h
index b04026d..ef07e91 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -111,10 +111,15 @@ int gnttab_copy_grant_page(grant_ref_t ref, struct page 
**pagep);
  */
 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>