qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	mdroth@linux.vnet.ibm.com, peterx@redhat.com,
	Eric Blake <eblake@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: [Qemu-devel] [RFC 0/6] monitor: allow per-monitor thread
Date: Mon, 21 Aug 2017 15:44:18 +0800	[thread overview]
Message-ID: <1503301464-27886-1-git-send-email-peterx@redhat.com> (raw)

This is an extended work for migration postcopy recovery. This series
is tested with the following series to make sure it solves the monitor
hang problem that we have encountered for postcopy recovery:

  [RFC 00/29] Migration: postcopy failure recovery
  [RFC 0/6] migration: re-use migrate_incoming for postcopy recovery

The root problem is that, monitor commands are all handled in main
loop thread now, no matter how many monitors we specify. And, if main
loop thread hangs due to some reason, all monitors will be stuck.
This can be done in reversed order as well: if any of the monitor
hangs, it will hang the main loop, and the rest of the monitors (if
there is any).

That affects postcopy recovery, since the recovery requires user input
on destination side.  If monitors hang, the destination VM dies and
lose hope for even a final recovery.

So, sometimes we need to make sure the monitor be alive, at least one
of them.

The whole idea of this series is that instead if handling monitor
commands all in main loop thread, we do it separately in per-monitor
threads.  Then, even if main loop thread hangs at any point by any
reason, per-monitor thread can still survive.  Further, we add hint in
QMP/HMP to show whether a command can be executed without QMP, if so,
we avoid taking BQL when running that command.  It greatly reduced
contention of BQL.  Now the only user of that new parameter (currently
I call it "without-bql") is "migrate-incoming" command, which is the
only command to rescue a paused postcopy migration.

However, even with the series, it does not mean that per-monitor
threads will never hang.  One example is that we can still run "info
vcpus" in per-monitor threads during a paused postcopy (in that state,
page faults are never handled, and "info cpus" will never return since
it tries to sync every vcpus).  So to make sure it does not hang, we
not only need the per-monitor thread, the user should be careful as
well on how to use it.

For postcopy recovery, we may need dedicated monitor channel for
recovery.  In other words, a destination VM that supports postcopy
recovery would possibly need:

  -qmp MAIN_CHANNEL -qmp RECOVERY_CHANNEL

Here, the MAIN_CHANNEL can be MUXed and shared by other chardev
frontends, while the RECOVERY_CHANNEL should *ONLY* be used to input
the "migrate-incoming" command (similar thing applies to HMP
channels).  As long as we are following this rule, the
RECOVERY_CHANNEL can never hang.

Some details on each patch:

Patch 1: a simple cleanup only

Patch 2: allow monitors to create per-monitor thread to handle monitor
         command requests. Since monitor is only one type of chardev
         frontend, we only do this if the backend is dedicated, say,
         if MUX is not turned on (if MUX is on, it's still using main
         loop thread).

Patch 3: based on patch 2, this patch introduced a new parameter for
         QMP commands called "without-bql", it is a hint that the
         command does not need BQL.

Patch 4: Let QMP command "migrate-incoming" avoid taking BQL.

Patch 5: Introduced sister parameter for HMP "without_bql", which
         works just like QMP "without-bql".

Patch 6: Let HMP command "migrate-incoming" avoid taking BQL.

Please review. Thanks,

Peter Xu (6):
  monitor: move skip_flush into monitor_data_init
  monitor: allow monitor to create thread to poll
  QAPI: new QMP command option "without-bql"
  migration: qmp: migrate_incoming don't need BQL
  hmp: support "without_bql"
  migration: hmp: migrate_incoming don't need BQL

 docs/devel/qapi-code-gen.txt | 10 +++++-
 hmp-commands.hx              |  1 +
 include/qapi/qmp/dispatch.h  |  1 +
 monitor.c                    | 79 ++++++++++++++++++++++++++++++++++++++++----
 qapi-schema.json             |  3 +-
 qapi/qmp-dispatch.c          | 26 +++++++++++++++
 scripts/qapi-commands.py     | 18 +++++++---
 scripts/qapi-introspect.py   |  2 +-
 scripts/qapi.py              | 15 ++++++---
 scripts/qapi2texi.py         |  2 +-
 10 files changed, 137 insertions(+), 20 deletions(-)

-- 
2.7.4

             reply	other threads:[~2017-08-21  7:52 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21  7:44 Peter Xu [this message]
2017-08-21  7:44 ` [Qemu-devel] [RFC 1/6] monitor: move skip_flush into monitor_data_init Peter Xu
2017-08-21  7:44 ` [Qemu-devel] [RFC 2/6] monitor: allow monitor to create thread to poll Peter Xu
2017-08-21  7:44 ` [Qemu-devel] [RFC 3/6] QAPI: new QMP command option "without-bql" Peter Xu
2017-08-21  7:44 ` [Qemu-devel] [RFC 4/6] migration: qmp: migrate_incoming don't need BQL Peter Xu
2017-08-21  7:44 ` [Qemu-devel] [RFC 5/6] hmp: support "without_bql" Peter Xu
2017-08-21  7:44 ` [Qemu-devel] [RFC 6/6] migration: hmp: migrate_incoming don't need BQL Peter Xu
2017-08-21  8:58 ` [Qemu-devel] [RFC 0/6] monitor: allow per-monitor thread Fam Zheng
2017-08-21 10:05   ` Peter Xu
2017-08-21 10:17     ` Dr. David Alan Gilbert
2017-08-21 14:04       ` Fam Zheng
2017-08-21 14:06         ` Dr. David Alan Gilbert
2017-08-21 13:57     ` Fam Zheng
2017-08-21 15:36       ` Dr. David Alan Gilbert
2017-08-21 16:54         ` Fam Zheng
2017-08-21 17:28           ` Dr. David Alan Gilbert
2017-08-22  2:15             ` Fam Zheng
2017-08-22  2:56               ` Peter Xu
2017-08-22  4:15                 ` Fam Zheng
2017-08-22  5:59                   ` Peter Xu
2017-08-22  6:33                     ` Fam Zheng
2017-08-22  6:56                       ` Peter Xu
2017-08-22  8:29                       ` Dr. David Alan Gilbert
2017-08-22  8:48                         ` Fam Zheng
2017-08-22  8:48                   ` Dr. David Alan Gilbert
2017-08-22  4:51 ` no-reply
2017-08-22  6:21   ` Peter Xu

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=1503301464-27886-1-git-send-email-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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 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).