[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] xen: simplify bitmap_to_xenctl_bitmap for little endian
The little endian implementation of bitmap_to_xenctl_bitmap leads to unnecessary xmallocs and xfrees. Given that Xen only supports little endian architectures, it is worth optimizing. This patch removes the need for the xmalloc on little endian architectures. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx> diff --git a/xen/common/bitmap.c b/xen/common/bitmap.c index 3da63a32a6..38d77fc876 100644 --- a/xen/common/bitmap.c +++ b/xen/common/bitmap.c @@ -384,21 +384,26 @@ int bitmap_to_xenctl_bitmap(struct xenctl_bitmap *xenctl_bitmap, uint8_t zero = 0; int err = 0; unsigned int xen_bytes = DIV_ROUND_UP(nbits, BITS_PER_BYTE); - uint8_t *bytemap = xmalloc_array(uint8_t, xen_bytes); - - if ( !bytemap ) - return -ENOMEM; + uint8_t *bytemap = (uint8_t *)bitmap; guest_bytes = DIV_ROUND_UP(xenctl_bitmap->nr_bits, BITS_PER_BYTE); copy_bytes = min(guest_bytes, xen_bytes); - bitmap_long_to_byte(bytemap, bitmap, nbits); + if ( IS_ENABLED(__BIG_ENDIAN) ) + { + bytemap = xmalloc_array(uint8_t, xen_bytes); + if ( !bytemap ) + return -ENOMEM; + + bitmap_long_to_byte(bytemap, bitmap, nbits); + } if ( copy_bytes && copy_to_guest(xenctl_bitmap->bitmap, bytemap, copy_bytes) ) err = -EFAULT; - xfree(bytemap); + if ( IS_ENABLED(__BIG_ENDIAN) ) + xfree(bytemap); for ( i = copy_bytes; !err && i < guest_bytes; i++ ) if ( copy_to_guest_offset(xenctl_bitmap->bitmap, i, &zero, 1) )
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |