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

[Xen-devel] [PATCH 07/17] Extend the grant tables implementation with an improved allocation batching mechanism.



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


 


Rackspace

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