[ovs-dev] [PATCH 6/7] ofproto-dpif: Use ovs_spinlock for stats.

Ben Pfaff blp at nicira.com
Wed Feb 12 01:28:54 UTC 2014


On Tue, Feb 11, 2014 at 04:30:48PM -0800, Jarno Rajahalme wrote:
> ovs_mutex showed high up in 'perf' stats, use a spinlock instead.
> 
> Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>

Do spinlocks perform better than adaptive mutexes, e.g. that one would
initialize by adding a function like this:

/* Initializes 'mutex' as an adaptive mutex. */
void
ovs_mutex_init_adaptive(const struct ovs_mutex *mutex)
{
#ifndef PTHREAD_MUTEX_ADAPTIVE_NP
#define PTHREAD_MUTEX_ADAPTIVE_NP PTHREAD_MUTEX_NORMAL
#endif
    ovs_mutex_init__(mutex, PTHREAD_MUTEX_ADAPTIVE_NP);
}

(spinlocks are nasty when a thread gets descheduled.)



More information about the dev mailing list