From patchwork Mon Feb 27 10:53:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xuquan (Euler)" X-Patchwork-Id: 9592927 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 293D660453 for ; Mon, 27 Feb 2017 10:56:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BC4C28375 for ; Mon, 27 Feb 2017 10:56:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1006E2838E; Mon, 27 Feb 2017 10:56:47 +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 70D4628375 for ; Mon, 27 Feb 2017 10:56:46 +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 1ciIwV-0007ql-VE; Mon, 27 Feb 2017 10:54:11 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ciIwU-0007qa-AS for xen-devel@lists.xen.org; Mon, 27 Feb 2017 10:54:10 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 82/5A-23940-15504B85; Mon, 27 Feb 2017 10:54:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJKsWRWlGSWpSXmKPExsVSPpHPSTeAdUu EwYsDphZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bLhlMsBRc0Kh5MvsXewLhTtYuRi0NI4BSj xO9vM1ggnI2MEkfvzWLqYuTkYBPQldh++hQriC0iYC6xdckWRpAiZoGTTBI7d71mA0kICzhJP P15gwWiyF3i0N69bBC2nsShz1PAmlkEVCV+7vsJNpRXIFji6e3VjCA2o4CYxPdTa8DizALiEn OnzQKrlxAQkXh48TQbhC0m8W/XQyhbUWJP3wdWiPoMiYt3m1ghZgpKnJz5hAWiRlLi4IobLBM YhWYhGTsLScssJC0QcR2JBbs/sUHY2hLLFr5mhqmf+nYjVK+vxLwHp4DqQf6/wiix9/llqISi xJTuh+wLGDlXMWoUpxaVpRbpGprpJRVlpmeU5CZm5ugaGhjr5aYWFyemp+YkJhXrJefnbmIER hkDEOxgXLXd8xCjJAeTkiiv2+fNEUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeJcxb4kQEixKTU +tSMvMAcY7TFqCg0dJhPcsSJq3uCAxtzgzHSJ1ilFRSpx3BUhCACSRUZoH1wZLMZcYZaWEeRm BDhHiKUgtys0sQZV/xSjOwagkzHsJZApPZl4J3PRXQIuZgBbPNt4IsrgkESEl1cCofrl9unSI t+qxE38kXm2pu/dlydKNL21eqpv9cxR3k55hIuW387uv95dLh2OXLXrx4G/DhcgnnQ8eFW61P rPWw2hetkt66LywwjNfNI36LQNKTO8kO3/NO/WZ4aqNVrXGPK91ZmtyGthKNLK8MtyPHzARFn vIsGCe0yLBLMX5iQU7ih8Hz+NWYinOSDTUYi4qTgQAKbxijiwDAAA= X-Env-Sender: xuquan8@huawei.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1488192845!29507187!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43805 invoked from network); 27 Feb 2017 10:54:08 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-4.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 27 Feb 2017 10:54:08 -0000 Received: from 172.24.1.60 (EHLO SZXEMI413-HUB.china.huawei.com) ([172.24.1.60]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CPS31316; Mon, 27 Feb 2017 18:54:01 +0800 (CST) Received: from SZXEMI506-MBX.china.huawei.com ([169.254.5.247]) by SZXEMI413-HUB.china.huawei.com ([10.86.210.41]) with mapi id 14.03.0235.001; Mon, 27 Feb 2017 18:53:53 +0800 From: "Xuquan (Quan Xu)" To: "xen-devel@lists.xen.org" Thread-Topic: [PATCH v2] x86/apicv: enhance posted-interrupt processing Thread-Index: AdKQ58FBKbex/kTWTtuB14F7XwXdAA== Date: Mon, 27 Feb 2017 10:53:53 +0000 Message-ID: Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.142.69.246] MIME-Version: 1.0 X-CFilter-Loop: Reflected Cc: "yang.zhang.wz@gmail.com" , "Tian, Kevin" , "quan.xu0@gmail.com" , Jan Beulich , Andrew Cooper , Jun Nakajima , "Gao, Chao" Subject: [Xen-devel] [PATCH v2] x86/apicv: enhance posted-interrupt processing 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From 6b5f702927d832513d270a2bca4634b271f4df47 Mon Sep 17 00:00:00 2001 From: Quan Xu Date: Tue, 28 Feb 2017 02:48:29 +0800 Subject: [PATCH v2] x86/apicv: enhance posted-interrupt processing If guest is already in non-root mode, an posted interrupt will be directly delivered to guest (leaving softirq being set without actually incurring a VM-Exit - breaking desired softirq behavior). Then further posted interrupts will skip the IPI, stay in PIR and not noted until another VM-Exit happens. When target vCPU is in non-root mode and running on remote CPU, posted way is triggered to inject interrupt without VM-Exit. Otherwise, set VCPU_KICK_SOFTIRQ bit to inject interrupt until another VM-Entry as a best effort. Signed-off-by: Quan Xu --- xen/arch/x86/hvm/vmx/vmx.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 1.8.3.1 diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 61925cf..ecdfbbb 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1839,17 +1839,14 @@ static void vmx_process_isr(int isr, struct vcpu *v) static void __vmx_deliver_posted_interrupt(struct vcpu *v) { - bool_t running = v->is_running; + unsigned int cpu = v->processor; vcpu_unblock(v); - if ( running && (in_irq() || (v != current)) ) - { - unsigned int cpu = v->processor; - - if ( !test_and_set_bit(VCPU_KICK_SOFTIRQ, &softirq_pending(cpu)) - && (cpu != smp_processor_id()) ) - send_IPI_mask(cpumask_of(cpu), posted_intr_vector); - } + if ( v->is_running && (in_irq() || (v != current)) && + (cpu != smp_processor_id()) ) + send_IPI_mask(cpumask_of(cpu), posted_intr_vector); + else + set_bit(VCPU_KICK_SOFTIRQ, &softirq_pending(cpu)); } static void vmx_deliver_posted_intr(struct vcpu *v, u8 vector)