From patchwork Fri Dec 13 22:48:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 11291907 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD82D139A for ; Fri, 13 Dec 2019 22:49:22 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D7E12253D for ; Fri, 13 Dec 2019 22:49:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="Fd3GB1+w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D7E12253D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iftjX-0003Ao-8b; Fri, 13 Dec 2019 22:48:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iftjV-0003AP-6H for xen-devel@lists.xenproject.org; Fri, 13 Dec 2019 22:48:25 +0000 X-Inumbo-ID: a6a9a308-1dfa-11ea-88e7-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a6a9a308-1dfa-11ea-88e7-bc764e2007e4; Fri, 13 Dec 2019 22:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1576277296; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=COc48C8hnO3YxD5NXPqosfwfgM1CqBkFABkSOGZli4I=; b=Fd3GB1+ww40msNx2Yjju11m4GoFaImlCnH+q4O7oomZ5WRPwYn0hHpOh rL5S09BpFQrzg2PXmH/7WsSdzjHDTxgodtIj/Nmm0GMEPATAGqpf48T+2 WneCrfbtnUbQgJJoR0ipglzkt7JTGDQ6UyuewfsB7s2TfEskJ9kJs2P9S 8=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=igor.druzhinin@citrix.com; spf=Pass smtp.mailfrom=igor.druzhinin@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of igor.druzhinin@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="igor.druzhinin@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of igor.druzhinin@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="igor.druzhinin@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: XRj+dJjBurxpzvqeSaxi80P7h0YwzABaAWh6qJ/gdm1SWVzw80isNX8p25AOchabm/O9rAJ275 5ccQUBqazR0RFl9RNc8DA39PBmYdiGImp0H91MYAE9E1ceaJ1vOSssn9UwrlGcnr5y1QETDBI6 +d15BABrEoZ8+IRbPHYg14ww3E/vtbrU2WufyLbI05EmZ5WRHqRgO6tZGvZT+0VTKko8vN9XGP eTm071Am0VkR2PwRciLQVa3DnsolIiKvBJeqz2g+IjBBN2tfRehyBfeFktymakrmrezqMBQtin nn0= X-SBRS: 2.7 X-MesageID: 10241745 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,311,1571716800"; d="scan'208";a="10241745" From: Igor Druzhinin To: Date: Fri, 13 Dec 2019 22:48:01 +0000 Message-ID: <1576277282-6590-2-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576277282-6590-1-git-send-email-igor.druzhinin@citrix.com> References: <1576277282-6590-1-git-send-email-igor.druzhinin@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/2] x86/time: drop vtsc_{kern, user}count debug counters X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: andrew.cooper3@citrix.com, Igor Druzhinin , wl@xen.org, jbeulich@suse.com, roger.pau@citrix.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" They either need to be transformed to atomics to work correctly (currently they left unprotected for HVM domains) or dropped entirely as taking a per-domain spinlock is too expensive for high-vCPU count domains even for debug build given this lock is taken too often. Choose the latter as they are not extremely important anyway. Signed-off-by: Igor Druzhinin Reviewed-by: Roger Pau Monné Acked-by: Andrew Cooper --- xen/arch/x86/hvm/hvm.c | 32 ++------------------------------ xen/arch/x86/time.c | 12 ------------ xen/include/asm-x86/domain.h | 4 ---- 3 files changed, 2 insertions(+), 46 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 47573f7..614ed60 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3405,37 +3405,9 @@ int hvm_vmexit_cpuid(struct cpu_user_regs *regs, unsigned int inst_len) return hvm_monitor_cpuid(inst_len, leaf, subleaf); } -static uint64_t _hvm_rdtsc_intercept(void) -{ - struct vcpu *curr = current; -#if !defined(NDEBUG) || defined(CONFIG_PERF_COUNTERS) - struct domain *currd = curr->domain; - - if ( currd->arch.vtsc ) - switch ( hvm_guest_x86_mode(curr) ) - { - case 8: - case 4: - case 2: - if ( unlikely(hvm_get_cpl(curr)) ) - { - case 1: - currd->arch.vtsc_usercount++; - break; - } - /* fall through */ - case 0: - currd->arch.vtsc_kerncount++; - break; - } -#endif - - return hvm_get_guest_tsc(curr); -} - void hvm_rdtsc_intercept(struct cpu_user_regs *regs) { - msr_split(regs, _hvm_rdtsc_intercept()); + msr_split(regs, hvm_get_guest_tsc(current)); HVMTRACE_2D(RDTSC, regs->eax, regs->edx); } @@ -3464,7 +3436,7 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) break; case MSR_IA32_TSC: - *msr_content = _hvm_rdtsc_intercept(); + *msr_content = hvm_get_guest_tsc(v); break; case MSR_IA32_TSC_ADJUST: diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 27a3a10..216169a 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -2135,13 +2135,6 @@ uint64_t pv_soft_rdtsc(const struct vcpu *v, const struct cpu_user_regs *regs) spin_lock(&d->arch.vtsc_lock); -#if !defined(NDEBUG) || defined(CONFIG_PERF_COUNTERS) - if ( guest_kernel_mode(v, regs) ) - d->arch.vtsc_kerncount++; - else - d->arch.vtsc_usercount++; -#endif - if ( (int64_t)(now - d->arch.vtsc_last) > 0 ) d->arch.vtsc_last = now; else @@ -2318,11 +2311,6 @@ static void dump_softtsc(unsigned char key) printk(",khz=%"PRIu32, d->arch.tsc_khz); if ( d->arch.incarnation ) printk(",inc=%"PRIu32, d->arch.incarnation); -#if !defined(NDEBUG) || defined(CONFIG_PERF_COUNTERS) - if ( d->arch.vtsc_kerncount | d->arch.vtsc_usercount ) - printk(",vtsc count: %"PRIu64" kernel,%"PRIu64" user", - d->arch.vtsc_kerncount, d->arch.vtsc_usercount); -#endif printk("\n"); domcnt++; } diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 212303f..3780287 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -374,10 +374,6 @@ struct arch_domain hardware TSC scaling cases */ uint32_t incarnation; /* incremented every restore or live migrate (possibly other cases in the future */ -#if !defined(NDEBUG) || defined(CONFIG_PERF_COUNTERS) - uint64_t vtsc_kerncount; - uint64_t vtsc_usercount; -#endif /* Pseudophysical e820 map (XENMEM_memory_map). */ spinlock_t e820_lock;