kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Jenkins <alan.christopher.jenkins@gmail.com>
To: yunhong jiang <yunhong.jiang@linux.intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, mtosatti@redhat.com, rkrcmar@redhat.com,
	kernellwp@gmail.com
Subject: Re: [RFC PATCH V2 4/4] Utilize the vmx preemption timer for tsc deadline timer
Date: Thu, 26 May 2016 15:05:04 +0100	[thread overview]
Message-ID: <e4320792-89ac-78b5-a20b-fdbc70531981@gmail.com> (raw)
In-Reply-To: <20160525154420.2c7fdcd3@jnakajim-build>

On 25/05/16 23:44, yunhong jiang wrote:
> On Wed, 25 May 2016 13:52:56 +0200
> Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> Yes, this should save two VMCS access on the vcpu_run(). Will do this way.
>
>>
>> The hardest part is converting guest_tsc to host_tsc.  From
>>
>> 	guest_tsc = (host_tsc * vcpu->arch.tsc_scaling_ratio >>
>> 			kvm_tsc_scaling_ratio_frac_bits) + tsc_offset
>>
>> you have
>>
>> 	host_tsc = ((unsigned __int128)(guest_tsc - tsc_offset)
>> 			<< kvm_tsc_scaling_ratio_frac_bits)
>> 			/ vcpu->arch.tsc_scaling_ratio;
>>
>> ... except that you need a division with a 128-bit dividend and a
>> 64-bit divisor here, and there is no such thing in Linux.  It's okay
>> if you restrict this to 64-bit hosts and use the divq assembly
>> instruction directly.  (You also need to trap the divide overflow
>> exception; if there is an overflow just disable the preemption
>> timer).  On 32-bit systems, it's okay to force-disable
>> set_hv_timer/cancel_hv_timer, i.e. set them to NULL.
>
> I'm scared by this conversion :) Sure will hav a try. Need firstly check
> how the scale_tsc works.

aaaaaaaaaaaa

1. Against my interests: have you actually confirmed the VMX preemption 
timer is affected by guest TSC scaling?

    It's not explicit in the SDM.  The way it's described for allocating 
timeslices to the guest, IMO it makes more sense if it is not scaled.

2. Paolo, any chance I could also get away with requiring 64-bit?  I.e.

#ifdef CONFIG_X86_64
#define HAVE_LAPIC_TIMER_ADVANCE 1
#endif

Regards
Alan

  reply	other threads:[~2016-05-26 14:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24 22:27 [RFC PATCH V2 0/4] Utilizing VMX preemption for timer virtualization Yunhong Jiang
2016-05-24 22:27 ` [RFC PATCH V2 1/4] Add the kvm sched_out hook Yunhong Jiang
2016-05-24 22:27 ` [RFC PATCH V2 2/4] Utilize the vmx preemption timer Yunhong Jiang
2016-06-14 13:23   ` Roman Kagan
2016-06-14 13:41     ` Paolo Bonzini
2016-06-14 16:46       ` yunhong jiang
2016-06-14 21:56         ` Paolo Bonzini
2016-06-15 18:03           ` yunhong jiang
2016-06-14 16:46     ` yunhong jiang
2016-05-24 22:27 ` [RFC PATCH V2 3/4] Separate the start_sw_tscdeadline Yunhong Jiang
2016-05-24 22:27 ` [RFC PATCH V2 4/4] Utilize the vmx preemption timer for tsc deadline timer Yunhong Jiang
2016-05-24 23:11   ` David Matlack
2016-05-24 23:35     ` yunhong jiang
2016-05-25 11:58       ` Paolo Bonzini
2016-05-25 22:53         ` yunhong jiang
2016-05-26  7:20           ` Paolo Bonzini
2016-05-25 10:40     ` Paolo Bonzini
2016-05-25 13:38       ` Radim Krčmář
2016-05-25 11:52   ` Paolo Bonzini
2016-05-25 22:44     ` yunhong jiang
2016-05-26 14:05       ` Alan Jenkins [this message]
2016-05-26 15:32         ` Paolo Bonzini
2016-06-04  0:24     ` yunhong jiang
2016-06-06 13:49       ` Paolo Bonzini
2016-06-06 18:21         ` yunhong jiang
2016-05-25 13:27   ` Radim Krčmář
2016-05-25 13:51     ` Paolo Bonzini
2016-05-25 14:31       ` Radim Krčmář
2016-05-25 23:13         ` yunhong jiang
2016-06-14 11:34         ` Paolo Bonzini
2016-05-25 13:45   ` Radim Krčmář
2016-05-25 22:57     ` yunhong jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e4320792-89ac-78b5-a20b-fdbc70531981@gmail.com \
    --to=alan.christopher.jenkins@gmail.com \
    --cc=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=yunhong.jiang@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).