lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #52763] mdns: move data off the stack and dynamically


From: Douglas
Subject: [lwip-devel] [bug #52763] mdns: move data off the stack and dynamically allocate data.
Date: Fri, 29 Dec 2017 22:25:46 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0

URL:
  <http://savannah.nongnu.org/bugs/?52763>

                 Summary: mdns: move data off the stack and dynamically
allocate data.
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: ourairquality
            Submitted on: Sat 30 Dec 2017 03:25:45 AM UTC
                Category: DNS
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: git head

    _______________________________________________________

Details:

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
it.

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
attractive.

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.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Sat 30 Dec 2017 03:25:45 AM UTC  Name:
0001-mdns-move-data-off-the-stack-and-dynamically-allocat.patch  Size: 64KiB  
By: ourairquality

<http://savannah.nongnu.org/bugs/download.php?file_id=42761>

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?52763>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]