On 04/02/2012 12:26 PM, Thomas Gleixner wrote: > > One thing about it is that it can give many false positives. Consider a > > fine-grained spinlock that is being accessed by many threads. That is, > > the lock is taken and released with high frequency, but there is no > > contention, because each vcpu is accessing a different instance. So the > > host scheduler will needlessly delay preemption of vcpus that happen to > > be holding a lock, even though this gains nothing. > > You're talking about per cpu locks, right? I can see the point there, > but per cpu stuff might be worth annotating to avoid this. Or any lock which is simply uncontended. Say a single process is running, the rest of the system is idle. It will take and release many locks; but it can be preempted at any point by the hypervisor with no performance loss. The overhead is arming a timer twice and an extra exit per deferred context switch. Perhaps not much given that you don't see tons of context switches on virt workloads, at least without threaded interrupts (or maybe interrupt threads should override this mechanism, by being realtime threads). > > A second issue may happen with a lock that is taken and released with > > high frequency, with a high hold percentage. The host scheduler may > > always sample the guest in a held state, leading it to conclude that > > it's exceeding its timeout when in fact the lock is held for a short > > time only. > > Well, no. You can avoid that. > > host VCPU > spin_lock() > modify_global_state() > exit > check_global_state() > mark_global_state() > reschedule vcpu > > spin_unlock() > check_global_state() > trigger_exit() > > So when an exit occures in the locked section, then the host can mark > the global state to tell the guest to issue a trap on unlock. Right. How does this nest? Do we trigger the exit on the outermost unlock? -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html