]> xenbits.xensource.com Git - people/ssmith/netchannel2-pvops.git/commitdiff
Extend the grant tables implementation with an improved allocation batching mechanism.
authorSteven Smith <ssmith@weybridge.uk.xensource.com>
Fri, 2 Oct 2009 16:48:43 +0000 (17:48 +0100)
committerSteven Smith <ssmith@weybridge.uk.xensource.com>
Tue, 6 Oct 2009 13:35:13 +0000 (14:35 +0100)
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@citrix.com>
drivers/xen/grant-table.c
include/xen/grant_table.h

index e327c4c171b8dfd57c418d92ae9349c218eb0fa2..2240adffd7758deddcdc9d822284dfe30f0e1c83 100644 (file)
@@ -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);
index b04026dab0eba682cd1ecb7be24ae59b8d84df10..ef07e91b9f6f526d96f9e8284fce025ea255309c 100644 (file)
@@ -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);