On Fri, 13 Sep 2013 17:29:53 -0400
Dwight Engen <dwight.en...@oracle.com> wrote:

> On Fri, 13 Sep 2013 12:09:55 -0400
> S.Çağlar Onur <cag...@10ur.org> wrote:
> 
> > Hi Dwight,
> > 
> > Yes, I only observed a hang so far but not this assertion (in fact I
> > don't remember ever seeing that). What I'm seeing is this;
> 
> Okay, something funny is going on, but I don't know what yet. That
> assertion is coming from liblxc.so->libgnutls->libgcrypt and seems to
> be complaining that we're unlocking something that is already
> unlocked. So I compiled lxc without GNUTLS support (by commenting out
> the check for it in configure.ac) and now I get past that and get
> hangs similar to yours.
> 
> Interestingly, I modified your program to just do the create and
> destroy and not the start nor stop and I still get the hangs during
> the creation part.

Sorry to reply to myself: So now I modified your program to do the
create single threaded and everything else threaded (see attached
patch) and that doesn't hang for me.

It looked like to me that the hung threads were stuck on process_lock()
so I added a backtrace there to debug it a bit more and it looks like
the hang is in the flow:

 lxcapi_create()
   c->save_config()
     container_disk_lock()
       lxclock()
         process_lock()

Not sure why yet though. Serge, do you think this could have to do with
the fork()ing from a thread in that flow?
diff --git a/src/tests/concurrent.c b/src/tests/concurrent.c
index 7faf34c..a70b252 100644
--- a/src/tests/concurrent.c
+++ b/src/tests/concurrent.c
@@ -15,6 +15,8 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
+
+#include <limits.h>
 #include <stdio.h>
 #include <pthread.h>
 
@@ -28,12 +30,13 @@ struct thread_args {
     char *mode;
 };
 
-void * concurrent(void *arguments) {
-    char name[4];
+void do_function(void *arguments)
+{
+    char name[NAME_MAX+1];
     struct thread_args *args = arguments;
     struct lxc_container *c;
 
-    sprintf(name, "%d", args->thread_id);
+    sprintf(name, "lxc-test-concurrent-%d", args->thread_id);
 
     c = lxc_container_new(name, NULL);
 
@@ -79,44 +82,60 @@ void * concurrent(void *arguments) {
     args->return_code = 0;
 out:
     lxc_container_put(c);
-    pthread_exit(NULL);
 }
 
+void * concurrent(void *arguments)
+{
+    do_function(arguments);
+    pthread_exit(NULL);
+}
 
 int main(int argc, char *argv[]) {
-    int i, j;
+    int i, j, loop, loops = 1;
     pthread_attr_t attr;
     pthread_t threads[NTHREADS];
     struct thread_args args[NTHREADS];
 
-    char *modes[] = {"create", "start", "stop", "destroy", NULL};
+    //char *modes[] = {"create", "start", "stop", "destroy", NULL};
+    char *modes[] = {"start", "stop", "destroy", NULL};
 
     pthread_attr_init(&attr);
-    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 
-    for (i = 0; modes[i];i++) {
-        printf("Executing (%s) for %d containers...\n", modes[i], NTHREADS);
-        for (j = 0; j < NTHREADS; j++) {
-            args[j].thread_id = j;
-            args[j].mode = modes[i];
+    if (argc > 1)
+        loops = atoi(argv[1]);
 
-            if (pthread_create(&threads[j], &attr, concurrent, (void *) &args[j]) != 0) {
-                perror("pthread_create() error");
-                exit(EXIT_FAILURE);
-            }
+    for (loop = 1; loop <= loops; loop++) {
+        printf("\nIteration %d/%d\n", loop, loops);
+        printf("Creating non-threaded...\n");
+        for(j = 0; j < NTHREADS; j++) {
+            args[0].thread_id = 0;
+            args[0].mode = "create";
+            do_function(&args[0]);
         }
 
-        for (j = 0; j < NTHREADS; j++) {
-            if ( pthread_join(threads[j], NULL) != 0) {
-                perror("pthread_join() error");
-                exit(EXIT_FAILURE);
+        for (i = 0; modes[i];i++) {
+            printf("Executing (%s) for %d containers...\n", modes[i], NTHREADS);
+            for (j = 0; j < NTHREADS; j++) {
+                args[j].thread_id = j;
+                args[j].mode = modes[i];
+
+                if (pthread_create(&threads[j], &attr, concurrent, (void *) &args[j]) != 0) {
+                    perror("pthread_create() error");
+                    exit(EXIT_FAILURE);
+                }
             }
-            if (args[j].return_code) {
-                perror("thread returned an error");
-                exit(EXIT_FAILURE);
+    
+            for (j = 0; j < NTHREADS; j++) {
+                if (pthread_join(threads[j], NULL) != 0) {
+                    perror("pthread_join() error");
+                    exit(EXIT_FAILURE);
+                }
+                if (args[j].return_code) {
+                    fprintf(stderr, "thread returned error %d", args[j].return_code);
+                    exit(EXIT_FAILURE);
+                }
             }
         }
-        printf("\n");
     }
 
     pthread_attr_destroy(&attr);
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to