qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Laszlo Ersek <lersek@redhat.com>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/2] monitor: maintain at most one G_IO_OUT watch
Date: Tue, 16 Jul 2013 13:58:35 -0500	[thread overview]
Message-ID: <87bo62miw4.fsf@codemonkey.ws> (raw)
In-Reply-To: <1373998781-29561-3-git-send-email-lersek@redhat.com>

Laszlo Ersek <lersek@redhat.com> writes:

> When monitor_flush() is invoked repeatedly outside the monitor_unblocked()
> callback, for example from tlb_info() -> ... -> print_pte(), several
> watches may be added for the same event.
>
> This is no problem per se because the extra monitor_unblocked() callbacks
> are harmless if mon->outbuf is empty, the watches will be removed
> gradually. However a big number of watches can grow "gpollfds" without
> limit in glib_pollfds_fill(), triggering a -1/EINVAL condition in
> g_poll().
>
> Keep at most one such watch, by following the pattern observable in eg.
> commits c874ea97 and c3d6b96e. The change has no effect when
> monitor_unblocked() calls monitor_flush() (when the watch can either be
> removed or renewed 1-for-1), but non-callback contexts won't create an
> additional watch when the monitor already has one.
>
> Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=970047
>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>  monitor.c |   11 +++++++++--
>  1 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 2ba7876..de24b2c 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -189,6 +189,7 @@ struct Monitor {
>      int suspend_cnt;
>      bool skip_flush;
>      QString *outbuf;
> +    guint watch;
>      ReadLineState *rs;
>      MonitorControl *mc;
>      CPUState *mon_cpu;
> @@ -263,7 +264,10 @@ int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
>  static gboolean monitor_unblocked(GIOChannel *chan, GIOCondition cond,
>                                    void *opaque)
>  {
> -    monitor_flush(opaque);
> +    Monitor *mon = opaque;
> +
> +    mon->watch = 0;
> +    monitor_flush(mon);
>      return FALSE;
>  }
>  
> @@ -294,7 +298,10 @@ void monitor_flush(Monitor *mon)
>              QDECREF(mon->outbuf);
>              mon->outbuf = tmp;
>          }
> -        qemu_chr_fe_add_watch(mon->chr, G_IO_OUT, monitor_unblocked, mon);
> +        if (mon->watch == 0) {
> +            mon->watch = qemu_chr_fe_add_watch(mon->chr, G_IO_OUT,
> +                                               monitor_unblocked, mon);
> +        }
>      }
>  }
>  
> -- 
> 1.7.1

  reply	other threads:[~2013-07-16 18:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-16 18:19 [Qemu-devel] [PATCH 0/2] changes related to monitor flow control Laszlo Ersek
2013-07-16 18:19 ` [Qemu-devel] [PATCH 1/2] char: io_channel_send: don't lose written bytes Laszlo Ersek
2013-07-16 18:57   ` Anthony Liguori
2013-07-16 19:26     ` Laszlo Ersek
2013-07-16 19:51       ` Anthony Liguori
2013-07-16 18:19 ` [Qemu-devel] [PATCH 2/2] monitor: maintain at most one G_IO_OUT watch Laszlo Ersek
2013-07-16 18:58   ` Anthony Liguori [this message]
2013-07-17 10:34 ` [Qemu-devel] [PATCH 0/2] changes related to monitor flow control Amit Shah
2013-07-18 19:36 ` Anthony Liguori

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=87bo62miw4.fsf@codemonkey.ws \
    --to=aliguori@us.ibm.com \
    --cc=lcapitulino@redhat.com \
    --cc=lersek@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).