From: Paolo Bonzini <pbonzini@redhat.com>
To: Satoru Moriya <satoru.moriya@hds.com>
Cc: "jan.kiszka@siemens.com" <jan.kiszka@siemens.com>,
"dle-develop@lists.sourceforge.net"
<dle-develop@lists.sourceforge.net>,
Seiji Aguchi <seiji.aguchi@hds.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"mtosatti@redhat.com" <mtosatti@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] Add option to mlock qemu and guest memory
Date: Tue, 12 Mar 2013 10:40:23 +0100 [thread overview]
Message-ID: <513EF807.8040607@redhat.com> (raw)
In-Reply-To: <8631DC5930FA9E468F04F3FD3A5D007214B0C1F2@USINDEM103.corp.hds.com>
Il 14/02/2013 21:21, Satoru Moriya ha scritto:
> We have some plans to migrate legacy enterprise systems which require
> low latency (10 msec order) to kvm virtualized environment. In our
> usecase, the system runs with other untrusted guests and so locking
> memory which is used by the system is needed to avoid latency
> impacts from other guests' memory activity.
>
> ChangeLog:
> v2
> - Change the option name from -mlock to -realtime mlock=on|off
> - Rebase qemu version 1.3.91
> - Update patch description
>
> ---
> In certain scenario, latency induced by paging is significant and
> memory locking is needed. Also, in the scenario with untrusted
> guests, latency improvement due to mlock is desired.
>
> This patch introduces a following new option to mlock guest and
> qemu memory:
>
> -realtime mlock=on|off
>
> Signed-off-by: Satoru Moriya <satoru.moriya@hds.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
As a follow up it would be nice to move -mem-prealloc/-mem-path under
-realtime as well.
Paolo
> ---
> include/sysemu/os-posix.h | 1 +
> include/sysemu/os-win32.h | 1 +
> os-posix.c | 8 ++++++++
> qemu-options.hx | 13 +++++++++++++
> vl.c | 31 +++++++++++++++++++++++++++++++
> 5 files changed, 54 insertions(+)
>
> diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h
> index 7f198e4..2f2ead6 100644
> --- a/include/sysemu/os-posix.h
> +++ b/include/sysemu/os-posix.h
> @@ -31,6 +31,7 @@ void os_set_proc_name(const char *s);
> void os_setup_signal_handling(void);
> void os_daemonize(void);
> void os_setup_post(void);
> +void os_mlock(void);
>
> typedef struct timeval qemu_timeval;
> #define qemu_gettimeofday(tp) gettimeofday(tp, NULL)
> diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
> index bf9edeb..a74ca13 100644
> --- a/include/sysemu/os-win32.h
> +++ b/include/sysemu/os-win32.h
> @@ -80,6 +80,7 @@ static inline void os_daemonize(void) {}
> static inline void os_setup_post(void) {}
> void os_set_line_buffering(void);
> static inline void os_set_proc_name(const char *dummy) {}
> +static inline void os_mlock(void) {}
>
> #if !defined(EPROTONOSUPPORT)
> # define EPROTONOSUPPORT EINVAL
> diff --git a/os-posix.c b/os-posix.c
> index 5c64518..1304b0e 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -363,3 +363,11 @@ bool is_daemonized(void)
> {
> return daemonize;
> }
> +
> +void os_mlock(void)
> +{
> + if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
> + perror("mlockall");
> + exit(1);
> + }
> +}
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 9d7131a..843fcb4 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2464,6 +2464,19 @@ STEXI
> Do not start CPU at startup (you must type 'c' in the monitor).
> ETEXI
>
> +DEF("realtime", HAS_ARG, QEMU_OPTION_realtime,
> + "-realtime [mlock=on|off]\n"
> + " run qemu with realtime features\n"
> + " mlock=on|off controls mlock support (default: on)\n",
> + QEMU_ARCH_ALL)
> +STEXI
> +@item -realtime mlock=on|off
> +@findex -realtime
> +Run qemu with realtime features.
> +mlocking qemu and guest memory can be enabled via @option{mlock=on}
> +(enabled by default).
> +ETEXI
> +
> DEF("gdb", HAS_ARG, QEMU_OPTION_gdb, \
> "-gdb dev wait for gdb connection on 'dev'\n", QEMU_ARCH_ALL)
> STEXI
> diff --git a/vl.c b/vl.c
> index 1355f69..c16c8ad 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -491,6 +491,18 @@ static QemuOptsList qemu_object_opts = {
> },
> };
>
> +static QemuOptsList qemu_realtime_opts = {
> + .name = "realtime",
> + .head = QTAILQ_HEAD_INITIALIZER(qemu_realtime_opts.head),
> + .desc = {
> + {
> + .name = "mlock",
> + .type = QEMU_OPT_BOOL,
> + },
> + { /* end of list */ }
> + },
> +};
> +
> const char *qemu_get_vm_name(void)
> {
> return qemu_name;
> @@ -1384,6 +1396,17 @@ static void smp_parse(const char *optarg)
> max_cpus = smp_cpus;
> }
>
> +static void configure_realtime(QemuOpts *opts)
> +{
> + bool is_mlock;
> +
> + is_mlock = qemu_opt_get_bool(opts, "mlock", true);
> +
> + if (is_mlock) {
> + os_mlock();
> + }
> +}
> +
> /***********************************************************/
> /* USB devices */
>
> @@ -2860,6 +2883,7 @@ int main(int argc, char **argv, char **envp)
> qemu_add_opts(&qemu_sandbox_opts);
> qemu_add_opts(&qemu_add_fd_opts);
> qemu_add_opts(&qemu_object_opts);
> + qemu_add_opts(&qemu_realtime_opts);
>
> runstate_init();
>
> @@ -3806,6 +3830,13 @@ int main(int argc, char **argv, char **envp)
> exit(1);
> }
> break;
> + case QEMU_OPTION_realtime:
> + opts = qemu_opts_parse(qemu_find_opts("realtime"), optarg, 0);
> + if (!opts) {
> + exit(1);
> + }
> + configure_realtime(opts);
> + break;
> default:
> os_parse_cmd_args(popt->index, optarg);
> }
>
next prev parent reply other threads:[~2013-03-12 9:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <8631DC5930FA9E468F04F3FD3A5D007214B0C1F2@USINDEM103.corp.hds.com>
2013-03-02 0:11 ` [Qemu-devel] [PATCH v2] Add option to mlock qemu and guest memory Satoru Moriya
2013-03-12 9:40 ` Paolo Bonzini [this message]
2013-03-15 17:21 ` Satoru Moriya
2013-03-16 1:44 ` Marcelo Tosatti
2013-03-21 9:08 ` Jan Kiszka
2013-03-21 19:08 ` Satoru Moriya
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=513EF807.8040607@redhat.com \
--to=pbonzini@redhat.com \
--cc=dle-develop@lists.sourceforge.net \
--cc=jan.kiszka@siemens.com \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=satoru.moriya@hds.com \
--cc=seiji.aguchi@hds.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).