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-ppc-devel

Re: [XenPPC] [linux-ppc-2.6] [XEN][POWERPC] Use a bitmap to manage the f

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [XenPPC] [linux-ppc-2.6] [XEN][POWERPC] Use a bitmap to manage the foreign page area
From: Muli Ben-Yehuda <muli@xxxxxxxxxx>
Date: Thu, 9 Nov 2006 23:49:58 +0200
Delivery-date: Thu, 09 Nov 2006 13:50:07 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <E1GhxNY-0004q9-DY@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
References: <E1GhxNY-0004q9-DY@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.11
On Thu, Nov 09, 2006 at 12:02:45AM +0000, Xen patchbot-linux-ppc-2.6 wrote:

> +struct page *alloc_foreign_page(void)
> +{
> +     int bit;
> +     do {
> +             bit = find_first_zero_bit(foreign_map_bitmap,
> +                                       foreign_map_pgs);

bit should be 'unsigned long'.

> +             if (bit >= foreign_map_pgs)
> +                     return NULL;

I would print a message that the allocator has been exhausted here -
it's a common source of bugs. Also, tiny optimization, but perhaps you
next fit rather than first fit?

> +     } while (test_and_set_bit(bit, foreign_map_bitmap) == 1);
> +
> +     return pfn_to_page(foreign_map_pfn + bit);
> +}
> +
> +void free_foreign_page(struct page *page)
> +{
> +     int bit = page_to_pfn(page) - foreign_map_pfn;
> +
> +     BUG_ON(bit < 0);
> +     BUG_ON(bit >= foreign_map_pgs);

I would add BUG_ON(!test_bit(bit, foreign_map_bitmap)) here to catch
another common source of bugs.

Cheers,
Muli

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

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