Date: Wed, 15 Nov 2000 01:07:46 -0800 From: Alfred Perlstein <bright@wintelcom.net> To: David Malone <dwmalone@maths.tcd.ie> Cc: Julian Elischer <julian@elischer.org>, Bosko Milekic <bmilekic@dsuper.net>, iedowse@maths.tcd.ie, freebsd-net@FreeBSD.ORG Subject: Re: M_RDONLY: review & comment Message-ID: <20001115010746.E29448@fw.wintelcom.net> In-Reply-To: <200011150835.aa94058@salmon.maths.tcd.ie>; from dwmalone@maths.tcd.ie on Wed, Nov 15, 2000 at 08:35:40AM %2B0000 References: <3A11329A.D54E17E3@elischer.org> <200011150835.aa94058@salmon.maths.tcd.ie>
next in thread | previous in thread | raw e-mail | index | archive | help
* David Malone <dwmalone@maths.tcd.ie> [001115 00:35] wrote: > > using char * is unsafe if the aim is to tag mbufs that were allocated > > by some module, if the midule is unloaded.. > > (the mbufs may hang around in some queu way afte the module has gone.. > > and an attempt to follow the char 8 pointer......) > > If a module which is responsible for mbufs with external storage, > then the free function for that storage will be in the module. If, > after the module is unloaded, mbufs are still allocated which are > using this external storage things will blow up when they are freed. > > So if the free function is still there, so will what the char * > points at. (Unless I'm missing something...) Modules using external clusters that point to some internal state should disallow unload until all such references go away. The char * may need to be allocated via MALLOC and leaked when the module is unloaded if mbufs without external storage are to be tagged with a char *. People get upset when I say "just leak the memory" but in reality the memory used will be very small. Another option is garbage collection, the char * could be contained in a special struct or instead of a char * it could be a pointer to a struct. In order to avoid an aditional refcount just for this pointer one could scan stick a loaded/unloaded bit in the struct. When a module is unloaded it marks the struct as unneeded and moves it to a queue/table it then starts a timer (if not started already) to scan and garbage collect the structs. Since afaik the mbufs are all allocated from a single kernel map, and they are all aligned on a specific boundry, one can scan the mbuf map for pointers to the "dead" structs on exiration of the timer, any structs that aren't found still pointed to can be free'd. *phew* :) -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001115010746.E29448>