[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] virtio-blk: Convert QEMUBH callback to "bitops.h" API
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH] virtio-blk: Convert QEMUBH callback to "bitops.h" API |
Date: |
Thu, 6 May 2021 22:00:43 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 |
On 5/6/21 9:42 PM, Philippe Mathieu-Daudé wrote:
> On 5/6/21 8:22 PM, Richard Henderson wrote:
>> On 5/6/21 8:54 AM, Philippe Mathieu-Daudé wrote:
>>> 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 (j = 0; j < nvqs; j += BITS_PER_LONG) {
>>> - unsigned long bits = bitmap[j / BITS_PER_LONG];
>>> -
>>> - while (bits != 0) {
>>> - unsigned i = j + ctzl(bits);
>>> + for (unsigned i = 0; i < s->conf->num_queues; i++) {
>>
>> Is this bitmap dense enough that you want to iterate by index,
The max is 1Kb:
#define VIRTIO_QUEUE_MAX 1024
>
> By 'iterate by index' do you mean the actual iteration with 'j'?
>
>> or is it
>> sparse enough to iterate via find_first_bit/find_next_bit?
>
> I looked at find_first_bit/find_next_bit() but they seemed to do
> a lot more than test_and_clear_bit(). As Stefan said this is hot
> path, I thought this would be cheaper, but haven't profiled the
> performance.
>
>> In either case, leave the copy of s->conf->num_queues to a local variable.
>
> That is sensible to do :)
>