qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 2/2] virtio-blk: Convert QEMUBH callback to "bitops.h" API


From: Stefan Hajnoczi
Subject: Re: [PATCH v3 2/2] virtio-blk: Convert QEMUBH callback to "bitops.h" API
Date: Fri, 21 May 2021 18:37:47 +0100

On Mon, May 10, 2021 at 10:07:58PM +0200, Philippe Mathieu-Daudé wrote:
> By directly using find_first_bit() and find_next_bit from the
> "bitops.h" API to iterate over the bitmap, we can remove the
> bitmap[] variable-length array copy on the stack and the complex
> manual bit testing/clearing logic.
> 
> Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/block/dataplane/virtio-blk.c | 20 +++++---------------
>  1 file changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
> index e9050c8987e..a31fa94ca33 100644
> --- a/hw/block/dataplane/virtio-blk.c
> +++ b/hw/block/dataplane/virtio-blk.c
> @@ -60,24 +60,14 @@ static void notify_guest_bh(void *opaque)
>  {
>      VirtIOBlockDataPlane *s = opaque;
>      unsigned nvqs = s->conf->num_queues;
> -    unsigned long bitmap[BITS_TO_LONGS(nvqs)];
> -    unsigned j;
>  
> -    memcpy(bitmap, s->batch_notify_vqs, sizeof(bitmap));
> -    memset(s->batch_notify_vqs, 0, sizeof(bitmap));
> +    for (unsigned long i = find_first_bit(s->batch_notify_vqs, nvqs);
> +             i < nvqs; i = find_next_bit(s->batch_notify_vqs, nvqs, i)) {

It needs to be find_next_bit(s->batch_notify_vqs, nvqs, i + 1).

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]