Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10546464ybi; Thu, 11 Jul 2019 07:04:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeBzvq7mZEfuN3cOR2zfra4J/8WwKu1XkHmedVxOwlt39ec7ECu99cej9F6TIe/xDpBNqG X-Received: by 2002:a63:1462:: with SMTP id 34mr4616137pgu.417.1562853874403; Thu, 11 Jul 2019 07:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562853874; cv=none; d=google.com; s=arc-20160816; b=XBREIV4vnt5EeFXuecCWMofJxK8bhDa/DE1qS12LXi9dZqfV9LHHxii3wrQTFHdfGk 4JjPSXUGyxXDeXkWVi1Nx5zgiOXMQ7UaypC2155Y8c1qjchuQH7q7FNIeF0dPaw1fOIf YQgNiAjk4aiY9sEREU9yPU7SQZLHj0vb9A7sO6Qto3iHA2o1OaBAX/7kM4qjtNfyZnA3 3lAKb9r1WOOBBifhvwqJ0/qkBLeKkzj8eRX7RfIF/D6hWKPEkz9AbEx1zCBqfL7DoAgF XjaQpmAzUeM0Sbf9qVZKMWiS8D8g7F6XGJlDiN8bqI2Ic70uKRHGSr6VMucIZx9nyT6s ZYiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=6QbsSGvqJ1CROTsT5zLLVFOwwglNu1pmlg45SGVssb4=; b=zO1kBzk75v5ALdEFx5UQKdxHMGxzpj1atXit+aDkuAc6D9gqlDOxTUAQa7TDy/MMq1 xzhcZPDawXqzDwbWmj2kIpXkT4a878iHNmHWfVOKf9Q8dzrbu7NIjWrna50Wu7nSYkgi TDIdzD1996X7ctkYKuXN6UMRrMISsjf333SCLN0uB7ncWpXNZmtD5B85i/xH2AyLA3tR 3zPZ8fclu2l0xOw/Vp0xM72+VB8AGzK1Kmz6EzKcpF6Q3N/vsHRgdJT0WO/CyuCr42GC lwEZLCQPodnBTF3ovdWbX8thF1QKVgIa36KK+nBYNoECyb2pbZnc7SsskcefIyZin5A/ g26Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s101si5093651pjc.5.2019.07.11.07.04.17; Thu, 11 Jul 2019 07:04:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728415AbfGKOD5 (ORCPT + 99 others); Thu, 11 Jul 2019 10:03:57 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40765 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728298AbfGKOD5 (ORCPT ); Thu, 11 Jul 2019 10:03:57 -0400 Received: by mail-wm1-f67.google.com with SMTP id v19so5826245wmj.5 for ; Thu, 11 Jul 2019 07:03:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6QbsSGvqJ1CROTsT5zLLVFOwwglNu1pmlg45SGVssb4=; b=DYsY9OqK4OLIZEhPxuBx5l/5QNhmF+aHXjh0sCNnf93EMvsO+nqpSlBx++xQmWvou4 K+pPvcT8ceyoe8idSv/SR8Pmg+HwETrq2fBkid/nkzUlYSBSIaxy/PkxxQXcB4B/TLSK tU6vpPIhlQrCjZfIW+kENajBU35U0MBEKVAOKElI3qY/8YFmEZ/y1453yPaUV4+nTD0a NVbGgOH1/6NAl3aIvof1K5Ckg15QFEytQ/xRH6cTxLEuKJ3Rm/3yOkIqFT0jVB1DO+Qb sIxpm3aOjjbir3B8KqJA46pcEBi32OTF4hj1IHb8jc7cz9+JApUkz6PYTv6rP8cDB7St 60vg== X-Gm-Message-State: APjAAAXa2cZT/x68K5Z3gMXSUAoxkZPP5u/6k8++bgfGOdr4Io4Q2Hzb lKn/JOxKfwWAiphTeo3S1sT92g== X-Received: by 2002:a1c:f61a:: with SMTP id w26mr4738999wmc.75.1562853835240; Thu, 11 Jul 2019 07:03:55 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:d066:6881:ec69:75ab? ([2001:b07:6468:f312:d066:6881:ec69:75ab]) by smtp.gmail.com with ESMTPSA id m16sm5509406wrv.89.2019.07.11.07.03.54 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2019 07:03:54 -0700 (PDT) Subject: Re: [PATCH v7 0/2] KVM: LAPIC: Implement Exitless Timer To: Wanpeng Li Cc: "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Marcelo Tosatti References: <1562376411-3533-1-git-send-email-wanpengli@tencent.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: <0e05bac0-af49-996a-c5fd-f6c61782ae4f@redhat.com> Date: Thu, 11 Jul 2019 16:03:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/07/19 15:50, Wanpeng Li wrote: > kindly ping, Sorry, I need more time to review this. It's basically the only remaining item for the 5.3 merge window, even though it won't be part of the first pull request to Linus. Paolo >> Dedicated instances are currently disturbed by unnecessary jitter due >> to the emulated lapic timers fire on the same pCPUs which vCPUs resident. >> There is no hardware virtual timer on Intel for guest like ARM. Both >> programming timer in guest and the emulated timer fires incur vmexits. >> This patchset tries to avoid vmexit which is incurred by the emulated >> timer fires in dedicated instance scenario. >> >> When nohz_full is enabled in dedicated instances scenario, the unpinned >> timer will be moved to the nearest busy housekeepers after commit >> 9642d18eee2cd (nohz: Affine unpinned timers to housekeepers) and commit >> 444969223c8 ("sched/nohz: Fix affine unpinned timers mess"). However, >> KVM always makes lapic timer pinned to the pCPU which vCPU residents, the >> reason is explained by commit 61abdbe0 (kvm: x86: make lapic hrtimer >> pinned). Actually, these emulated timers can be offload to the housekeeping >> cpus since APICv is really common in recent years. The guest timer interrupt >> is injected by posted-interrupt which is delivered by housekeeping cpu >> once the emulated timer fires. >> >> The host admin should fine tuned, e.g. dedicated instances scenario w/ >> nohz_full cover the pCPUs which vCPUs resident, several pCPUs surplus >> for busy housekeeping, disable mwait/hlt/pause vmexits to keep in non-root >> mode, ~3% redis performance benefit can be observed on Skylake server. >> >> w/o patchset: >> >> VM-EXIT Samples Samples% Time% Min Time Max Time Avg time >> >> EXTERNAL_INTERRUPT 42916 49.43% 39.30% 0.47us 106.09us 0.71us ( +- 1.09% ) >> >> w/ patchset: >> >> VM-EXIT Samples Samples% Time% Min Time Max Time Avg time >> >> EXTERNAL_INTERRUPT 6871 9.29% 2.96% 0.44us 57.88us 0.72us ( +- 4.02% ) >> >> Cc: Paolo Bonzini >> Cc: Radim Krčmář >> Cc: Marcelo Tosatti >> >> v6 -> v7: >> * remove bool argument >> >> v5 -> v6: >> * don't overwrites whatever the user specified >> * introduce kvm_can_post_timer_interrupt and kvm_use_posted_timer_interrupt >> * remove kvm_hlt_in_guest() condition >> * squash all of 2/3/4 together >> >> v4 -> v5: >> * update patch description in patch 1/4 >> * feed latest apic->lapic_timer.expired_tscdeadline to kvm_wait_lapic_expire() >> * squash advance timer handling to patch 2/4 >> >> v3 -> v4: >> * drop the HRTIMER_MODE_ABS_PINNED, add kick after set pending timer >> * don't posted inject already-expired timer >> >> v2 -> v3: >> * disarming the vmx preemption timer when posted_interrupt_inject_timer_enabled() >> * check kvm_hlt_in_guest instead >> >> v1 -> v2: >> * check vcpu_halt_in_guest >> * move module parameter from kvm-intel to kvm >> * add housekeeping_enabled >> * rename apic_timer_expired_pi to kvm_apic_inject_pending_timer_irqs >> >> >> Wanpeng Li (2): >> KVM: LAPIC: Make lapic timer unpinned >> KVM: LAPIC: Inject timer interrupt via posted interrupt >> >> arch/x86/kvm/lapic.c | 109 ++++++++++++++++++++++++++-------------- >> arch/x86/kvm/lapic.h | 1 + >> arch/x86/kvm/vmx/vmx.c | 3 +- >> arch/x86/kvm/x86.c | 12 +++-- >> arch/x86/kvm/x86.h | 2 + >> include/linux/sched/isolation.h | 2 + >> kernel/sched/isolation.c | 6 +++ >> 7 files changed, 90 insertions(+), 45 deletions(-) >> >> -- >> 1.8.3.1 >>