No kmem_cache_destroy?

Johannes Erdfelt (jerdfelt@sventech.com)
Fri, 6 Aug 1999 00:21:40 -0400


I'd like to use a kmem_cache in the UHCI module, however I don't see a
good way of doing this. The comments in mm/slab.c are a little confusing:

* Note, caches can _never_ be destroyed. When a sub-system (eg module) has
* finished with a cache, it can only be shrunk. This leaves the cache empty,
* but already enabled for re-use, eg. during a module re-load.

This clearly says there is no destroy function. Then we see:

/* Shrink a cache. Releases as many slabs as possible for a cache.
* It is expected this function will be called by a module when it is
* unloaded. The cache is _not_ removed, this creates too many problems and
* the cache-structure does not take up much room. A module should keep its
* cache pointer(s) in unloaded memory, so when reloaded it knows the cache
* is available. To help debugging, a zero exit status indicates all slabs
* were released.

This then goes on to say that modules should keep a pointer in unloaded
memory. This seems to be more of a kludge than a clean solution.

I've looked at implementing a kmem_cache_destroy function but some of
the comments seem to imply that creating one can't be done. Is there any
technical reason one cannot be created?

BTW - The nfs client module runs into this exact problem. If you load
the nfs client module and then unload and then cat /proc/slabinfo,
instant oops. Usually after this my system comes crashing down shortly
afterwards. (This is with 2.3.12 atleast)

JE

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/