lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #48300] Private mempools allocate foreign memory


From: chrysn
Subject: [lwip-devel] [bug #48300] Private mempools allocate foreign memory
Date: Wed, 6 Jul 2016 10:57:53 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux) AppleWebKit/538.15 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/538.15 Midori/0.5

Follow-up Comment #10, bug #48300 (project lwip):

In assembling the patch, I found that there has been already a start of the
mechanisms required in place -- the LWIP_MEM_ALIGN_BUFFER macro already did
the right thing by adding (alignment-1) bytes to a size, it was just never
used, so a first patch makes candidates use it.

The second patch introduces a macro LWIP_ALIGN_SUFFIX to cc.h. If there is a
way to make the compiler align memory at build time, LWIP_MEM_ALIGN_BUFFER
will not overallocate memory. The macro's documentation has been updated, it
is now required for all users of it to use LWIP_ALIGN_SUFFIX as well. This
introduces a dependency from lwip/mem.h to lwip/arch.h -- I hope that's not a
problem, I was unsure of which path cc.h is usually included via.

We could go a tad further and, at all locations where alignment through this
mechanism is enforced make the alignment calls assertations (as trouble is to
come when LWIP_ALIGN_SUFFIX is advertised but doesn't work) and in optimized
builds no-ops; I do have a patch for that too but it's preview quality only
and would need further discussion. That patch has been useful for testing,
though.

Speaking of testing: I'd like to add one or two test cases to the whole
allocation thing, but found no documentation on the tests/unit directory. How
are additional tests created, and how is the test suite run?

One thing that did occur to me when I reviewed all alignment macro uses is
that I don't quite see why so much effort is put into aligning the result of
pbuf creating functions -- after the next pbuf_header(), things might be out
of alignment, and whoever would rely on pbufs being aligned could only ever
work with pbufs they themselves have created, for every other pbuf might have
different alignment. IMO it would be more advantageous to have the IP header
aligned, but not whichever-level-the-pbuf-was-created-on.

(file #37729, file #37730, file #37731)
    _______________________________________________________

Additional Item Attachment:

File name: 0001-Use-LWIP_MEM_ALIGN_BUFFER-macro.patch Size:2 KB
File name: 0002-Introduce-LWIP_ALIGN_SUFFIX-macro.patch Size:4 KB
File name: 0003-demo-only-Be-strict-about-when-memory-should-already.patch
Size:2 KB


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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