From nobody@FreeBSD.org  Sun Sep  1 09:52:27 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id 9F1557FF
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  1 Sep 2013 09:52:27 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 7A8C722EB
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  1 Sep 2013 09:52:27 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r819qR3s016512
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 1 Sep 2013 09:52:27 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r819qR5G016511;
	Sun, 1 Sep 2013 09:52:27 GMT
	(envelope-from nobody)
Message-Id: <201309010952.r819qR5G016511@oldred.freebsd.org>
Date: Sun, 1 Sep 2013 09:52:27 GMT
From: Chie Taguchi <taguchi.ch@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: threads caused hung on ARM/RPI
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         181718
>Category:       arm
>Synopsis:       threads caused hung on ARM/RPI
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-arm
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 01 10:00:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Sun Sep  1 10:20:00 UTC 2013
>Originator:     Chie Taguchi
>Release:        FreeBSD 10.0-CURRENT
>Organization:
>Environment:
FreeBSD RPI-1 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r255089: Sat Aug 31 17:13:40 JST 2013     user@arty:/usr/home/user/crochet-freebsd/work/obj/arm.armv6/usr/src.arm/sys/RPI-B-DBG  arm
>Description:
i am trying to remove BROKEN on arm at devel/nspr.

i had made two patches, attached, as reference OpenBSD and NetBSD.
and build had succeeded.

so i ran "make test" in devel/nspr.
almost tests-suite were PASS.
but, after running tests/cvar2 and tests/threads, RPI hunged without any core.
in addition to this, there is another issue of tests/nbconn,
 but i will make a other PR about it.

i done unit test of cvar2 and threads. these results were following:
tests/cvar2:
# ./cvar2
5 Thread tests
           Condvar simple test shared UU: 140.00 usec
           Condvar simple test shared UK: 110.00 usec
             Condvar simple test priv UU: 350.00 usec
             Condvar simple test priv UK: 350.00 usec
                 Condvar simple test All: 370.00 usec
                    Condvar timeout test: 770.00 usec

10 Thread tests
           Condvar simple test shared UU: 180.00 usec
           Condvar simple test shared UK: 170.00 usec
             Condvar simple test priv UU: 650.00 usec
             Condvar simple test priv UK: 640.00 usec
                 Condvar simple test All: 760.00 usec
                    Condvar timeout test: 950.00 usec

15 Thread tests
           Condvar simple test shared UU: 230.00 usec
           Condvar simple test shared UK: 240.00 usec
             Condvar simple test priv UU: 950.00 usec
             Condvar simple test priv UK: 940.00 usec
                 Condvar simple test All: 1060.00 usec
                    Condvar timeout test: 1120.00 usec

20 Thread tests
           Condvar simple test shared UU: 290.00 usec
           Condvar simple test shared UK: 280.00 usec
             Condvar simple test priv UU: 1270.00 usec
             Condvar simple test priv UK: 1250.00 usec
                 Condvar simple test All: 1460.00 usec
                    Condvar timeout test: 1320.00 usec
PASS

# ./cvar2 -v (debug mode)
..skipping...
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 779
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 779
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 779
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 779
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 779
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 779
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 779
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 779
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 779
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 779
PrivateCondVarThread: thread 0x2085b320 notified exitcvar = 0x2080d2c0 cnt = 780
                    Condvar timeout test: 12840.00 usec
PASS

tests/threads:
# ./threads -d (debug mode)
** Tests lots of thread creations.
** Create 10 native threads 50 times.
** Create 10 user threads 50 times.
                Create user/user threads: 3000.00 usec
              Create user/native threads: 2180.00 usec
              Create native/user threads: 2040.00 usec
            Create native/native threads: 2160.00 usec
                Create user/user threads: 2000.00 usec
              Create user/native threads: 1960.00 usec
              Create native/user threads: 2060.00 usec
            Create native/native threads: 2120.00 usec
                Create user/user threads: 2080.00 usec
              Create user/native threads: 2080.00 usec
              Create native/user threads: 2060.00 usec
            Create native/native threads: 1940.00 usec
                Create user/user threads: 2080.00 usec
              Create user/native threads: 1920.00 usec
              Create native/user threads: 2060.00 usec
            Create native/native threads: 2040.00 usec
                Create user/user threads: 2240.00 usec
              Create user/native threads: 2160.00 usec
              Create native/user threads: 2060.00 usec
            Create native/native threads: 1980.00 usec
                Create user/user threads: 1940.00 usec
              Create user/native threads: 2180.00 usec
              Create native/user threads: 1980.00 usec
            Create native/native threads: 1920.00 usec
                Create user/user threads: 2120.00 usec
              Create user/native threads: 2000.00 usec
              Create native/user threads: 2140.00 usec
            Create native/native threads: 1980.00 usec
                Create user/user threads: 1940.00 usec
              Create user/native threads: 2100.00 usec
              Create native/user threads: 2140.00 usec
            Create native/native threads: 1940.00 usec
                Create user/user threads: 2040.00 usec
              Create user/native threads: 1980.00 usec
              Create native/user threads: 2040.00 usec
            Create native/native threads: 1980.00 usec
                Create user/user threads: 1960.00 usec
              Create user/native threads: 2120.00 usec
              Create native/user threads: 2160.00 usec
            Create native/native threads: 1880.00 usec

Now switch to recycling threads

                Create user/user threads: 2040.00 usec
              Create user/native threads: 1920.00 usec
              Create native/user threads: 2080.00 usec
            Create native/native threads: 2020.00 usec
                Create user/user threads: 2020.00 usec
              Create user/native threads: 1980.00 usec
              Create native/user threads: 2200.00 usec
            Create native/native threads: 2000.00 usec
                Create user/user threads: 2060.00 usec
              Create user/native threads: 2280.00 usec
              Create native/user threads: 2080.00 usec
            Create native/native threads: 1960.00 usec
                Create user/user threads: 2200.00 usec
              Create user/native threads: 1980.00 usec
              Create native/user threads: 2060.00 usec
            Create native/native threads: 2060.00 usec
                Create user/user threads: 2000.00 usec
              Create user/native threads: 2080.00 usec
              Create native/user threads: 2080.00 usec
            Create native/native threads: 2040.00 usec
                Create user/user threads: 2220.00 usec
              Create user/native threads: 2020.00 usec
              Create native/user threads: 2000.00 usec
            Create native/native threads: 2100.00 usec
                Create user/user threads: 2000.00 usec
              Create user/native threads: 2060.00 usec
              Create native/user threads: 1940.00 usec
            Create native/native threads: 2140.00 usec
                Create user/user threads: 2200.00 usec
              Create user/native threads: 2000.00 usec
              Create native/user threads: 2220.00 usec
            Create native/native threads: 2000.00 usec
                Create user/user threads: 2280.00 usec
              Create user/native threads: 2160.00 usec
              Create native/user threads: 2140.00 usec
            Create native/native threads: 1980.00 usec
                Create user/user threads: 2160.00 usec
              Create user/native threads: 2280.00 usec
              Create native/user threads: 2080.00 usec
            Create native/native threads: 2100.00 usec
PASS

----test.log.ended---

these example of test-log were seemed to hung after test ended.
but, sometimes hunged on the way, or finished nomally in rare cases.

once hunged, RPI did not accept any key, perfect freeze.

also /var/crash was empty. and i can not get any clue.
>How-To-Repeat:
# cd /usr/ports/devel/nspr
# make install
# make test

# cd /usr/ports/devel/nspr/work/nspr-4.10/nspr/build/pr/tests
# ./cvar2
# ./cvar2 -v
# ./threads -d

>Fix:


Patch attached with submission follows:

--- ../pr/include/md/_freebsd.h.orig	2013-08-28 13:16:35.000000000 +0900
+++ ../pr/include/md/_freebsd.h	2013-08-28 00:36:04.000000000 +0900
@@ -29,6 +29,8 @@
 #define _PR_SI_ARCHITECTURE "powerpc64"
 #elif defined(__powerpc__)
 #define _PR_SI_ARCHITECTURE "powerpc"
+#elif defined(__arm__)
+#define _PR_SI_ARCHITECTURE "arm"
 #else
 #error "Unknown CPU architecture"
 #endif


>Release-Note:
>Audit-Trail:

From: Chie Taguchi <taguchi.ch@gmail.com>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-arm@FreeBSD.org
Cc: taguchi.ch@gmail.com
Subject: Re: arm/181718: threads caused hung on ARM/RPI
Date: Sun, 1 Sep 2013 19:18:07 +0900

 This is a multi-part message in MIME format.
 
 --Multipart=_Sun__1_Sep_2013_19_18_07_+0900_TsjHl4gNLICNWh//
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 
 it is looks like missing one of my patches. and i will reattach it.
 
 thanks.
 
 C.Taguchi
 
 On Sun, 1 Sep 2013 10:00:00 GMT
 FreeBSD-gnats-submit@FreeBSD.org wrote:
 
 > Thank you very much for your problem report.
 > It has the internal identification `arm/181718'.
 > The individual assigned to look at your
 > report is: freebsd-arm. 
 > 
 > You can access the state of your problem report at any time
 > via this link:
 > 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=181718
 > 
 > >Category:       arm
 > >Responsible:    freebsd-arm
 > >Synopsis:       threads caused hung on ARM/RPI
 > >Arrival-Date:   Sun Sep 01 10:00:00 UTC 2013
 
 
 -- 
 Chie Taguchi <taguchi.ch@gmail.com>
 
 --Multipart=_Sun__1_Sep_2013_19_18_07_+0900_TsjHl4gNLICNWh//
 Content-Type: text/plain;
  name="patch-nspr-pr-include-md-_freebsd_cfg.txt"
 Content-Disposition: attachment;
  filename="patch-nspr-pr-include-md-_freebsd_cfg.txt"
 Content-Transfer-Encoding: 7bit
 
 --- ../pr/include/md/_freebsd.cfg.orig	2013-08-28 13:17:50.000000000 +0900
 +++ ../pr/include/md/_freebsd.cfg	2013-08-28 00:35:07.000000000 +0900
 @@ -20,7 +20,7 @@
  #define HAVE_LONG_LONG
  #endif
  
 -#if defined(__i386__)
 +#if defined(__i386__) || defined(__arm__)
  
  #define IS_LITTLE_ENDIAN 1
  #undef  IS_BIG_ENDIAN
 
 --Multipart=_Sun__1_Sep_2013_19_18_07_+0900_TsjHl4gNLICNWh//--
>Unformatted:
