From: Dan Magenheimer Subject: page_list_splice Date: Thu, 5 Mar 2009 20:23:07 +0000 (GMT) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "Xen-Devel (E-mail)" List-Id: xen-devel@lists.xenproject.org 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)=20 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff -r 4ac8bc60c000 xen/include/xen/mm.h --- a/xen/include/xen/mm.h=09Tue Feb 10 05:51:00 2009 +0000 +++ b/xen/include/xen/mm.h=09Thu Mar 05 13:06:42 2009 -0700 @@ -219,6 +221,32 @@ page_list_remove_head(struct page_list_h return page; } =20 +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 =3D list->next; + head->tail =3D list->tail; + return; + } + + first =3D list->next; + last =3D list->tail; + at =3D head->next; + + first->list.prev =3D page_to_mfn(head->next); + head->next =3D first; + + last->list.next =3D page_to_mfn(at); + at->list.prev =3D page_to_mfn(last); +} + #define page_list_for_each(pos, head) \ for ( pos =3D (head)->next; pos; pos =3D page_list_next(pos, head) ) #define page_list_for_each_safe(pos, tmp, head) \