|
|
|
|
|
|
|
|
|
|
xen-ppc-devel
Re: [XenPPC] [linux-ppc-2.6] [XEN][POWERPC] Use a bitmap to manage the f
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
|
|
|
|
|