Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3157412ybi; Mon, 17 Jun 2019 17:57:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpyTmsjq4Uqyu8U+roemAk/4C7uaHNEhjiOGghevuRvEro4z3iL9x9xuSbz4ovOP3PobKC X-Received: by 2002:a63:79c8:: with SMTP id u191mr127885pgc.366.1560819457730; Mon, 17 Jun 2019 17:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560819457; cv=none; d=google.com; s=arc-20160816; b=ANdQlXnmlhvUrHk2bkVten0rcu2caMkQH3fCcD20o6rGlSPXzU3uQiNn1b7D6rRyQf s6gjhgQ3WOK0iIxIGzMLMuUOcgPqYggbhyWZdZdKz7M556MW7aJVVtrkA1raowOAtJoZ 8l3JF7ouev6f2rNU6hljgE37jodDx8V0BuwAM9czDaWUwgeBl+OvUO0R0AhiDxRjLoTX WH10HNkOO3x33znblIb4QtQ+QE01eRvXyZMSmznx9h5gVS1gqIHMg9cp88/lYPbZCho7 Xh91mKEwEmRhUaa2MiMCAYaBMlLEn/iW//6UCkgUUnsoqyH/jyuQa0FtNOGPQdNT4Glj QXFw== 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=LAof2iPuEsmEYY4js8fXji44icMGLEIkpZjnqdzAtFI=; b=smvDmvgFFK0a4Uy7QH4WSJlxOk3vL0JKMhLRM3h3+8D0LcZ3gfntJn2JVDdazAukgz NfVtRT/lYRGmreGiGrG90I2jCsM44TZnSOdLnCh7z556nA03BMrisNtycMQRgVkKppKz esdwteeXSJ0YHaa4vVZ1GnlWV+5TEIAWJMebQkaujPMkfgxW+xEtiJ0idQ6dnJC+Rhr6 EmDvLAWaDyUe5Qc6hKIE+DTgSlAzWyHSOarv0+YbsqrlMnInTt4oBFP6cNQncstb/HKP B46QRahmxWKMxgE7CxvEsNi4W8BUcDAqr2Gp5v8XaSVXVD+gLlxCglZpI/mY8ucTMusT QJVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NAIs7vmQ; 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 e7si11897700pfi.130.2019.06.17.17.57.22; Mon, 17 Jun 2019 17:57:37 -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=NAIs7vmQ; 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 S1726685AbfFRA4k (ORCPT + 99 others); Mon, 17 Jun 2019 20:56:40 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:38277 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbfFRA4k (ORCPT ); Mon, 17 Jun 2019 20:56:40 -0400 Received: by mail-ot1-f65.google.com with SMTP id d17so11836051oth.5; Mon, 17 Jun 2019 17:56:39 -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=LAof2iPuEsmEYY4js8fXji44icMGLEIkpZjnqdzAtFI=; b=NAIs7vmQcsIIa8lS+vTvC5bC1yt5vtdlN596xVfEf8KBK7ly+kPIH49W5sZweA/Ar5 PA4/gqSU3x5eUZ0EtsBshtI91HVoJKNqtK6Ou+yQB7Gjsm7MZm4cqPjgpzW7RlbVFSN6 YhnqPmRSGWE8NntPKcZ7CCpEftrq4oNhfZgDPcSVKNyBk4zxI+veE9QHenHLTUzhnipp bbtUbg36mT3JQA7Wl9g2HSRNGKbn+tMG/JW+aNYQ79yVEzzhX2bpOcGEBtQz8/JiIjHC CDmw6qkhEzYvCzD5tjXQocYSqYRGCH72DeLaqI2NIS2py8OQegBrJOaMTbMUjTyAVbey K1tA== 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=LAof2iPuEsmEYY4js8fXji44icMGLEIkpZjnqdzAtFI=; b=KNPyi8GGgDO7fT4XB7t0G9psPPDhBDiCMwmMSNSzMbdLq567rkhbaj0aoU/Zxb1PId ee4RY2CVUCNNCVM2QklmTbLdxXzgbkkUnArQl6ylQt1Hg+OJu4ZqbVjmdTX2TGLJ+njz +L7S+GkB0/7rMMZz7HLr2tCsWXZnhVAJXlI5TWDi8xfBcMqghLEYZujFUFtdfc0q/U5z 53U+gmjllhFNVSCgjUKojeMcXBR3ZzXl+ODJWcP1Ww/XqM75iLzrbUFTBWgFPmsjC4Wd am9kYMq644kTmJzCNXIQ24jaE3/BhCJ3MmNQgX4nVf3A92EuuurMHNI2eIxpxEVjLDkv CZuA== X-Gm-Message-State: APjAAAVuUbMkdq+LRIWD0kazYKj15BbtxUYwqGGNqkdfaGWl/lRCXkNn xYpUNdy6QGqWYDfQZui4Zp03jnxxrkPuLuUxBpy78HfS X-Received: by 2002:a9d:62c4:: with SMTP id z4mr45374362otk.56.1560819399619; Mon, 17 Jun 2019 17:56:39 -0700 (PDT) MIME-Version: 1.0 References: <1560770687-23227-1-git-send-email-wanpengli@tencent.com> <1560770687-23227-6-git-send-email-wanpengli@tencent.com> <20190617213201.GA26346@flask> In-Reply-To: From: Wanpeng Li Date: Tue, 18 Jun 2019 08:57:15 +0800 Message-ID: Subject: Re: [PATCH v4 5/5] KVM: LAPIC: add advance timer support to pi_inject_timer To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: LKML , kvm , Paolo Bonzini , Marcelo Tosatti 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 Tue, 18 Jun 2019 at 08:44, Wanpeng Li wrote: > > On Tue, 18 Jun 2019 at 05:32, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: > > > > 2019-06-17 19:24+0800, Wanpeng Li: > > > From: Wanpeng Li > > > > > > Wait before calling posted-interrupt deliver function directly to add > > > advance timer support to pi_inject_timer. > > > > > > Cc: Paolo Bonzini > > > Cc: Radim Kr=C4=8Dm=C3=A1=C5=99 > > > Cc: Marcelo Tosatti > > > Signed-off-by: Wanpeng Li > > > --- > > > > Please merge this patch with [2/5], so bisection doesn't break. > > Agreed. > > > > > > arch/x86/kvm/lapic.c | 6 ++++-- > > > arch/x86/kvm/lapic.h | 2 +- > > > arch/x86/kvm/svm.c | 2 +- > > > arch/x86/kvm/vmx/vmx.c | 2 +- > > > 4 files changed, 7 insertions(+), 5 deletions(-) > > > > > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > > > index 1a31389..1a31ba5 100644 > > > --- a/arch/x86/kvm/lapic.c > > > +++ b/arch/x86/kvm/lapic.c > > > @@ -1462,6 +1462,8 @@ static void apic_timer_expired(struct kvm_lapic= *apic, bool can_pi_inject) > > > return; > > > > > > if (can_pi_inject && posted_interrupt_inject_timer(apic->vcpu))= { > > > + if (apic->lapic_timer.timer_advance_ns) > > > + kvm_wait_lapic_expire(vcpu, true); > > > > From where does kvm_wait_lapic_expire() take > > apic->lapic_timer.expired_tscdeadline? > > Sorry, I failed to understand this. > https://git.kernel.org/pub/scm/virt/kvm/kvm.git/tree/arch/x86/kvm/lapic.c= ?h=3Dqueue#n1541 > We can get apic->lapic_timer.expired_tscdeadline in > kvm_wait_lapic_expire() directly. Oh, miss the latest expired_tscdeadline, how about something like below? diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 1a31ba5..7cd95ea 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1461,6 +1461,9 @@ static void apic_timer_expired(struct kvm_lapic *apic, bool can_pi_inject) if (atomic_read(&apic->lapic_timer.pending)) return; + if (apic_lvtt_tscdeadline(apic) || ktimer->hv_timer_in_use) + ktimer->expired_tscdeadline =3D ktimer->tscdeadline; + if (can_pi_inject && posted_interrupt_inject_timer(apic->vcpu)) { if (apic->lapic_timer.timer_advance_ns) kvm_wait_lapic_expire(vcpu, true); @@ -1477,9 +1480,6 @@ static void apic_timer_expired(struct kvm_lapic *apic, bool can_pi_inject) */ if (swait_active(q)) swake_up_one(q); - - if (apic_lvtt_tscdeadline(apic) || ktimer->hv_timer_in_use) - ktimer->expired_tscdeadline =3D ktimer->tscdeadline; } /*