qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] s390: Async page fault control
@ 2013-07-09 15:47 Dominik Dingel
  2013-07-09 15:47 ` [Qemu-devel] [PATCH] Enable async page faults Dominik Dingel
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Dingel @ 2013-07-09 15:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cornelia Huck, Christian Borntraeger, Alexander Graf,
	Dominik Dingel, Richard Henderson

Following the current discussion on the kvm ML, here are the qemu bits
regarding async page faults. They are responsible for enabling, disabling
the feature and adding a savevm handler for live migration.

Dominik Dingel (1):
  Enable async page faults with live migration

 target-s390x/kvm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

-- 
1.8.2.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH] Enable async page faults
  2013-07-09 15:47 [Qemu-devel] [PATCH] s390: Async page fault control Dominik Dingel
@ 2013-07-09 15:47 ` Dominik Dingel
  2013-07-10  0:59   ` Andreas Färber
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Dingel @ 2013-07-09 15:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cornelia Huck, Christian Borntraeger, Alexander Graf,
	Dominik Dingel, Richard Henderson

S390 can also use async page faults, to enhance guest scheduling.
But in the case of live migration we want to disable the feature and know
if there are still notifications in flight.

Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
---
 target-s390x/kvm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 42f758f..61df7d4 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -36,6 +36,7 @@
 #include "sysemu/device_tree.h"
 #include "qapi/qmp/qjson.h"
 #include "monitor/monitor.h"
+#include "migration/migration.h"
 
 /* #define DEBUG_KVM */
 
@@ -92,9 +93,50 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 
 static int cap_sync_regs;
 
+static int apf_disable(QEMUFile *f, void *opaque)
+{
+    kvm_vm_ioctl(opaque, KVM_S390_APF_DISABLE);
+    return 0;
+}
+
+static void apf_enable(void *opaque)
+{
+    kvm_vm_ioctl(opaque, KVM_S390_APF_ENABLE);
+}
+
+static int apf_finish(QEMUFile *f, void *opaque, int version_id)
+{
+    apf_enable(opaque);
+    return 0;
+}
+
+static uint64_t apf_status(QEMUFile *f, void *opaque, uint64_t max_size)
+{
+    uint64_t rc = 0;
+
+    if (kvm_vm_ioctl(opaque, KVM_S390_APF_STATUS) !=
+        KVM_S390_APF_DISABLED_NON_PENDING) {
+        rc = 0xff0000;
+    }
+    return rc;
+}
+
+SaveVMHandlers savevm_apf_handlers = {
+    .save_live_setup = apf_disable,
+    .save_live_iterate = NULL,
+    .save_live_complete = NULL,
+    .save_live_pending = apf_status,
+    .load_state = apf_finish,
+    .cancel = apf_enable,
+};
+
 int kvm_arch_init(KVMState *s)
 {
     cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
+    if (kvm_check_extension(s, KVM_CAP_ASYNC_PF)) {
+        register_savevm_live(NULL, "apf", -1, 1, &savevm_apf_handlers, s);
+        kvm_vm_ioctl(s, KVM_S390_APF_ENABLE);
+    }
     return 0;
 }
 
-- 
1.8.2.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] Enable async page faults
  2013-07-09 15:47 ` [Qemu-devel] [PATCH] Enable async page faults Dominik Dingel
@ 2013-07-10  0:59   ` Andreas Färber
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Färber @ 2013-07-10  0:59 UTC (permalink / raw)
  To: Dominik Dingel
  Cc: Cornelia Huck, Christian Borntraeger, Richard Henderson,
	qemu-devel, Alexander Graf

Am 09.07.2013 17:47, schrieb Dominik Dingel:
> S390 can also use async page faults, to enhance guest scheduling.
> But in the case of live migration we want to disable the feature and know
> if there are still notifications in flight.
> 
> Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
> ---
>  target-s390x/kvm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
> 
> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
> index 42f758f..61df7d4 100644
> --- a/target-s390x/kvm.c
> +++ b/target-s390x/kvm.c
> @@ -36,6 +36,7 @@
>  #include "sysemu/device_tree.h"
>  #include "qapi/qmp/qjson.h"
>  #include "monitor/monitor.h"
> +#include "migration/migration.h"
>  
>  /* #define DEBUG_KVM */
>  
> @@ -92,9 +93,50 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
>  
>  static int cap_sync_regs;
>  
> +static int apf_disable(QEMUFile *f, void *opaque)
> +{
> +    kvm_vm_ioctl(opaque, KVM_S390_APF_DISABLE);

Better don't pass opaques directly as a typed argument, especially in a
KVM file not widely tested; we just had such a runtime breakage.
KVMState *s = opaque; elegantly avoids it here and improves readability.

Regards,
Andreas

> +    return 0;
> +}
> +
> +static void apf_enable(void *opaque)
> +{
> +    kvm_vm_ioctl(opaque, KVM_S390_APF_ENABLE);
> +}
> +
> +static int apf_finish(QEMUFile *f, void *opaque, int version_id)
> +{
> +    apf_enable(opaque);
> +    return 0;
> +}
> +
> +static uint64_t apf_status(QEMUFile *f, void *opaque, uint64_t max_size)
> +{
> +    uint64_t rc = 0;
> +
> +    if (kvm_vm_ioctl(opaque, KVM_S390_APF_STATUS) !=
> +        KVM_S390_APF_DISABLED_NON_PENDING) {
> +        rc = 0xff0000;
> +    }
> +    return rc;
> +}
> +
> +SaveVMHandlers savevm_apf_handlers = {
> +    .save_live_setup = apf_disable,
> +    .save_live_iterate = NULL,
> +    .save_live_complete = NULL,
> +    .save_live_pending = apf_status,
> +    .load_state = apf_finish,
> +    .cancel = apf_enable,
> +};
> +
>  int kvm_arch_init(KVMState *s)
>  {
>      cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
> +    if (kvm_check_extension(s, KVM_CAP_ASYNC_PF)) {
> +        register_savevm_live(NULL, "apf", -1, 1, &savevm_apf_handlers, s);
> +        kvm_vm_ioctl(s, KVM_S390_APF_ENABLE);
> +    }
>      return 0;
>  }
>  
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-10  1:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-09 15:47 [Qemu-devel] [PATCH] s390: Async page fault control Dominik Dingel
2013-07-09 15:47 ` [Qemu-devel] [PATCH] Enable async page faults Dominik Dingel
2013-07-10  0:59   ` Andreas Färber

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).