--- mm/slab.c~ Tue Aug 1 11:07:11 2000
+++ mm/slab.c Tue Aug 1 14:45:44 2000
@@ -987,8 +987,8 @@
* is available. To help debugging, a zero exit status indicates all slabs
* were released.
*/
-int
-kmem_cache_shrink(kmem_cache_t *cachep)
+
+static int __kmem_cache_shrink(kmem_cache_t *cachep, int validated)
{
kmem_cache_t *searchp;
kmem_slab_t *slabp;
@@ -1003,26 +1003,29 @@
return 2;
}
- /* Find the cache in the chain of caches. */
- down(&cache_chain_sem); /* Semaphore is needed. */
- searchp = &cache_cache;
- for (;searchp->c_nextp != &cache_cache; searchp = searchp->c_nextp) {
- if (searchp->c_nextp != cachep)
- continue;
-
- /* Accessing clock_searchp is safe - we hold the mutex. */
- if (cachep == clock_searchp)
- clock_searchp = cachep->c_nextp;
- goto found;
- }
- up(&cache_chain_sem);
- printk(KERN_ERR "kmem_shrink: Invalid cache addr %p\n", cachep);
- return 2;
+ if(validated==0)
+ {
+ /* Find the cache in the chain of caches. */
+ down(&cache_chain_sem); /* Semaphore is needed. */
+ searchp = &cache_cache;
+ for (;searchp->c_nextp != &cache_cache; searchp = searchp->c_nextp) {
+ if (searchp->c_nextp != cachep)
+ continue;
+
+ /* Accessing clock_searchp is safe - we hold the mutex. */
+ if (cachep == clock_searchp)
+ clock_searchp = cachep->c_nextp;
+ goto found;
+ }
+ up(&cache_chain_sem);
+ printk(KERN_ERR "kmem_shrink: Invalid cache addr %p\n", cachep);
+ return 2;
found:
- /* Release the semaphore before getting the cache-lock. This could
- * mean multiple engines are shrinking the cache, but so what.
- */
- up(&cache_chain_sem);
+ /* Release the semaphore before getting the cache-lock. This could
+ * mean multiple engines are shrinking the cache, but so what.
+ */
+ up(&cache_chain_sem);
+ }
spin_lock_irq(&cachep->c_spinlock);
/* If the cache is growing, stop shrinking. */
@@ -1042,6 +1045,11 @@
return ret;
}
+int kmem_cache_shrink(kmem_cache_t *cachep)
+{
+ __kmem_cache_shrink(cachep,0);
+}
+
/*
* Remove a kmem_cache_t object from the slab cache. When returns 0 it
* completed succesfully. -arca
@@ -1087,7 +1095,7 @@
return 1;
}
- if (kmem_cache_shrink(cachep)) {
+ if (__kmem_cache_shrink(cachep, 1)) {
printk(KERN_ERR "kmem_destroy: Can't free all objects %p\n",
cachep);
down(&cache_chain_sem);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]