From patchwork Wed Feb 22 17:29:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9587265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8D126600CA for ; Wed, 22 Feb 2017 17:32:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8012C284FB for ; Wed, 22 Feb 2017 17:32:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 744A3285C3; Wed, 22 Feb 2017 17:32:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0AFDA284FB for ; Wed, 22 Feb 2017 17:32:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgajm-0008MS-Jt; Wed, 22 Feb 2017 17:29:58 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgajk-0008MM-VU for xen-devel@lists.xenproject.org; Wed, 22 Feb 2017 17:29:57 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 4C/D6-19998-39ACDA85; Wed, 22 Feb 2017 17:29:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsVybKJsh+7kU2s jDOadkrD4vmUykwOjx+EPV1gCGKNYM/OS8isSWDN2/7jCWHBftOLj77/MDYztQl2MXBxCAlMZ Jf68380K4Rxikvg99xVLFyMnB5uAocTfJ5vYQGwRASWJe6smM4HYzAItjBJzJhqC2MICphIHt h4GquHgYBFQlXh0URMkzCvgJvFx3jNGEFtCQE7i5LHJrBB2hsS8njlQtpfEohuXoGw1iavnNj FPYORZwMiwilGjOLWoLLVI19BYL6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMalYLzk/dxMj0O8 MQLCDcdt2z0OMkhxMSqK8fDvWRgjxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4OUEhpGQYFFqempF WmYOMABh0hIcPEoivMwgad7igsTc4sx0iNQpRl2OUzdOv2QSYsnLz0uVEue9eRKoSACkKKM0D 24ELBouMcpKCfMyAh0lxFOQWpSbWYIq/4pRnINRSZhXBmQVT2ZeCdymV0BHMAEdYekMdkRJIk JKqoFR/8+LLTulN7nyXPpQP6foSR2jmV9KXtPLyCXtznVn6mca9PJleteIvLkYLuz0/utSayu dwrplontuGu5e+Uw5MfzAC5eL6rZeXOu9fgY1hC5guCEYfP9LbrH2fqN7TIceL2CNNtrKeJFb NTHkUfg/6wvZc9deDuIMVv9y4t26Xc1KL6N2LDBXYinOSDTUYi4qTgQATkbKq4ECAAA= X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-6.tower-31.messagelabs.com!1487784594!60592264!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48528 invoked from network); 22 Feb 2017 17:29:55 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-6.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 22 Feb 2017 17:29:55 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 606BA201CE; Wed, 22 Feb 2017 17:29:52 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.hil-pdxphhh.sea.wayport.net (ip-64-134-128-59.public.wayport.net [64.134.128.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 900C2200DE; Wed, 22 Feb 2017 17:29:50 +0000 (UTC) From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Wed, 22 Feb 2017 09:29:47 -0800 Message-Id: <1487784587-16380-1-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 X-Virus-Scanned: ClamAV using ClamSMTP Cc: edgar.iglesias@xilinx.com, julien.grall@arm.com, sstabellini@kernel.org, dario.faggioli@citrix.com, george.dunlap@citrix.com Subject: [Xen-devel] [PATCH v2] xen/arm: introduce vwfi parameter X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Introduce new Xen command line parameter called "vwfi", which stands for virtual wfi. The default is "trap": Xen traps the guest wfi instruction and calls vcpu_block on the guest vcpu. The behavior can be changed setting vwfi to "native", in that case Xen doesn't trap the instruction at all, running it in guest context. The result is strong reduction in irq latency (from 5000ns to 2000ns, measured using https://github.com/edgarigl/tbm, the physical timer, and 1 pcpu dedicated to 1 vcpu). The downside is that the scheduler thinks that the guest is busy when actually is sleeping, leading to suboptimal scheduling decisions. Signed-off-by: Stefano Stabellini CC: dario.faggioli@citrix.com CC: george.dunlap@citrix.com CC: edgar.iglesias@xilinx.com Reviewed-by: Edgar E. Iglesias --- docs/misc/xen-command-line.markdown | 12 ++++++++++++ xen/arch/arm/traps.c | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown index c0106fb..6dea172 100644 --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -1638,6 +1638,18 @@ Note that if **watchdog** option is also specified vpmu will be turned off. As the virtualisation is not 100% safe, don't use the vpmu flag on production systems (see http://xenbits.xen.org/xsa/advisory-163.html)! +### vwfi +> `= trap | native + +> Default: `trap` + +WFI is the ARM instruction to "wait for interrupt". This option, which +is ARM specific, changes the way guest WFI is implemented in Xen. By +default, Xen traps the instruction, then blocks the guest vcpu. When setting +vwfi to `native`, Xen doesn't trap the instruction, running it in guest +context. Setting vwfi to `native` reduces irq latency, but leads to +suboptimal scheduling decisions. + ### watchdog > `= force | ` diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 4f96a2b..3a40717 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -102,6 +102,19 @@ static int debug_stack_lines = 40; integer_param("debug_stack_lines", debug_stack_lines); +static enum { + TRAP, + NATIVE, +} vwfi; + +static void __init parse_vwfi(const char *s) +{ + if ( !strcmp(s, "native") ) + vwfi = NATIVE; + else + vwfi = TRAP; +} +custom_param("vwfi", parse_vwfi); void init_traps(void) { @@ -128,8 +141,8 @@ void init_traps(void) /* Setup hypervisor traps */ WRITE_SYSREG(HCR_PTW|HCR_BSU_INNER|HCR_AMO|HCR_IMO|HCR_FMO|HCR_VM| - HCR_TWE|HCR_TWI|HCR_TSC|HCR_TAC|HCR_SWIO|HCR_TIDCP|HCR_FB, - HCR_EL2); + (vwfi != NATIVE ? HCR_TWI : 0) |HCR_TWE| + HCR_TSC|HCR_TAC|HCR_SWIO|HCR_TIDCP|HCR_FB,HCR_EL2); isb(); }