Review needed: Mbuf double-free detection patch

Bosko Milekic bmilekic at unixdaemons.com
Thu May 1 10:06:41 PDT 2003


On Thu, May 01, 2003 at 04:12:10AM -0700, Luigi Rizzo wrote:
> as Bosko noticed, it would be a good idea to make the change to subr_mbuf.c
> conditionally compiled under DIAGNOSTIC or INVARIANTS or the like.
> 
> I was actually wondering if you have caught already any bug
> with this code enabled.
> 
> [on a side note, it is a bit depressing to see the same
> code replicated twice, in m_free() and m_freem(). Couldn't
> one try to make m_freem() just call m_free() in a loop and
> save some code bloat ? I doubt the extra function call
> would harm performance too much.]
> 
> 	cheers
> 	luigi

  The reason it's done that way has to do with a bigger optimization
  than just the avoidance of the extra function call: the cache lock is
  held, as most as possible, across repeated calls to mb_free().  In
  order to implement this "as most as possible," to allow for virtually
  atomic frees in some cases, it was ripped out and done that way... if
  you can figure out a cleaner way, that would be cool, though.

-- 
Bosko Milekic
bmilekic at unixdaemons.com
bmilekic at FreeBSD.org



More information about the freebsd-net mailing list