qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 4/9] qcow2-threads: qcow2_co_do_compress: pro


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [Qemu-devel] [PATCH v3 4/9] qcow2-threads: qcow2_co_do_compress: protect queuing by mutex
Date: Tue, 22 Jan 2019 10:22:16 +0000

16.01.2019 2:29, Paolo Bonzini wrote:
> On 08/01/19 18:06, Vladimir Sementsov-Ogievskiy wrote:
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
>> ---
>>   block/qcow2-threads.c | 10 +++++++---
>>   1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/block/qcow2-threads.c b/block/qcow2-threads.c
>> index 20b2616529..156e0667be 100644
>> --- a/block/qcow2-threads.c
>> +++ b/block/qcow2-threads.c
>> @@ -158,15 +158,19 @@ qcow2_co_do_compress(BlockDriverState *bs, void *dest, 
>> size_t dest_size,
>>           .func = func,
>>       };
>>   
>> +    qemu_co_mutex_lock(&s->lock);
>>       while (s->nb_compress_threads >= MAX_COMPRESS_THREADS) {
>> -        qemu_co_queue_wait(&s->compress_wait_queue, NULL);
>> +        qemu_co_queue_wait(&s->compress_wait_queue, &s->lock);
>>       }
>> -
>>       s->nb_compress_threads++;
>> +    qemu_co_mutex_unlock(&s->lock);
>> +
>>       thread_pool_submit_co(pool, qcow2_compress_pool_func, &arg);
>> -    s->nb_compress_threads--;
>>   
>> +    qemu_co_mutex_lock(&s->lock);
>> +    s->nb_compress_threads--;
>>       qemu_co_queue_next(&s->compress_wait_queue);
>> +    qemu_co_mutex_unlock(&s->lock);
>>   
>>       return arg.ret;
>>   }
>>
> 
> Reviewed-by: Paolo Bonzini <address@hidden>
> 
> but, some information would be nice to have in the commit message.

Could you suggest one?

Just, "To make it thread-safe."? I don't have good understanding
of moving from "AioContext lock usage" to other locks, as well as
I don't know how BlockDriverState is going to be used in parallel
threads, and how much of other code is already prepared to work
in multiple-threads environment.

I looked through your commit messages on patches which added protection
to similar places about co-queues, but didn't find detailed description.

> 
> Paolo
> 


-- 
Best regards,
Vladimir

reply via email to

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