Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp132557ybi; Wed, 29 May 2019 18:11:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtSvzydnnORs6i0Fxaaoc3qJUxzMftF/biSWbX6mXwNDwkry77QQ2UnryvsxDnAN49DKqz X-Received: by 2002:a17:90a:21ce:: with SMTP id q72mr644593pjc.3.1559178683266; Wed, 29 May 2019 18:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559178683; cv=none; d=google.com; s=arc-20160816; b=e7AhOO7lBvLM7BOupiAeiYYaYgubECfmKC0etqXtF3oGJnhbkeHt6DaroKwPCBEMpR /439iyl+4RIJLqPw5+0oRgTS5lfl8M+f7t/eWuJk5RLx/8RHFef3XEWSE1uOraXJOdsn tdmi6wT5ThTPISISRycVaJE5I5vjHYQoS6dNjVb4xoJtwMuUXqJp0mSZbXrZVsuTZv9A 3MQC54kdER80Hs14V+NMRoiZ/9idCapnyCawXKxln9dA8RoLrC4CYaQcSS9F2XzM/U7n oU0DUZ1a5nDDFg33e3Tklzvl0SMrfxAw6b72u6d/KK+/q6O9yPmmw1Fn8jPjupmMictm 7nqA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/QWOK7mvM11aBaoeWXjkLlMbPoa5BTdf7AzqNiYer/E=; b=HuFXJAL9Pl2hpU+Y0Sp7N+xATCa0JQh/nkpRA7L+aSZvaekPae7Vo8ORgMytcmE8nD AuGWYmCW8OiO4BGcC0NP/p/Ya7HGQXYFZaer76MfN4T2vS5NFU09G004BJJMWqIStExc ML6C0LxkYjGEXOx0zgMd/JWatqL5dAkYnO2BssgtVLQ96Z0S6wSP8d8kQsjR5eUU8uR4 mBY6vSmmpA3REOeAzsZYVgS8MrsbiZcfZsiUKQz/6HMWNnopkH9zxiwneq7dv4DNs+zB Qxcrwv50fzpgT7/L48pvE8CFLLp30AIJsjMXQxRGpxNQ6rfjivLVFEl1hgCoUjkaW2KT F+Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QqyttgTd; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si1450386pgv.401.2019.05.29.18.11.07; Wed, 29 May 2019 18:11:23 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QqyttgTd; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727227AbfE3BKC (ORCPT + 99 others); Wed, 29 May 2019 21:10:02 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:38239 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726527AbfE3BKB (ORCPT ); Wed, 29 May 2019 21:10:01 -0400 Received: by mail-oi1-f195.google.com with SMTP id 18so2888461oij.5; Wed, 29 May 2019 18:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/QWOK7mvM11aBaoeWXjkLlMbPoa5BTdf7AzqNiYer/E=; b=QqyttgTda14aWjZEGL+vqbJe+Gqk+CrytZgAWK7eMyvrA/Fw9Exa0E7jAnMXzMIS7z nG21x87aCzYhdPyXoRG4SzqztHrpBojU5kBhe1ifDRAHrk+WSJR8HZbA4ITrBBARyJ9Z uJVvy+8o3hakeiiV2GyriQscVFvw30D+e3oTuk6SxPWdZDUcQMBuG9Yhlk836xQgaGkt mQkpjLOYyp+dYa6ZpdaFSOVTOuDlD1e49snQKH0EhOnZvHjiHactytiptNCNrE3ASs4o YotJe4wePJrBfhKDlR2N1l9FXC+XTRS7cdhIXHedVrvejYdksvWIjtjMYyTf1HUk9MOF Ch8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/QWOK7mvM11aBaoeWXjkLlMbPoa5BTdf7AzqNiYer/E=; b=WKQ2poLCrSA7x2//WbSjNFt0rX77mB2KWPCfmGRlen+beIgAHpTFJt5OpCvK5Lz8N+ shHzCxdR6b1Znf/SaQLR+kA1wkYD2xoMCAuah7CwPwbb7eU2UuO7UOjCAHhriCZT93c6 ycxYawWNCpSDNvx086/ODfllWaRL5KH6SCw4SLCPjS5FwF0MB5GEm6XWzbdPocgtepBG GfFjyDpN7Dl9vkNCNxH6+61wo1LloyUezQc/24zTGPkdikMqJTh/GoXrah2e49xSI+3L QtWys/bFXFFqYWIPAnQw4GcsHd2G2CMT3CIiQNz7fSf6eQtPG1P+4yjccD7PKRFUKcLf CeNg== X-Gm-Message-State: APjAAAWWn1RCimyd7xWolplfP/E90JbsGTiRE9R1KpIRo1yElCA+pyZL m6oJYHEN92h4wrxUorJMecxvUGwbYHFuHwf3WT4= X-Received: by 2002:aca:3305:: with SMTP id z5mr762027oiz.141.1559178601213; Wed, 29 May 2019 18:10:01 -0700 (PDT) MIME-Version: 1.0 References: <1559004795-19927-1-git-send-email-wanpengli@tencent.com> <1559004795-19927-3-git-send-email-wanpengli@tencent.com> In-Reply-To: From: Wanpeng Li Date: Thu, 30 May 2019 09:09:52 +0800 Message-ID: Subject: Re: [PATCH v2 2/3] KVM: X86: Implement PV sched yield hypercall To: Liran Alon Cc: LKML , kvm , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 May 2019 at 20:28, Liran Alon wrote: > > > > > On 28 May 2019, at 3:53, Wanpeng Li wrote: > > > > From: Wanpeng Li > > > > The target vCPUs are in runnable state after vcpu_kick and suitable > > as a yield target. This patch implements the sched yield hypercall. > > > > 17% performace increase of ebizzy benchmark can be observed in an > > over-subscribe environment. (w/ kvm-pv-tlb disabled, testing TLB flush > > call-function IPI-many since call-function is not easy to be trigged > > by userspace workload). > > > > Cc: Paolo Bonzini > > Cc: Radim Kr=C4=8Dm=C3=A1=C5=99 > > Signed-off-by: Wanpeng Li > > --- > > arch/x86/kvm/x86.c | 24 ++++++++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index e7e57de..2ceef51 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -7172,6 +7172,26 @@ void kvm_vcpu_deactivate_apicv(struct kvm_vcpu *= vcpu) > > kvm_x86_ops->refresh_apicv_exec_ctrl(vcpu); > > } > > > > +void kvm_sched_yield(struct kvm *kvm, u64 dest_id) > > +{ > > + struct kvm_vcpu *target; > > + struct kvm_apic_map *map; > > + > > + rcu_read_lock(); > > + map =3D rcu_dereference(kvm->arch.apic_map); > > + > > + if (unlikely(!map)) > > + goto out; > > + > > We should have a bounds-check here on =E2=80=9Cdest_id=E2=80=9D. Yeah, fix it in v3. Regards, Wanpeng Li