From patchwork Wed Dec 23 14:53:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 7913011 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8BAEEBEEE5 for ; Wed, 23 Dec 2015 14:57:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82691205DC for ; Wed, 23 Dec 2015 14:57:38 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 674BC205D3 for ; Wed, 23 Dec 2015 14:57:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aBko1-0002be-Au; Wed, 23 Dec 2015 14:54:21 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aBknz-0002bZ-FB for xen-devel@lists.xenproject.org; Wed, 23 Dec 2015 14:54:19 +0000 Received: from [85.158.143.35] by server-3.bemta-4.messagelabs.com id FE/98-31122-A95BA765; Wed, 23 Dec 2015 14:54:18 +0000 X-Env-Sender: tamas.k.lengyel@gmail.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1450882458!6888529!1 X-Originating-IP: [74.125.82.41] X-SpamReason: No, hits=0.7 required=7.0 tests=BODY_RANDOM_LONG, RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 65386 invoked from network); 23 Dec 2015 14:54:18 -0000 Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by server-11.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Dec 2015 14:54:18 -0000 Received: by mail-wm0-f41.google.com with SMTP id p187so151639748wmp.0 for ; Wed, 23 Dec 2015 06:54:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=asrH+IkU6P16L2mPBQmCy0AK41CxJoHq4p3ygqD9LWg=; b=Ko20oBoQoK+z+2acAWyj7bRbpBmrCk58YVlNyKGa32JqxO8M/RcDsuQ+tTV/MrGvzY tDFVV/OzG1dzQw6O3vCYbYm5jZrfEzG7Hqzu7SNMQLGS+Sfcu5ViyRntDH+AKUIIl/56 G5orus42Yhf+S3K1tcbz98QJWfumNLOsq8Y9xfh0nex5uHcoDYtJnPB5TnfrAUQhNLfF G4CAm5rpNAZIpaaDU3FOqjfMiRxqTB6k1Aar7lv7nl4wejDY2YGnlADE9AB/BJjOexou UIxvwmrfyhBcYcqBrnA0jcHgptXS+wuQuDzrc3VwZ4vw5FeuPaeuXDAQv7TZxgcwBR00 mE1w== X-Received: by 10.28.171.135 with SMTP id u129mr32067360wme.99.1450882457841; Wed, 23 Dec 2015 06:54:17 -0800 (PST) Received: from localhost.localdomain (catv-5-148-229-101.catv.broadband.hu. [5.148.229.101]) by smtp.gmail.com with ESMTPSA id 186sm29637406wmv.9.2015.12.23.06.54.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Dec 2015 06:54:16 -0800 (PST) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Wed, 23 Dec 2015 15:53:51 +0100 Message-Id: <1450882432-10484-1-git-send-email-tamas@tklengyel.com> X-Mailer: git-send-email 2.1.4 Cc: Tamas K Lengyel , Wei Liu , Ian Campbell , Razvan Cojocaru , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 1/2] vm_event: sync domctl X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce new vm_event domctl option which allows an event subscriber to request all vCPUs not currently pending a vm_event request to be paused, thus allowing the subscriber to sync up on the state of the domain. This is especially useful when the subscribed wants to disable certain events from being delivered and wants to ensure no more requests are pending on the ring before doing so. Cc: Ian Jackson Cc: Stefano Stabellini Cc: Ian Campbell Cc: Wei Liu Cc: Razvan Cojocaru Signed-off-by: Tamas K Lengyel Acked-by: Ian Campbell --- tools/libxc/include/xenctrl.h | 11 +++++++++++ tools/libxc/xc_vm_event.c | 16 ++++++++++++++++ xen/common/vm_event.c | 23 +++++++++++++++++++++++ xen/include/public/domctl.h | 14 +++++++++++++- 4 files changed, 63 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 01a6dda..27bb907 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2433,6 +2433,17 @@ int xc_monitor_emulate_each_rep(xc_interface *xch, domid_t domain_id, bool enable); /*** + * xc_vm_event_sync_on can be used by a vm_event subscriber to pause all vCPUs + * that do not currently have a pending vm_event request. This allows the + * subscriber to sync up on the domain's status and process all outstanding + * vm_event requests without any new ones being placed on the ring. A caller + * of xc_vm_event_sync_on can resume these vCPUs by calling + * xc_vm_event_sync_off. + */ +int xc_vm_event_sync_on(xc_interface *xch, domid_t domain_id); +int xc_vm_event_sync_off(xc_interface *xch, domid_t domain_id); + +/*** * Memory sharing operations. * * Unles otherwise noted, these calls return 0 on succes, -1 and errno on diff --git a/tools/libxc/xc_vm_event.c b/tools/libxc/xc_vm_event.c index 2fef96a..6b39908 100644 --- a/tools/libxc/xc_vm_event.c +++ b/tools/libxc/xc_vm_event.c @@ -156,3 +156,19 @@ void *xc_vm_event_enable(xc_interface *xch, domid_t domain_id, int param, return ring_page; } + +int xc_vm_event_sync_on(xc_interface *xch, domid_t domain_id) +{ + return xc_vm_event_control(xch, domain_id, + XEN_VM_EVENT_ENABLE, + XEN_DOMCTL_VM_EVENT_OP_SYNC, + NULL); +} + +int xc_vm_event_sync_off(xc_interface *xch, domid_t domain_id) +{ + return xc_vm_event_control(xch, domain_id, + XEN_VM_EVENT_DISABLE, + XEN_DOMCTL_VM_EVENT_OP_SYNC, + NULL); +} diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 28a7add..b8298bd 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -726,6 +726,29 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, break; #endif + case XEN_DOMCTL_VM_EVENT_OP_SYNC: + { + struct vcpu *v; + rc = 0; + + switch( vec->op ) + { + case XEN_VM_EVENT_ENABLE: + for_each_vcpu( d, v ) + if ( !atomic_read(&v->vm_event_pause_count) ) + vcpu_pause(v); + break; + + default: + for_each_vcpu( d, v ) + if ( !atomic_read(&v->vm_event_pause_count) ) + vcpu_unpause(v); + break; + }; + } + break; + + default: rc = -ENOSYS; } diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 7a56b3f..486c667 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -749,7 +749,8 @@ struct xen_domctl_gdbsx_domstatus { * sharing, monitor and paging. This hypercall allows one to * control these rings (enable/disable), as well as to signal * to the hypervisor to pull responses (resume) from the given - * ring. + * ring. Sync will pause/unpause all vCPUs which don't have + * a pending vm_event. */ #define XEN_VM_EVENT_ENABLE 0 #define XEN_VM_EVENT_DISABLE 1 @@ -810,6 +811,17 @@ struct xen_domctl_gdbsx_domstatus { */ #define XEN_DOMCTL_VM_EVENT_OP_SHARING 3 +/* + * SYNC is a special vm_event operation where all vCPUs get paused + * to allow the toolstack to sync up with the state of the domain, + * without any new vm_event requests being produced by the domain + * on any of the rings. + * When issued with ENABLE all the vCPUs get paused that aren't + * already paused for a vm_event request. When issued with DISABLE + * or RESUME the vCPUs without a pending vm_event request get unpaused. + */ +#define XEN_DOMCTL_VM_EVENT_OP_SYNC 4 + /* Use for teardown/setup of helper<->hypervisor interface for paging, * access and sharing.*/ struct xen_domctl_vm_event_op {