From: Laurent Vivier <Laurent.Vivier@bull.net>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm-devel <kvm-devel@lists.sourceforge.net>,
linux-kernel <linux-kernel@vger.kernel.org>,
virtualization <virtualization@lists.linux-foundation.org>
Subject: Re: [kvm-devel] [PATCH 4/4] Modify KVM to update guest time accounting.
Date: Mon, 20 Aug 2007 16:22:05 +0200 [thread overview]
Message-ID: <46C9A38D.6090509@bull.net> (raw)
In-Reply-To: <46C9A057.6060303@qumranet.com>
[-- Attachment #1: Type: text/plain, Size: 2270 bytes --]
Avi Kivity wrote:
> Laurent Vivier wrote:
>> Avi Kivity wrote:
>>
>>> Laurent Vivier wrote:
>>>
>>>> [PATCH 4/4] Modify KVM to update guest time accounting.
>>>>
>>>>
>>>>
>>>> Index: kvm/drivers/kvm/kvm.h
>>>> ===================================================================
>>>> --- kvm.orig/drivers/kvm/kvm.h 2007-08-20 13:23:53.000000000 +0200
>>>> +++ kvm/drivers/kvm/kvm.h 2007-08-20 13:23:58.000000000 +0200
>>>> @@ -589,6 +589,17 @@ void kvm_mmu_unload(struct kvm_vcpu *vcp
>>>>
>>>> int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
>>>>
>>>> +static inline void kvm_guest_enter(void)
>>>> +{
>>>> +#ifdef CONFIG_GUEST_ACCOUNTING
>>>> + current->flags |= PF_VCPU;
>>>> +#endif
>>>>
>>>>
>>> Since you select GUEST_ACCOUNTING, the #ifdef is always true?
>>>
>> It is just to avoid error if we compile kvm module outside of the kernel, with
>> kernel without support of guest accounting. Can be removed if you want.
>>
>>
>
> Ah okay. We take care of the external module in
> external-module-compat.h (in this case, we can #define PF_VCPU to 0 if
> it is undefined).
OK
>>>> +}
>>>> +
>>>> +static inline void kvm_guest_exit(void)
>>>> +{
>>>>
>>>>
>>> Missing content?
>>>
>> No, empty function.
>>
>> It is just to introduce "symmetry" in code, the VCPU code begins with
>> "kvm_guest_start()" and ends with "kvm_guest_exit()". And we have no operation
>> to do in kvm_guest_exit() (the PF_VCPU is cleared by account_system_time()), so
>> "empty function", removed by the optimizer (I hope).
>>
>
> But what if account_system_time() is not called (because we exited
> before the timer interrupt hit)?
account_system_time() is called by the scheduler on tick. If we clear PF_VCPU in
kvm_guest_exit(), the flag is always cleared when account_system_time() is
executed, so we account "0", if we call account_system_time() directly from
kvm_guest_exit() we account "1", so we subtract 1 to system time, and we have
perhaps not used 1 tick in system: in my opinion this implies wrong results.
Laurent
--
------------- Laurent.Vivier@bull.net --------------
"Software is hard" - Donald Knuth
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Laurent Vivier <Laurent.Vivier-6ktuUTfB/bM@public.gmane.org>
To: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel
<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
linux-kernel
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
virtualization
<virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
Subject: Re: [PATCH 4/4] Modify KVM to update guest time accounting.
Date: Mon, 20 Aug 2007 16:22:05 +0200 [thread overview]
Message-ID: <46C9A38D.6090509@bull.net> (raw)
In-Reply-To: <46C9A057.6060303-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
[-- Attachment #1.1: Type: text/plain, Size: 2290 bytes --]
Avi Kivity wrote:
> Laurent Vivier wrote:
>> Avi Kivity wrote:
>>
>>> Laurent Vivier wrote:
>>>
>>>> [PATCH 4/4] Modify KVM to update guest time accounting.
>>>>
>>>>
>>>>
>>>> Index: kvm/drivers/kvm/kvm.h
>>>> ===================================================================
>>>> --- kvm.orig/drivers/kvm/kvm.h 2007-08-20 13:23:53.000000000 +0200
>>>> +++ kvm/drivers/kvm/kvm.h 2007-08-20 13:23:58.000000000 +0200
>>>> @@ -589,6 +589,17 @@ void kvm_mmu_unload(struct kvm_vcpu *vcp
>>>>
>>>> int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
>>>>
>>>> +static inline void kvm_guest_enter(void)
>>>> +{
>>>> +#ifdef CONFIG_GUEST_ACCOUNTING
>>>> + current->flags |= PF_VCPU;
>>>> +#endif
>>>>
>>>>
>>> Since you select GUEST_ACCOUNTING, the #ifdef is always true?
>>>
>> It is just to avoid error if we compile kvm module outside of the kernel, with
>> kernel without support of guest accounting. Can be removed if you want.
>>
>>
>
> Ah okay. We take care of the external module in
> external-module-compat.h (in this case, we can #define PF_VCPU to 0 if
> it is undefined).
OK
>>>> +}
>>>> +
>>>> +static inline void kvm_guest_exit(void)
>>>> +{
>>>>
>>>>
>>> Missing content?
>>>
>> No, empty function.
>>
>> It is just to introduce "symmetry" in code, the VCPU code begins with
>> "kvm_guest_start()" and ends with "kvm_guest_exit()". And we have no operation
>> to do in kvm_guest_exit() (the PF_VCPU is cleared by account_system_time()), so
>> "empty function", removed by the optimizer (I hope).
>>
>
> But what if account_system_time() is not called (because we exited
> before the timer interrupt hit)?
account_system_time() is called by the scheduler on tick. If we clear PF_VCPU in
kvm_guest_exit(), the flag is always cleared when account_system_time() is
executed, so we account "0", if we call account_system_time() directly from
kvm_guest_exit() we account "1", so we subtract 1 to system time, and we have
perhaps not used 1 tick in system: in my opinion this implies wrong results.
Laurent
--
------------- Laurent.Vivier-6ktuUTfB/bM@public.gmane.org --------------
"Software is hard" - Donald Knuth
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
[-- Attachment #3: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
next prev parent reply other threads:[~2007-08-20 14:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-20 13:14 [PATCH 4/4] Modify KVM to update guest time accounting Laurent Vivier
2007-08-20 13:14 ` Laurent Vivier
2007-08-20 13:40 ` [kvm-devel] " Avi Kivity
2007-08-20 13:40 ` Avi Kivity
2007-08-20 13:49 ` [kvm-devel] " Laurent Vivier
2007-08-20 13:49 ` Laurent Vivier
2007-08-20 13:49 ` Laurent Vivier
2007-08-20 14:08 ` [kvm-devel] " Avi Kivity
2007-08-20 14:08 ` Avi Kivity
2007-08-20 14:08 ` Avi Kivity
2007-08-20 14:22 ` [kvm-devel] " Laurent Vivier
2007-08-20 14:22 ` Laurent Vivier [this message]
2007-08-20 14:22 ` Laurent Vivier
2007-08-20 13:40 ` [kvm-devel] " Avi Kivity
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=46C9A38D.6090509@bull.net \
--to=laurent.vivier@bull.net \
--cc=avi@qumranet.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.