On 25 Jul 2011, at 12:00, Daan Vreeken wrote:

> Couldn't the dangling pointer problem be solved by adding a 'generation' 
> field 
> to the mbuf structure?
> The 'generation' could be a system-wide number that gets incremented whenever 
> an interface is removed. The mbuf* functions could keep a (per CPU?) 
> reference count on the number of mbufs allocated/freed during 
> that 'generation'. After interface removal, the ifnet structure could be 
> freed when all the reference counters of generations before the current 
> generation reach zero (whenever that happens).

I think a hybrid approach makes sense, combining a number of the ideas we've 
been kicking about:

(1) Add per-CPU ifnet refcounts that don't imply cache-line misses on each mbuf 
alloc/free
(2) Add optional subsystem drain functions so that subsystems that may have 
unbounded queueing times for mbufs deterministically ensure reference release, 
perhaps by substituting a common deadif for outstanding dying references.

The former gives us actual correctness in terms of avoiding races, the latter 
gives us deterministic freeing by subsystems that potentially queue mbufs 
forever (i.e., TCP) but no longer require the ifnet reference.

Robert_______________________________________________
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"

Reply via email to