qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Denis Plotnikov <den-plotnikov@yandex-team.ru>, qemu-devel@nongnu.org
Cc: yc-core@yandex-team.ru, mlevitsk@redhat.com
Subject: Re: [Ping][PATCH v0] vl: flush all task from rcu queue before exiting
Date: Wed, 10 Nov 2021 17:29:10 +0100	[thread overview]
Message-ID: <3a8e8e0c-672b-ee72-3fc2-a5f4545416ea@redhat.com> (raw)
In-Reply-To: <830c8775-4d39-f91c-d223-2934d8cc1c21@yandex-team.ru>

On 11/10/21 14:29, Denis Plotnikov wrote:
> 
> On 09.11.2021 20:46, Paolo Bonzini wrote:
>> On 11/9/21 08:23, Denis Plotnikov wrote:
>>> Ping ping!
>>
>> Looks good, but can you explain why it's okay to call it before 
>> qemu_chr_cleanup() and user_creatable_cleanup()?
>>
>> I think a better solution to the ordering problem would be:
>>
>>   qemu_chr_cleanup();
>>   user_creatable_cleanup();
>>   flush_rcu();
>>   monitor_cleanup();
> I agree, this looks better
>>
>> with something like this:
>>
>> diff --git a/chardev/char-fe.c b/chardev/char-fe.c
>> index 7789f7be9c..f0c3ea5447 100644
>> --- a/chardev/char-fe.c
>> +++ b/chardev/char-fe.c
>> @@ -195,6 +195,7 @@ bool qemu_chr_fe_init(CharBackend *b,
>>      int tag = 0;
>>
>>      if (s) {
>> +        object_ref(OBJECT(s));
>>          if (CHARDEV_IS_MUX(s)) {
>>              MuxChardev *d = MUX_CHARDEV(s);
>>
>> @@ -241,6 +242,7 @@ void qemu_chr_fe_deinit(CharBackend *b, bool del)
>>              } else {
>>                  object_unref(obj);
>>              }
>> +            object_unref(obj);
>>          }
>>          b->chr = NULL;
>>      }
>>
>> to keep the chardev live between qemu_chr_cleanup() and 
>> monitor_cleanup().
> 
> but frankly speaking I don't understand why we have to do ref/unref in 
> char-fe interface functions, instead of just ref/uref-ing monitor's char 
> device directly like this:
> 
> diff --git a/monitor/monitor.c b/monitor/monitor.c
> index 21c7a68758f5..3692a8e15268 100644
> --- a/monitor/monitor.c
> +++ b/monitor/monitor.c
> @@ -611,6 +611,7 @@ void monitor_data_destroy(Monitor *mon)
>   {
>       g_free(mon->mon_cpu_path);
>       qemu_chr_fe_deinit(&mon->chr, false);
> +    object_unref(OBJECT(&mon->chr));
>       if (monitor_is_qmp(mon)) {
>           monitor_data_destroy_qmp(container_of(mon, MonitorQMP, common));
>       } else {
> @@ -737,6 +738,7 @@ int monitor_init(MonitorOptions *opts, bool 
> allow_hmp, Error **errp)
>           error_propagate(errp, local_err);
>           return -1;
>       }
> +    object_ref(OBJECT(chr));
>       return 0;
>   }
> 
> May be this shows the intentions better?

Sure, that works too.  But in the end the char-fe _is_ the place where 
the extra reference is taken/dropped (in the ->chr field of 
CharBackend), so I was thinking of a more generic solution too.  Feel 
free to submit yours though, it's certainly safer for 6.2 freeze.

Paolo



      reply	other threads:[~2021-11-10 16:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02 13:39 [PATCH v0] vl: flush all task from rcu queue before exiting Denis Plotnikov
2021-11-02 14:13 ` Denis Plotnikov
2021-11-09  7:23 ` [Ping][PATCH " Denis Plotnikov
2021-11-09 17:46   ` Paolo Bonzini
2021-11-10 13:29     ` Denis Plotnikov
2021-11-10 16:29       ` Paolo Bonzini [this message]

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=3a8e8e0c-672b-ee72-3fc2-a5f4545416ea@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=den-plotnikov@yandex-team.ru \
    --cc=mlevitsk@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yc-core@yandex-team.ru \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).