All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxim Davydov <maxim.davydov@openvz.org>
To: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>,
	qemu-devel@nongnu.org
Cc: eduardo@habkost.net, berrange@redhat.com,
	xiaoguangrong.eric@gmail.com, mst@redhat.com, jsnow@redhat.com,
	crosa@redhat.com, f4bug@amsat.org, chen.zhang@intel.com,
	armbru@redhat.com, wangyanan55@huawei.com,
	marcandre.lureau@redhat.com, imammedo@redhat.com,
	lizhijian@fujitsu.com, pbonzini@redhat.com, ani@anisinha.ca,
	den@openvz.org, eblake@redhat.com
Subject: Re: [PATCH v1 7/9] colo-compare: safe finalization
Date: Mon, 4 Apr 2022 18:20:48 +0300	[thread overview]
Message-ID: <e25206c3-409d-7124-9a70-3aeab94a1190@openvz.org> (raw)
In-Reply-To: <9c5f38c4-d75f-95e0-cabd-3e483c9406ec@mail.ru>

The main problem that if we call object_new_with_class() and then 
object_unref(), it fails. First of all, this is due to the fact that 
finalize expects that net/colo-compare.c:colo_compare_complete() has 
been called before.

On 3/30/22 17:54, Vladimir Sementsov-Ogievskiy wrote:
> 29.03.2022 00:15, Maxim Davydov wrote:
>> Fixes some possible issues with finalization. For example, finalization
>> immediately after instance_init fails on the assert.
>>
>> Signed-off-by: Maxim Davydov <maxim.davydov@openvz.org>
>> ---
>>   net/colo-compare.c | 25 ++++++++++++++++---------
>>   1 file changed, 16 insertions(+), 9 deletions(-)
>>
>> diff --git a/net/colo-compare.c b/net/colo-compare.c
>> index 62554b5b3c..81d8de0aaa 100644
>> --- a/net/colo-compare.c
>> +++ b/net/colo-compare.c
>> @@ -1426,7 +1426,7 @@ static void colo_compare_finalize(Object *obj)
>>               break;
>>           }
>>       }
>> -    if (QTAILQ_EMPTY(&net_compares)) {
if colo_compare_active == false, event_mtx and event_complete_cond 
didn't inited in colo_compare_complete()
>> +    if (QTAILQ_EMPTY(&net_compares) && colo_compare_active) {
>>           colo_compare_active = false;
>>           qemu_mutex_destroy(&event_mtx);
>>           qemu_cond_destroy(&event_complete_cond);
>> @@ -1442,19 +1442,26 @@ static void colo_compare_finalize(Object *obj)
>>         colo_compare_timer_del(s);
>>   -    qemu_bh_delete(s->event_bh);
s->event_bh wasn't allocated in colo_compare_iothread() in 
colo_compare_complete()
>> +    if (s->event_bh) {
>> +        qemu_bh_delete(s->event_bh);
>> +    }
>>   -    AioContext *ctx = iothread_get_aio_context(s->iothread);
>> -    aio_context_acquire(ctx);
>> -    AIO_WAIT_WHILE(ctx, !s->out_sendco.done);
>> -    if (s->notify_dev) {
>> -        AIO_WAIT_WHILE(ctx, !s->notify_sendco.done);
s->iothread == NULL after .instance_init (it can be detected in 
colo_compare_complete(), if it has been called)
>> +    if (s->iothread) {
>> +        AioContext *ctx = iothread_get_aio_context(s->iothread);
>> +        aio_context_acquire(ctx);
>> +        AIO_WAIT_WHILE(ctx, !s->out_sendco.done);
>> +        if (s->notify_dev) {
>> +            AIO_WAIT_WHILE(ctx, !s->notify_sendco.done);
>> +        }
>> +        aio_context_release(ctx);
>>       }
>> -    aio_context_release(ctx);
>>         /* Release all unhandled packets after compare thead exited */
>>       g_queue_foreach(&s->conn_list, colo_flush_packets, s);
>> -    AIO_WAIT_WHILE(NULL, !s->out_sendco.done);
In normal situation, it flushes all packets and sets s->out_sendco.done 
= true via compare_chr_send (we wait this event). But s->conn_list isn't 
initialized, s->out_sendco.done == false and won't become true. So, it's 
infinite waiting.
>> +    /* Without colo_compare_complete done == false without packets */
>> +    if (!g_queue_is_empty(&s->out_sendco.send_list)) {
>> +        AIO_WAIT_WHILE(NULL, !s->out_sendco.done);
>> +    }
>
> I think, would be good to add more description for this last change. 
> It's not as obvious as previous two changes.
>
>> g_queue_clear(&s->conn_list);
>>       g_queue_clear(&s->out_sendco.send_list);
>
>
-- 
Best regards,
Maxim Davydov



  reply	other threads:[~2022-04-04 15:29 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 21:15 [PATCH v1 0/9] Machine type compatible properties Maxim Davydov
2022-03-28 21:15 ` [PATCH v1 1/9] qmp: Add dump machine " Maxim Davydov
2022-03-30 11:03   ` Vladimir Sementsov-Ogievskiy
2022-04-04  9:08     ` Maxim Davydov
2022-03-28 21:15 ` [PATCH v1 2/9] pci: add null-pointer check Maxim Davydov
2022-03-30 11:07   ` Vladimir Sementsov-Ogievskiy
2022-04-04 11:07     ` Maxim Davydov
2022-03-31 11:46   ` Igor Mammedov
2022-03-28 21:15 ` [PATCH v1 3/9] mem: appropriate handling getting mem region Maxim Davydov
2022-03-30 11:27   ` Vladimir Sementsov-Ogievskiy
2022-04-04 11:57     ` Maxim Davydov
2022-03-31 11:43   ` Igor Mammedov
2022-03-28 21:15 ` [PATCH v1 4/9] msmouse: add appropriate unregister handler Maxim Davydov
2022-03-29  8:13   ` Marc-André Lureau
2022-03-28 21:15 ` [PATCH v1 5/9] wctablet: " Maxim Davydov
2022-03-29  8:13   ` Marc-André Lureau
2022-03-28 21:15 ` [PATCH v1 6/9] chardev: add appropriate getting address Maxim Davydov
2022-03-30 11:32   ` Vladimir Sementsov-Ogievskiy
2022-04-04 12:38     ` Maxim Davydov
2022-03-28 21:15 ` [PATCH v1 7/9] colo-compare: safe finalization Maxim Davydov
2022-03-30 14:54   ` Vladimir Sementsov-Ogievskiy
2022-04-04 15:20     ` Maxim Davydov [this message]
2022-03-28 21:15 ` [PATCH v1 8/9] qom: add command to print initial properties Maxim Davydov
2022-03-30 15:17   ` Vladimir Sementsov-Ogievskiy
2022-04-04 15:33     ` Maxim Davydov
2022-03-31 11:55   ` Igor Mammedov
2022-04-04 16:08     ` Maxim Davydov
2022-03-28 21:15 ` [PATCH v1 9/9] scripts: printing machine type compat properties Maxim Davydov
2022-03-30 15:55   ` Vladimir Sementsov-Ogievskiy
2022-03-31 15:38     ` John Snow
2022-03-31 11:51 ` [PATCH v1 0/9] Machine type compatible properties Igor Mammedov
2022-04-21  8:44 ` Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e25206c3-409d-7124-9a70-3aeab94a1190@openvz.org \
    --to=maxim.davydov@openvz.org \
    --cc=ani@anisinha.ca \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=chen.zhang@intel.com \
    --cc=crosa@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=f4bug@amsat.org \
    --cc=imammedo@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=lizhijian@fujitsu.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=v.sementsov-og@mail.ru \
    --cc=wangyanan55@huawei.com \
    --cc=xiaoguangrong.eric@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.