lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [patch #9272] arp/ndp: allow overriding the decision to cop


From: David van Moolenbroek
Subject: [lwip-devel] [patch #9272] arp/ndp: allow overriding the decision to copy pbufs
Date: Mon, 27 Feb 2017 11:41:12 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0

URL:
  <http://savannah.nongnu.org/patch/?9272>

                 Summary: arp/ndp: allow overriding the decision to copy pbufs
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: dcvmoole
            Submitted on: Mon 27 Feb 2017 04:41:11 PM UTC
                Category: ARP
                Priority: 3 - Low
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

I realize that this is a contentious topic, especially because the long-term
goal is a larger redesign, but after about a decade I'm guessing that that
might take a while longer. ;) Therefore I'd like to propose a tiny change in
this area that has substantial benefits for me right now at least [*]. I'd
love to hear what you think.

To recap the current situation, at least as I understand it: in zero-copy
setups, drivers may asynchronously transmit buffers provided to them, simply
increasing the reference count of those buffers until the transmission is
complete. This avoids the need to make copies of the buffers. Whether avoiding
the copy is possible at all depends on the buffer type. For PBUF_ROM, it is
always possible. For PBUF_RAM/PBUF_ROM/PBUF_REF there are two factors to
consider: lwIP itself, and the application that uses lwIP. lwIP itself
internally supports zero-copy use of those types of buffers, as it should,
because otherwise zero-copy would not have any benefit at all. Applications
that use lwIP must be careful with their own use (and in particular, reuse) of
such buffers so as to not mess up the ability to do such corruption-free
zero-copy transmissions. As such, any zero-copy setup needs an
application/driver agreement on which types of buffers need to be copied on
low-level output for reliable zero-copy transmission. lwIP itself does not
know anything about that agreement. So far so good.

My issue, then, is with the current arp/ndp queuing code, which in essence is
very much like the driver transmission code: it may hold a packet for a short
time while waiting for something external to happen. The queuing code
currently always assumes the worst case, making copies of any packets that do
not consist entirely of PBUF_ROM buffers. As a default policy, that is
perfectly fine. However, my proposal here is to allow the user to be able to
override this decision, specifically by allowing zero-copy implementations to
specify their own aforementioned application/driver agreement in a single
macro. That way, lwIP can avoid the extra copy unless necessary. The attached
patch basically moves two lines around in order to allow for this.

As a possible theoretical extension, the same new macro (PBUF_NEEDS_COPY) may
be used at the driver level for the same purpose. As such, this is the
simplest implementation of my suggestion in bug #49914 comment #5. It should
then probably documented in doxygen as well; for now I'm leaving that to a
future patch if it is deemed useful at all.

[*] To be exact: it is not any speed increase that is important to me here,
but rather the elimination of the only operation-critical place that requires
relatively large (~1500 byte) contiguous memory allocations. In a nutshell,
this issue is in my way of eliminating the need for a 1500+byte memory pool
which, to account for the worst case, takes up about 75KB of memory all by
itself right now. It seems silly having to spend that much memory just to
account for allocations that are entirely unnecessary in my setup..

===

lwIP aims to support zero-copy TX, and thus, must internally handle
all cases that pbufs are referenced rather than copied upon low-level
output.  However, in the current situation, the arp/ndp packet queuing
routines conservatively copy entire packets, even when unnecessary in
cases where lwIP is used in a zero-copy compliant manner.  This patch
moves the decision whether to copy into a centralized macro, allowing
zero-copy compliant applications to override the macro to avoid the
unnecessary copies.  The macro defaults to the safe behavior, though.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Mon 27 Feb 2017 04:41:11 PM UTC  Name:
0001-arp-ndp-allow-overriding-the-decision-to-copy-pbufs.patch  Size: 4kB  
By: dcvmoole

<http://savannah.nongnu.org/patch/download.php?file_id=39837>

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?9272>

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




reply via email to

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