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] page_list_splice

To: "Xen-Devel (E-mail)" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] page_list_splice
From: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
Date: Thu, 5 Mar 2009 20:23:07 +0000 (GMT)
Delivery-date: Thu, 05 Mar 2009 12:23:44 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Keir, Jan (or anybody familiar with the new page_list_* functions) --

I've implemented page_list_splice as below but I don't
think the second if clause should be necessary...  I'm
using it with this clause because it works for this case
which is nearly always true (splicing into the scrub_list
which is almost always empty).

Without this clause, I get a null-pointer (actually null+4) 
dereference... I think I must be missing some basic
difference between normal list code and page_list code.

Anyway, could you take a look at the routine to see if
I've missed something obvious in the case where neither
page_list parameter is empty?  It's tough to reproduce
this condition and you might be able to see a bug
on inspection.  (Or maybe the differences between normal
list code and page_list code require the extra
page_list_empty check and this code will work properly
regardless of whether one or both page_list is empty.)

Thanks,
Dan

P.S. In case its not obvious, I started from list_splice
in list.h

==============

diff -r 4ac8bc60c000 xen/include/xen/mm.h
--- a/xen/include/xen/mm.h      Tue Feb 10 05:51:00 2009 +0000
+++ b/xen/include/xen/mm.h      Thu Mar 05 13:06:42 2009 -0700
@@ -219,6 +221,32 @@ page_list_remove_head(struct page_list_h
     return page;
 }
 
+static inline void
+page_list_splice(struct page_list_head *list, struct page_list_head *head)
+{
+    struct page_info *first, *last, *at;
+
+    if ( page_list_empty(list) )
+        return;
+
+    if ( page_list_empty(head) )
+    {
+        head->next = list->next;
+        head->tail = list->tail;
+        return;
+    }
+
+    first = list->next;
+    last = list->tail;
+    at = head->next;
+
+    first->list.prev = page_to_mfn(head->next);
+    head->next = first;
+
+    last->list.next = page_to_mfn(at);
+    at->list.prev = page_to_mfn(last);
+}
+
 #define page_list_for_each(pos, head) \
     for ( pos = (head)->next; pos; pos = page_list_next(pos, head) )
 #define page_list_for_each_safe(pos, tmp, head) \

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

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