[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #52763] mdns: move data off the stack and dynamically
[lwip-devel] [bug #52763] mdns: move data off the stack and dynamically allocate data.
Fri, 29 Dec 2017 22:25:46 -0500 (EST)
Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0
Summary: mdns: move data off the stack and dynamically
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: ourairquality
Submitted on: Sat 30 Dec 2017 03:25:45 AM UTC
Severity: 3 - Normal
Item Group: None
Assigned to: None
Discussion Lock: Any
Planned Release: None
lwIP version: git head
The mdns responder uses a lot of stack for a small system, well over 1k, which
is out of proportion to the general stack resource needs for a small system.
This is largely due to stack allocated fixed sized 256 byte buffers for domain
names. This patch largely moves data off the stack and dynamically allocates
The code also allocated fixed size buffers for the domain names, big enough
for the maximum size name of 256 bytes. This patch dynamically allocates
buffers just large enough for their content, growing them as needed. There are
trade offs in doing so, but with this change it is still trivial to over
allocate storage if that is preferred.
The patch currently uses realloc() to grow the buffers. Some compatibility
code is expected to be needed to fit other systems.
Some context: on the esp8266 using lwip with FreeRTOS the large stack usage is
problematic, it demands almost an extra 1k be allocated to the stack, and
there is little ram to spare for some apps. Another issue is that instruction
ram can be used as data ram as a last resort but this iram has restrictions
and best not to put a task stack there making stack allocation less
The patch bundles in the change suggested in
https://savannah.nongnu.org/bugs/?52747 which attempts to avoid the mdns code
being called in other threads (it still uses a bit of stack). Not really happy
with that solution as it also required core locking to be disabled. Perhaps
there is a need for some other queue for jobs to run in the tcp thread when it
is free, to avoid a resource spike, while still supporting core locking.
This is a WIP, feedback welcomed.
Date: Sat 30 Dec 2017 03:25:45 AM UTC Name:
0001-mdns-move-data-off-the-stack-and-dynamically-allocat.patch Size: 64KiB
Reply to this item at:
Message sent via/by Savannah
- [lwip-devel] [bug #52763] mdns: move data off the stack and dynamically allocate data.,