<div dir="ltr">Hi Serge,<br><div class="gmail_extra"><br></div><div class="gmail_extra">[resending as lxc-devel rejected my first mail due to its size]<br><br><div class="gmail_quote">On Wed, Sep 18, 2013 at 11:20 AM, Serge Hallyn <span dir="ltr"><<a href="mailto:serge.hallyn@ubuntu.com" target="_blank">serge.hallyn@ubuntu.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">pthread_mutex_lock() will only return an error if it was set to<br>


PTHREAD_MUTEX_ERRORCHECK and we are recursively calling it (and<br>
would otherwise have deadlocked).  If that's the case then log a<br>
message for future debugging and exit.  Trying to "recover" is<br>
nonsense at that point.<br>
<br>
process_lock() was held over too long a time in lxcapi_start()<br>
in the daemonize case.  (note the non-daemonized case still needs a<br>
check to enforce that it must NOT be called while threaded).  Add<br>
process_lock() at least across all open/close/socket() calls.<br>
<br>
Anything done after a fork() doesn't need the locks as it is no<br>
longer threaded - so some open/close/dups()s are not locked for<br>
that reason.  However, some common functions are called from both<br>
threaded and non-threaded contexts.  So after doing a fork(), do<br>
a possibly-extraneous process_unlock() to make sure that, if we<br>
were forked while pthread mutex was held, we aren't deadlocked by<br>
nobody.<br>
<br>
Tested that lp:~serge-hallyn/+junk/lxc-test still works with this<br>
patch.<br>
<br>
lxc-test-concurrent with this patchset passes almost 100%.  I<br>
occasionally get failures of containers to start (but no task<br>
corruption) which I've yet to look into.  Certainly it seems a<br>
huge improvement.<br></blockquote><div><br></div><div><div class="gmail_extra" style="font-family:arial,sans-serif;font-size:13px">It is a huge improvement, thanks! I'm observing very same thing that you described with my test suite. Concurrent creates/stops/shutdowns and destroys are now %100 passing but some start calls are failing time to time.</div>

<div class="gmail_extra" style="font-family:arial,sans-serif;font-size:13px"><br></div><div class="gmail_extra" style="font-family:arial,sans-serif;font-size:13px">Tested-by: S.Çağlar Onur <<a href="mailto:caglar@10ur.org" target="_blank">caglar@10ur.org</a>></div>

<div class="gmail_extra" style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial;font-size:small"> </span><br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


Signed-off-by: Serge Hallyn <<a href="mailto:serge.hallyn@ubuntu.com">serge.hallyn@ubuntu.com</a>><br>
---<br>
 src/lxc/af_unix.c      |  15 ++++<br>
 src/lxc/apparmor.c     |  11 +++<br>
 src/lxc/attach.c       |  35 +++++++++<br>
 src/lxc/bdev.c         |  96 +++++++++++++++++++++---<br>
 src/lxc/caps.c         |   5 ++<br>
 src/lxc/cgroup.c       |  35 +++++++++<br>
 src/lxc/commands.c     |  11 +++<br>
 src/lxc/conf.c         |  83 +++++++++++++++++++-<br>
 src/lxc/console.c      |  72 ++++++++++++------<br>
 src/lxc/freezer.c      |   5 ++<br>
 src/lxc/log.c          |   7 ++<br>
 src/lxc/lxccontainer.c | 200 ++++++++++++++++++++++++++++++++-----------------<br>
 src/lxc/lxclock.c      |   9 ++-<br>
 src/lxc/lxclock.h      |   2 +-<br>
 src/lxc/lxcutmp.c      |  11 +++<br>
 src/lxc/mainloop.c     |  11 ++-<br>
 src/lxc/monitor.c      |  18 ++++-<br>
 src/lxc/network.c      |   9 +++<br>
 src/lxc/nl.c           |   5 ++<br>
 src/lxc/parse.c        |   5 ++<br>
 src/lxc/seccomp.c      |   5 ++<br>
 src/lxc/start.c        |  31 +++++++-<br>
 src/lxc/state.c        |   5 ++<br>
 src/lxc/sync.c         |  12 ++-<br>
 src/lxc/utils.c        |  52 +++++++++++--<br>
 25 files changed, 627 insertions(+), 123 deletions(-)<br></blockquote></div><br>Cheers,<br>-- <br>S.Çağlar Onur <<a href="mailto:caglar@10ur.org">caglar@10ur.org</a>>
</div></div>