Rusty Russell wrote: > On Fri, 2007-08-17 at 09:35 +0200, Laurent Vivier wrote: >> Rusty Russell wrote: >>> Hi Laurent, >> Hi Rusty, >> how are your puppies ? > > They're getting a little fat, actually. Too many features ... > >> - remove PATCH 3, and add in task_struct a "ktime vtime" where we accumulate >> guest time (by calling something like guest_enter() and guest_exit() from the >> virtualization engine), and when in account_system_time() we have cputime > >> vtime we substrate vtime from cputime and add vtime to user time and guest time. >> But doing like this we freeze in kernel/sched.c the link between system time, >> user time and guest time (i.e. system time = system time - vtime, user time = >> user time + vtime and guest time = guest time + vtime). > > Actually, I think we can set a per-cpu "in_guest" flag for the scheduler > code, which then knows to add the tick to the guest time. That seems > the simplest possible solution. > > lguest or kvm would set the flag before running the guest (which is done > with preempt disabled or using preemption hooks), and reset it > afterwards. > > Thoughts? It was my first attempt (except I didn't have a per-cpu flag, but a per-task flag), it's not visible but I love simplicity... ;-) A KVM VCPU is stopped by preemption, so when we enter in scheduler we have exited from VCPU and thus this flags is off (so we account 0 to the guest). What I did then is "set the flag on when we enter in the VCPU, and "account_system_time()" sets the flag off when it adds this timeslice to cpustat (and compute correctly guest, user, system time). But I didn't like this idea because all code executed after we entered in the VCPU is accounted to the guest until we have an account_system_time() and I suppose we can have real system time in this part. And I guess a VCPU can be less than 1 ms (unit of cputime) in a timeslice. So ? What's best ? Laurent -- ------------- [email protected] -------------- "Software is hard" - Donald Knuth
Attachment:
signature.asc
Description: OpenPGP digital signature
- Follow-Ups:
- Re: [kvm-devel] [PATCH/RFC 3/4]Introduce "account modifiers" mechanism
- From: Avi Kivity <[email protected]>
- [PATCH/RFC 3/4, second shot]Introduce "account_guest_time"
- From: Laurent Vivier <[email protected]>
- Re: [kvm-devel] [PATCH/RFC 3/4]Introduce "account modifiers" mechanism
- References:
- [PATCH/RFC 3/4]Introduce "account modifiers" mechanism
- From: Laurent Vivier <[email protected]>
- Re: [PATCH/RFC 3/4]Introduce "account modifiers" mechanism
- From: Rusty Russell <[email protected]>
- Re: [PATCH/RFC 3/4]Introduce "account modifiers" mechanism
- From: Laurent Vivier <[email protected]>
- Re: [PATCH/RFC 3/4]Introduce "account modifiers" mechanism
- From: Rusty Russell <[email protected]>
- [PATCH/RFC 3/4]Introduce "account modifiers" mechanism
- Prev by Date: Re: Fork Bombing Patch
- Next by Date: Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures
- Previous by thread: Re: [PATCH/RFC 3/4]Introduce "account modifiers" mechanism
- Next by thread: [PATCH/RFC 3/4, second shot]Introduce "account_guest_time"
- Index(es):