On Wed, Jun 14, 2006 at 05:06:23PM +0100, Andy Jackson wrote:
> Attached is a simple patch that makes the thread stack sizes CDL adjustable
> in the FreeBSD network stack. I suspect that most of the time people will
> be happy with the defaults, but just recently I've had some problems in
> this area and being able to tweak the stack sizes easily has been a real
> benefit.
Hi Andy
I reworked your patch a little, but kept the basic idea. Attached is
what i've committed.
Andrew
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/ChangeLog,v
retrieving revision 1.60
diff -u -r1.60 ChangeLog
--- ChangeLog 19 May 2006 10:15:03 -0000 1.60
+++ ChangeLog 17 Jun 2006 18:05:02 -0000
@@ -1,3 +1,8 @@
+2006-06-14 Andy Jackson <[EMAIL PROTECTED]>
+
+ * cdl/freebsd_net.cdl, src/ecos/support.c, src/ecos/support.c:
+ Changes to make stack sizes CDL configurable.
+
2006-05-19 Andrew Lunn <[EMAIL PROTECTED]>
* tests/sysctl1.c: Use CYG_NELEM from infra.
Index: cdl/freebsd_net.cdl
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/cdl/freebsd_net.cdl,v
retrieving revision 1.10
diff -u -r1.10 freebsd_net.cdl
--- cdl/freebsd_net.cdl 12 Mar 2005 12:55:46 -0000 1.10
+++ cdl/freebsd_net.cdl 17 Jun 2006 18:05:02 -0000
@@ -320,7 +320,7 @@
}
cdl_option CYGPKG_NET_MAXSOCKETS {
- display "Max number of open sockets."
+ display "Max number of open sockets"
flavor data
default_value CYGNUM_FILEIO_NFILE
description "
@@ -337,31 +337,63 @@
used by the networking code."
}
- cdl_option CYGPKG_NET_THREAD_PRIORITY {
- display "Priority level for backgound network processing."
- flavor data
- default_value 7
- description "
- This option allows the thread priority level used by the
- networking stack to be adjusted by the user. It should be set
- high enough that sufficient CPU resources are available to
- process network data, but may be adjusted so that application
- threads can have precedence over network processing."
+ cdl_component CYGPKG_NET_THREAD {
+ display "Background network processing thread options"
+ flavor none
+ no_define
+
+ cdl_option CYGPKG_NET_THREAD_PRIORITY {
+ display "Priority level for background network processing"
+ flavor data
+ default_value 7
+ description "
+ This option allows the thread priority level used by the
+ networking stack to be adjusted by the user. It should be set
+ high enough that sufficient CPU resources are available to
+ process network data, but may be adjusted so that application
+ threads can have precedence over network processing."
+ }
+
+ cdl_option CYGNUM_NET_THREAD_STACKSIZE {
+ display "Stack size for backgound network processing"
+ flavor data
+ default_value { (CYGPKG_NET_INET6 ?
+ "CYGNUM_HAL_STACK_SIZE_TYPICAL+2048" :
+ "CYGNUM_HAL_STACK_SIZE_TYPICAL") }
+ description "
+ This option allows the thread stack allocated for the
+ networking stack to be adjusted by the user. "
+ }
}
- cdl_option CYGPKG_NET_FAST_THREAD_PRIORITY {
- display "Priority level for fast network processing."
- flavor data
- default_value CYGPKG_NET_THREAD_PRIORITY - 1
- description "
- This option sets the thread priority level used by the fast
- network thread. The fast network thread runs often but briefly, to
- service network device interrupts and network timeout events. This
- thread should have higher priority than the background network
- thread. It is reasonable to set this thread's priority higher than
- application threads for best network throughput, or to set it lower
- than application threads for best latency for those application
- threads themselves, potentially at a cost to network throughput."
+ cdl_component CYGPKG_NET_FAST_THREAD {
+ display "Fast network processing thread options"
+ flavor none
+ no_define
+
+ cdl_option CYGPKG_NET_FAST_THREAD_PRIORITY {
+ display "Priority level for fast network processing"
+ flavor data
+ default_value CYGPKG_NET_THREAD_PRIORITY - 1
+ description "
+ This option sets the thread priority level used by the fast
+ network thread. The fast network thread runs often but briefly, to
+ service network device interrupts and network timeout events. This
+ thread should have higher priority than the background network
+ thread. It is reasonable to set this thread's priority higher than
+ application threads for best network throughput, or to set it lower
+ than application threads for best latency for those application
+ threads themselves, potentially at a cost to network throughput."
+ }
+
+ cdl_option CYGNUM_NET_FAST_THREAD_STACKSIZE {
+ display "Stack size for fast network processing"
+ flavor data
+ default_value { "CYGNUM_HAL_STACK_SIZE_TYPICAL" }
+ description "
+ This option allows the thread stack allocated for the
+ fast networking stack to be adjusted by the user. "
+ }
}
cdl_component CYGPKG_NET_FAST_THREAD_TICKLE_DEVS {
Index: src/ecos/support.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/src/ecos/support.c,v
retrieving revision 1.18
diff -u -r1.18 support.c
--- src/ecos/support.c 8 May 2006 17:21:37 -0000 1.18
+++ src/ecos/support.c 17 Jun 2006 18:05:03 -0000
@@ -104,11 +104,8 @@
int cyg_net_log_mask = CYGPKG_NET_FREEBSD_LOGGING;
#endif
-#ifdef CYGPKG_NET_INET6
-#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL+2048)
-#else
-#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
-#endif
+#define STACK_SIZE CYGNUM_NET_THREAD_STACKSIZE
+
static char netint_stack[STACK_SIZE];
static cyg_thread netint_thread_data;
static cyg_handle_t netint_thread_handle;
Index: src/ecos/timeout.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/src/ecos/timeout.c,v
retrieving revision 1.4
diff -u -r1.4 timeout.c
--- src/ecos/timeout.c 30 Apr 2004 01:13:56 -0000 1.4
+++ src/ecos/timeout.c 17 Jun 2006 18:05:04 -0000
@@ -64,7 +64,8 @@
static cyg_int32 last_delta;
static cyg_tick_count_t last_set_time;
-#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
+#define STACK_SIZE CYGNUM_NET_FAST_THREAD_STACKSIZE
+
static char alarm_stack[STACK_SIZE];
static cyg_thread alarm_thread_data;
static cyg_handle_t alarm_thread_handle;