This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: CPU Stack Overflow In BSD Network Stack


OK.  I'm a bit of a novice with CDL, so I could use a bit of help.  The
simple approach would be to do as the other components of the net package do
(bootp, dhcp, tfpt, IPv6 routing, etc.).  Just put the conditional stuff in
the source file, like:

   #ifdef CYGPKG_NET_INET6
   #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL+2048)
   #else
   #define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
   #endif
   static char netint_stack[STACK_SIZE];

This involves no CDL changes.  Another approach is via CDL, as you
suggested.  I am having a bit of trouble.  Here's what I'm trying:

        cdl_option CYGNUM_NET_THREAD_STACK_SIZE {
            display "Network thread processor stack size"
            flavor  data
            default_value { (CYGPKG_NET_INET6 == 1) ?
                            ((CYGNUM_HAL_STACK_SIZE_TYPICAL) + 2048) :
                            CYGNUM_HAL_STACK_SIZE_TYPICAL }
            description   "
                This option configures the size of the processor stack
                for the network thread."
        }

    }

The problem I'm having with this is that CDL is evaluating
CYGNUM_HAL_STACK_SIZE_TYPICAL to be 0, so I either get a stack size of 0 or
2048 -- not what I want.

I thought about using a "calculated" rather than a "default_value", but
"calculated" options are not user changable, and I think I will have the
same CDL expression evaluation problem as with the "default_value".

Jay

-----Original Message-----
From: Andrew Lunn [mailto:andrew.lunn@ascom.ch]
Sent: Friday, June 20, 2003 3:49 AM
To: Jay Foster
Cc: 'ecos-discuss@sources.redhat.com'
Subject: Re: [ECOS] CPU Stack Overflow In BSD Network Stack


On Thu, Jun 19, 2003 at 01:26:22PM -0700, Jay Foster wrote:
> I have been seeing what looks like CPU stack overflows with the BSD
network
> stack.  The code is running on the Samsung S3C4510B ARM7TDMI processor,
with
> the assertions and stack checking enabled
> (CYGFUN_KERNEL_THREADS_STACK_CHECKING), and IPv6 enabled
(CYGPKG_NET_INET6).
> 
> A call backtrace of the assertion follows:
> 
> Call return addresses (most recent first)
> 0006da84 {write_thread_id}
> 000209d4 {cyg_assert_fail + $10}
> 000ac3b4 {_ZN18Cyg_HardwareThread11check_stackEv + $124}
> 0002d418 {_ZN13Cyg_Scheduler12unlock_innerEj + $54}
> 0002ecb4 {_ZN9Cyg_Mutex4lockEv + $138}
> 00020c4c {ks32c5000_eth_buffer_send + $88}
> 00021cdc {ks32c5000_eth_send + $8C}
> 00067634 {eth_drv_send + $12C}
> 00085898 {cyg_ether_output_frame + $A0}
> 0008566c {cyg_ether_output + $2D0}
> 0005e9c8 {cyg_nd6_output + $160}
> 00058098 {cyg_ip6_output + $A24}
> 00060654 {cyg_nd6_na_output + $328}
> 0005f2c4 {cyg_nd6_ns_input + $510}
> 00097aec {cyg_icmp6_input + $E38}
> 00052e5c {cyg_ip6_input + $8F4}
> 00052548 {cyg_ip6intr + $3C}
> 00035bcc {cyg_netint + $44}
> 0002abd4 {_ZN18Cyg_HardwareThread12thread_entryEP10Cyg_Thread + $7C}
> 0002ab40 {_GLOBAL__I_cyg_scheduler_start}
> 
> In the file, "packages/net/bsd_tcpip/current/src/ecos/support.c", it
defines
> the network stack (netint_stack[]) to be CYGNUM_HAL_STACK_SIZE_TYPICAL
bytes
> in size.  For the ARM architecture, CYGNUM_HAL_STACK_SIZE_TYPICAL is 2400
> bytes.
> 
> I increased the stack and the stack overflow assertions have gone away.
> 
>   #ifdef CYGPKG_NET_INET6
>   #define STACK_SIZE (2*CYGNUM_HAL_STACK_SIZE_TYPICAL)
>   #else
>   #define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
>   #endif
>   static char netint_stack[STACK_SIZE];
> 
> Before the IPv6 (CYGPKG_NET_INET6) was enabled, there were no stack 
> overflows observed.  It looks like the IPv6 enabled network stack
> code requires more processor stack than the IPv4 network stack.  Has 
> anyone else encountered this situation?

I've done all my testing using the synthetic target. That by default
has a bigger CYGNUM_HAL_STACK_SIZE_TYPICAL, 16K i think, so i never
ran into this problem. 
 
> Should the stack size be conditionally configured based on whether
> CYGPKG_NET_INET6 is configured?  Whether
> CYGFUN_KERNEL_THREADS_STACK_CHECKING
> is configured?  Both?


If should be made bigger when IPv6 is included. 

How much should be added you can only tell from trying it and
seeing. If your experiments show that an extra 1K is sufficient, than
we can go with that. 

The general philosophy is to do things like this in CDL. So i suggest
you add a new CDL option in the net.cdl file. Call it
CYGNUM_NET_THREAD_STACK_SIZE and use CDL to add the extra when IPv6 is
configured.

Could you do this and submit a proper patch and a ChangeLog entry? I
will then commit it to CVS.

     Thanks
        Andrew

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]