libev, multiple threads, and ev_async as notification vs valgrind/helgrind

Christian Parpart trapni at gmail.com
Fri May 2 17:21:22 CEST 2014


Yes, that's all I wanted to know. So here I am on the safe side.
Many thanks, Marc.

Cheers,
Christian Parpart.


On Fri, May 2, 2014 at 4:36 PM, Marc Lehmann <schmorp at schmorp.de> wrote:

> On Fri, May 02, 2014 at 04:12:29PM +0200, Christian Parpart <
> trapni at gmail.com> wrote:
> > I hope somebody can tell me that this is a false positive or what I might
> > be missing.
>
> Most likely, these are either bugs in helgrind (not emulating the memory
> fence instruction correctly) or simply a design limitation in helgrind, in
> that it doesn't support lockfree data structures, or maybe it has a
> concept of data race that cannot distinguish between problematic data races
> and harmless ones (ones that don't break the few guarantees that libev
> offers).
>
> Unfortunately, I am not up to the task of analysing helgrind and its
> limitations, so maybe you need to ask somebody who knows (about valgrind).
>
> I'm pretty confident that there are no races at the hardware level in
> libev.
>
> > >From what I can think of, I should not need any locks at for my
> threading
> > model, there watchers are only modified inside their respective worker
> > threads *except* the fact, that ev_async is used to notify thread A to
> > thread B to wake up and do some work.
>
> Yes, thats correct (and libev itself also doesn't use/need any locks).
>
> > As you may see in the backtrace, I also tried to add a lock around struct
> > ev_loop uses, as shown in the example of the libev man page, in the hope,
> > that maybe I need that part there anyways, but appearently that didn't
> fix
> > it either.
>
> It's also not needed - indeed ev_async should be safe to call from another
> thread without locking, and if otherwise you do everything in the same
> thread, you also don't need any locking.
>
> --
>                 The choice of a       Deliantra, the free code+content
> MORPG
>       -----==-     _GNU_              http://www.deliantra.net
>       ----==-- _       generation
>       ---==---(_)__  __ ____  __      Marc Lehmann
>       --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
>       -=====/_/_//_/\_,_/ /_/\_\
>
> _______________________________________________
> libev mailing list
> libev at lists.schmorp.de
> http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20140502/a27ddd53/attachment.html>


More information about the libev mailing list