Re: [tip:perf/core] perf tools: Protect accesses the dso rbtrees/ lists with a rw lock

From: Ingo Molnar
Date: Wed Jun 10 2015 - 03:04:58 EST



* Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:

> Em Tue, Jun 09, 2015 at 11:56:10AM +0200, Ingo Molnar escreveu:
> > * tip-bot for Arnaldo Carvalho de Melo <tipbot@xxxxxxxxx> wrote:
>
> > > +void dsos__add(struct dsos *dsos, struct dso *dso)
> > > +{
> > > + pthread_rwlock_wrlock(&dsos->lock);
> > > + __dsos__add(dsos, dso);
> > > + pthread_rwlock_unlock(&dsos->lock);
> > > }
> >
> > Please introduce wrappers and use the kernel API names:
> > read_lock()/read_unlock()/etc. (and name the mutex primitives
> > mutex_lock()/unlock())
> >
> > That way kernel developers will find their way around the perf locking details
> > easily, and we can also use liblockdep to check locking correctness.
>
> Yeah, we discussed about that, will do it eventually, you said this was already
> present in some tools/ code, but I couldn't find it:
>
> [acme@zoo linux]$ find tools/ -type f | xargs grep '\<mutex_unlock'
> [acme@zoo linux]$

it's in -tip in tools/kvm/:

triton:~/tip> git grep mutex_lock tools/kvm/include/kvm/mutex.h
tools/kvm/include/kvm/mutex.h:static inline void mutex_lock(struct mutex *lock)

triton:~/tip> git grep down tools/kvm/include/kvm/rwsem.h
tools/kvm/include/kvm/rwsem.h:static inline void down_read(pthread_rwlock_t *rwsem)
tools/kvm/include/kvm/rwsem.h:static inline void down_write(pthread_rwlock_t *rwsem)

Thanks,

Ingo
--
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/