Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3434302ybi; Mon, 10 Jun 2019 10:11:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8DHA2djxZc1b2cQDEYsFLcl7EkMmPN4a4mH3raqyJ5bPo+KW1qGXwIaVRDSPyLBSeYgo3 X-Received: by 2002:aa7:825a:: with SMTP id e26mr76667776pfn.255.1560186703979; Mon, 10 Jun 2019 10:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560186703; cv=none; d=google.com; s=arc-20160816; b=ghP5UJxZxVWuuqgmWOxsqMDaQ+Qf610iPVDeihFPTqJxtxYJ0aKtKBaJIqV7hbKEtN GJxDGGHsbP07tC+Wus9LB8Jy5UGPf5wvfMrOswVuw/fXAkBLcYdZIO0MlYjJ7+9D9tap ndxjz69+GlpPJQMQBipw01mnSgZk7862FqMrY9dXlWm0vzcB5VQOnx2UYxhTiDveZ6kB RJvAKkGCWAgB1FXXQvEaKuKe7TArUAUPGB041M7DYxJyuN9kc2vJmhNRXTv83SImyISf xDAheGLWx26zI63qDyfJpQMcqH3RL4wNsTeE720RsZfljQahRqcWZBOnxO4DmtPkvAQx dRMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=aUDfcTL9V2WG4xA/8iNI1qWZMNQvt04tI8IkrT8Sz6Q=; b=1Df3yG4jX388ETd3bgaUYuCgNKiPdCqYte2yOyUb4Gqs0c408EHbf5pqAIAjdsaGKE JjCs9C210B03Auk+iEEfdafKYjC4iug6pPVJJjXu0PAxEoEinv8JAv8uyjHI3lbCqXbb SzMvpfLAEsa3CeiB13xcf+sAPyl3aC6y2G+f4968/m9RG8BnID8U/UniZ29dL/s4t1L9 gP6C0qYHKOfNZmggGs8+nM4RTUE7Xw7fFY8t99DkCsU9NZo5bkHjey6wiMLRttX2aU+u ssrq2ORpiC5xIIJPRlKowYc7wq2uo1OWbWAJ8K7t6wIb4qniYWN31A+Qr65EusGkLprJ o++g== 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 w6si3570295pfn.84.2019.06.10.10.11.28; Mon, 10 Jun 2019 10:11:43 -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 S1728508AbfFJRLQ (ORCPT + 99 others); Mon, 10 Jun 2019 13:11:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34636 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728289AbfFJRLN (ORCPT ); Mon, 10 Jun 2019 13:11:13 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D4E40C18B2DB; Mon, 10 Jun 2019 17:11:12 +0000 (UTC) Received: from flask (unknown [10.43.2.83]) by smtp.corp.redhat.com (Postfix) with SMTP id D77026061B; Mon, 10 Jun 2019 17:11:10 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Mon, 10 Jun 2019 19:11:10 +0200 Date: Mon, 10 Jun 2019 19:11:10 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Subject: Re: [PATCH v2 1/3] KVM: LAPIC: Make lapic timer unpinned when timer is injected by posted-interrupt Message-ID: <20190610171110.GB8389@flask> References: <1559799086-13912-1-git-send-email-wanpengli@tencent.com> <1559799086-13912-2-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1559799086-13912-2-git-send-email-wanpengli@tencent.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 10 Jun 2019 17:11:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2019-06-06 13:31+0800, Wanpeng Li: > From: Wanpeng Li > > Make lapic timer unpinned when timer is injected by posted-interrupt, > the emulated timer can be offload to the housekeeping cpus. > > The host admin should fine tuned, e.g. dedicated instances scenario > w/ nohz_full cover the pCPUs which vCPUs resident, several pCPUs > surplus for housekeeping, disable mwait/hlt/pause vmexits to occupy > the pCPUs, fortunately preemption timer is disabled after mwait is > exposed to guest which makes emulated timer offload can be possible. > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Signed-off-by: Wanpeng Li > --- > arch/x86/kvm/lapic.c | 20 ++++++++++++++++---- > arch/x86/kvm/x86.c | 5 +++++ > arch/x86/kvm/x86.h | 2 ++ > include/linux/sched/isolation.h | 2 ++ > kernel/sched/isolation.c | 6 ++++++ > 5 files changed, 31 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index fcf42a3..09b7387 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -127,6 +127,12 @@ static inline u32 kvm_x2apic_id(struct kvm_lapic *apic) > return apic->vcpu->vcpu_id; > } > > +static inline bool posted_interrupt_inject_timer_enabled(struct kvm_vcpu *vcpu) > +{ > + return pi_inject_timer && kvm_vcpu_apicv_active(vcpu) && > + kvm_mwait_in_guest(vcpu->kvm); I'm torn about the mwait dependency. It covers a lot of the targeted user base, but the relation is convoluted and not fitting perfectly. What do you think about making posted_interrupt_inject_timer_enabled() just pi_inject_timer && kvm_vcpu_apicv_active(vcpu) and disarming the vmx preemption timer when posted_interrupt_inject_timer_enabled(), just like we do with mwait now? Thanks.