Re: [PATCH] use unfair spinlock when running on hypervisor.

From: Srivatsa Vaddagiri
Date: Thu Jun 03 2010 - 01:38:14 EST


On Thu, Jun 03, 2010 at 06:51:51AM +0200, Eric Dumazet wrote:
> > Guest side:
> >
> > static inline void spin_lock(spinlock_t *lock)
> > {
> > raw_spin_lock(&lock->rlock);
> > + __get_cpu_var(gh_vcpu_ptr)->defer_preempt++;
>
> 1) __this_cpu_inc() should be faster

Ok ..thx for that tip.

> 2) Isnt a bit late to do this increment _after_
> raw_spin_lock(&lock->rlock);

I think so, my worry about doing it earlier is we may set the defer_preempt hint
for the wrong vcpu (if lets say the guest application thread is preempted by
guest kernel and later migrated to another vcpu after it sets the hint and
before it acquires the lock).

- vatsa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/