Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Feb 2005 01:32:31 GMT
From:      David Xu <davidxu@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 71086 for review
Message-ID:  <200502150132.j1F1WVRR069610@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=71086

Change 71086 by davidxu@davidxu_tiger on 2005/02/15 01:32:10

	Change default stack size to 2M for 64 bits machine, 1M for 32 bits machine.

Affected files ...

.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_attr.c#4 edit
.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_create.c#7 edit
.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_init.c#11 edit
.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_private.h#20 edit
.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_stack.c#5 edit

Differences ...

==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_attr.c#4 (text+ko) ====

@@ -321,15 +321,15 @@
 	int	ret;
 	pthread_attr_t	pattr;
 
+	_thr_check_init();
+
 	/* Allocate memory for the attribute object: */
 	if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL)
 		/* Insufficient memory: */
 		ret = ENOMEM;
 	else {
 		/* Initialise the attribute object with the defaults: */
-		memcpy(pattr, &_pthread_attr_default,
-		    sizeof(struct pthread_attr));
-		pattr->guardsize_attr = _thr_guard_default;
+		memcpy(pattr, &_pthread_attr_default, sizeof(struct pthread_attr));
 
 		/* Return a pointer to the attribute object: */
 		*attr = pattr;

==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_create.c#7 (text+ko) ====

@@ -91,9 +91,9 @@
 		 */
 	}
 
-	if (_thread_scope_system > 0)
+	if (_thr_scope_system > 0)
 		new_thread->attr.flags |= PTHREAD_SCOPE_SYSTEM;
-	else if (_thread_scope_system < 0)
+	else if (_thr_scope_system < 0)
 		new_thread->attr.flags &= ~PTHREAD_SCOPE_SYSTEM;
 
 	if (create_stack(&new_thread->attr) != 0) {

==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_init.c#11 (text+ko) ====

@@ -329,7 +329,7 @@
 	 * resource limits, so this stack needs an explicitly mapped
 	 * red zone to protect the thread stack that is just beyond.
 	 */
-	if (mmap((void *)_usrstack - THR_STACK_INITIAL -
+	if (mmap((void *)_usrstack - _thr_stack_initial -
 	    _thr_guard_default, _thr_guard_default, 0, MAP_ANON,
 	    -1, 0) == MAP_FAILED)
 		PANIC("Cannot allocate red zone for initial thread");
@@ -343,8 +343,8 @@
 	 *       actually free() it; it just puts it in the free
 	 *       stack queue for later reuse.
 	 */
-	thread->attr.stackaddr_attr = (void *)_usrstack - THR_STACK_INITIAL;
-	thread->attr.stacksize_attr = THR_STACK_INITIAL;
+	thread->attr.stackaddr_attr = (void *)_usrstack - _thr_stack_initial;
+	thread->attr.stacksize_attr = _thr_stack_initial;
 	thread->attr.guardsize_attr = _thr_guard_default;
 	thread->attr.flags |= THR_STACK_USER;
 
@@ -399,16 +399,17 @@
 			PANIC("Cannot get kern.usrstack from sysctl");
 		_thr_page_size = getpagesize();
 		_thr_guard_default = _thr_page_size;
-	 	_pthread_attr_default.guardsize_attr = _thr_guard_default;
-		
+		_pthread_attr_default.guardsize_attr = _thr_guard_default;
+		_pthread_attr_default.stacksize_attr = _thr_stack_default;
+
 		TAILQ_INIT(&_thr_atfork_list);
 #ifdef SYSTEM_SCOPE_ONLY
-		_thread_scope_system = 1;
+		_thr_scope_system = 1;
 #else
 		if (getenv("LIBPTHREAD_SYSTEM_SCOPE") != NULL)
-			_thread_scope_system = 1;
+			_thr_scope_system = 1;
 		else if (getenv("LIBPTHREAD_PROCESS_SCOPE") != NULL)
-			_thread_scope_system = -1;
+			_thr_scope_system = -1;
 #endif
 	}
 	init_once = 1;

==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_private.h#20 (text+ko) ====

@@ -255,14 +255,14 @@
 /*
  * Miscellaneous definitions.
  */
-#define THR_STACK_DEFAULT			0x100000
+#define THR_STACK_DEFAULT		(sizeof(void *) / 4 * 1024 * 1024)
 
 /*
  * Maximum size of initial thread's stack.  This perhaps deserves to be larger
  * than the stacks of other threads, since many applications are likely to run
  * almost entirely on this stack.
  */
-#define THR_STACK_INITIAL			0x200000
+#define THR_STACK_INITIAL		(THR_STACK_DEFAULT * 2)
 
 /*
  * Define the different priority ranges.  All applications have thread
@@ -584,8 +584,8 @@
 SCLASS void		*_usrstack	SCLASS_PRESET(NULL);
 SCLASS struct pthread	*_thr_initial	SCLASS_PRESET(NULL);
 /* For debugger */
-SCLASS int		_libkse2_debug		SCLASS_PRESET(0);
-SCLASS int		_thread_scope_system	SCLASS_PRESET(0);
+SCLASS int		_libthread_debug	SCLASS_PRESET(0);
+SCLASS int		_thr_scope_system	SCLASS_PRESET(0);
 
 /* List of all threads: */
 SCLASS TAILQ_HEAD(, pthread)	_thread_list
@@ -634,6 +634,8 @@
 
 SCLASS pid_t		_thr_pid		SCLASS_PRESET(0);
 SCLASS int		_thr_guard_default;
+SCLASS int		_thr_stack_default	SCLASS_PRESET(THR_STACK_DEFAULT);
+SCLASS int		_thr_stack_initial	SCLASS_PRESET(THR_STACK_INITIAL);
 SCLASS int		_thr_page_size;
 /* Garbage thread count. */
 SCLASS int              _gc_count               SCLASS_PRESET(0);

==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_stack.c#5 (text+ko) ====

@@ -187,7 +187,7 @@
 	else {
 		/* Allocate a stack from usrstack. */
 		if (last_stack == NULL)
-			last_stack = _usrstack - THR_STACK_INITIAL -
+			last_stack = _usrstack - _thr_stack_initial -
 			    _thr_guard_default;
 
 		/* Allocate a new stack. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200502150132.j1F1WVRR069610>