On Tue, 2020-06-02 at 01:12 +0000, Volodymyr Babchuk wrote: > On Fri, 2020-05-29 at 10:48 +0200, Dario Faggioli wrote: > > > Actually, I tried to not only rebase this patch series to the current > mainline, but also to add x86 support. This gave me deeper > unsterstanding of the inner workings. At least I hope so :) > Right. > Anyways, I want to discuss the matter before continuing reworking the > patches. The goal of those patches is to account guest time more > precisely. > Yes, I agree. IIRC, the patches are doing more than that, e.g., discriminating between the runtime of the idle vCPUs and the time during which the CPUs were actually idle, and even trying to classify somehow what the hypervisor was actually doing (guest sync, etc). But, indeed, I would very much start with the one yous stated above, as a goal. > Right now I can see only two main reasons, when guest can be charged > for a time it dindn't used: interrupts and soft irqs. > > - do_softirq() is called every time we leave hypervisor mode. It is > used to do housekeeping for the hypervisor itself. But, some random > guest will charged for time spent in do_softirq() unless this > function > is not called on a idle vcpu. > > - also, pCPU can be interrupted by IRQ assigned to some other guest > or > to hypervisor itself. But time spent in interrupt handler will be > charged for a guest being interrupted. > I think those are the ones, yes. > So, basically, to account guest time correctly, we need to substract > time spent in do_softirq() and in do_IRQ(). > That's how I'd try to do this, if it were me doing it. > Actually, we can charge the correct guest for time spent in do_IRQ(), > because handler code will eventually know target vCPU for the > interrupt. There is technical problem with interrupt nesting. We will > need some stack to track nesting correctly. But this is doable. > Yes, there's this, and maybe a few other "dependencies" that we may discuss about, and try to track and account for, for even greather fairness. But maybe this can come as a second step? > Just for statistical purposes we can track hypervisor time somwhere, > but it is not needed for scheduling decisions. > What we need is, I think, a way to tell the used/admin that that time is being spent in the hypervisor. E.g., if we were spending (let's exaggerate) 20% of the time processing interrupts and softirqs, the user would see some of this 20% load coming from each guest. It certainly wasn't ideal, but we do not want for such 20% to suddenly vanish either. > Am I missing something? > To me, it seems you're not. :-) Regards -- Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <> (Raistlin Majere)