From patchwork Thu Mar 10 10:07:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Razvan Cojocaru X-Patchwork-Id: 8554721 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 3E842C0553 for ; Thu, 10 Mar 2016 10:09:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6ABAA20320 for ; Thu, 10 Mar 2016 10:09:40 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 00D0A20328 for ; Thu, 10 Mar 2016 10:09:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1adxVN-0001cb-Hd; Thu, 10 Mar 2016 10:07:41 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1adxVL-0001cP-QW for xen-devel@lists.xen.org; Thu, 10 Mar 2016 10:07:40 +0000 Received: from [193.109.254.147] by server-14.bemta-14.messagelabs.com id 6E/FC-02987-B6741E65; Thu, 10 Mar 2016 10:07:39 +0000 X-Env-Sender: rcojocaru@bitdefender.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1457604457!29213541!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27810 invoked from network); 10 Mar 2016 10:07:38 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-4.tower-27.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 10 Mar 2016 10:07:38 -0000 Received: (qmail 17408 invoked from network); 10 Mar 2016 12:07:37 +0200 Received: from unknown (HELO mx-sr.buh.bitdefender.com) (10.17.80.103) by mx01.bbu.dsd.mx.bitdefender.com with AES256-GCM-SHA384 encrypted SMTP; 10 Mar 2016 12:07:37 +0200 Received: from smtp01.buh.bitdefender.com (unknown [10.17.80.75]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id BDA067FC05 for ; Thu, 10 Mar 2016 12:07:36 +0200 (EET) Received: (qmail 2081 invoked from network); 10 Mar 2016 12:07:36 +0200 Received: from xen.dsd.ro (HELO xen.dsd.bitdefender.biz) (rcojocaru@bitdefender.com@10.10.14.109) by smtp01.buh.bitdefender.com with AES128-SHA256 encrypted SMTP; 10 Mar 2016 12:07:35 +0200 From: Razvan Cojocaru To: xen-devel@lists.xen.org Date: Thu, 10 Mar 2016 12:07:23 +0200 Message-Id: <1457604443-32344-1-git-send-email-rcojocaru@bitdefender.com> X-Mailer: git-send-email 1.9.1 X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.4 on smtp01.buh.bitdefender.com, sigver: 7.64797 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.743, Dats: 417318, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.002711)], BW: [Enabled, t: (0.000006,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.005045), Flags: BDD9BED7; NN_LARGER; NN_NO_CONTENT_TYPE; NN_NO_LINK_NMD; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.010150)], URL: [Enabled, t: (0.000005)], RTDA: [Enabled, t: (0.013473), Hit: No, Details: v2.3.3; Id: 2m1gha7.1acu9ka7e.348dd], total: 0(775) X-BitDefender-CF-Stamp: none Cc: andrew.cooper3@citrix.com, keir@xen.org, Razvan Cojocaru , jbeulich@suse.com Subject: [Xen-devel] [PATCH] xen: Don't disable the REP emulation optimizations for regular IO 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 Currently REP emulations optimizations remain disabled even if the emulation does not happen as a result of a vm_event reply requestion emulation (i.e. even for regular IO). This patch takes emulate_each_rep into account only if emulation has been requested by a vm_event-capable application, and is a noticeable speed optimization for monitored guests. Signed-off-by: Razvan Cojocaru Reviewed-by: Andrew Cooper Reviewed-by: Tamas K Lengyel --- xen/arch/x86/hvm/emulate.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 082aa30..ddc8007 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -498,6 +498,7 @@ static int hvmemul_virtual_to_linear( { struct segment_register *reg; int okay; + unsigned long max_reps = 4096; if ( seg == x86_seg_none ) { @@ -506,16 +507,21 @@ static int hvmemul_virtual_to_linear( } /* + * If introspection has been enabled for this domain, and we're emulating + * becase a vm_reply asked us to (i.e. not doing regular IO) reps should + * be at most 1, since optimization might otherwise cause a single + * vm_event being triggered for repeated writes to a whole page. + */ + if ( unlikely(current->domain->arch.mem_access_emulate_each_rep) && + current->arch.vm_event->emulate_flags != 0 ) + max_reps = 1; + + /* * Clip repetitions to avoid overflow when multiplying by @bytes_per_rep. * The chosen maximum is very conservative but it's what we use in * hvmemul_linear_to_phys() so there is no point in using a larger value. - * If introspection has been enabled for this domain, *reps should be - * at most 1, since optimization might otherwise cause a single vm_event - * being triggered for repeated writes to a whole page. */ - *reps = min_t(unsigned long, *reps, - unlikely(current->domain->arch.mem_access_emulate_each_rep) - ? 1 : 4096); + *reps = min_t(unsigned long, *reps, max_reps); reg = hvmemul_get_seg_reg(seg, hvmemul_ctxt);