aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/slab.c')
-rw-r--r--mm/slab.c27
1 files changed, 2 insertions, 25 deletions
diff --git a/mm/slab.c b/mm/slab.c
index 944b20581f8c..12344432e201 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -409,9 +409,6 @@ struct kmem_cache {
409 /* constructor func */ 409 /* constructor func */
410 void (*ctor) (void *, struct kmem_cache *, unsigned long); 410 void (*ctor) (void *, struct kmem_cache *, unsigned long);
411 411
412 /* de-constructor func */
413 void (*dtor) (void *, struct kmem_cache *, unsigned long);
414
415/* 5) cache creation/removal */ 412/* 5) cache creation/removal */
416 const char *name; 413 const char *name;
417 struct list_head next; 414 struct list_head next;
@@ -1911,20 +1908,11 @@ static void slab_destroy_objs(struct kmem_cache *cachep, struct slab *slabp)
1911 slab_error(cachep, "end of a freed object " 1908 slab_error(cachep, "end of a freed object "
1912 "was overwritten"); 1909 "was overwritten");
1913 } 1910 }
1914 if (cachep->dtor && !(cachep->flags & SLAB_POISON))
1915 (cachep->dtor) (objp + obj_offset(cachep), cachep, 0);
1916 } 1911 }
1917} 1912}
1918#else 1913#else
1919static void slab_destroy_objs(struct kmem_cache *cachep, struct slab *slabp) 1914static void slab_destroy_objs(struct kmem_cache *cachep, struct slab *slabp)
1920{ 1915{
1921 if (cachep->dtor) {
1922 int i;
1923 for (i = 0; i < cachep->num; i++) {
1924 void *objp = index_to_obj(cachep, slabp, i);
1925 (cachep->dtor) (objp, cachep, 0);
1926 }
1927 }
1928} 1916}
1929#endif 1917#endif
1930 1918
@@ -2124,7 +2112,7 @@ static int setup_cpu_cache(struct kmem_cache *cachep)
2124 * @align: The required alignment for the objects. 2112 * @align: The required alignment for the objects.
2125 * @flags: SLAB flags 2113 * @flags: SLAB flags
2126 * @ctor: A constructor for the objects. 2114 * @ctor: A constructor for the objects.
2127 * @dtor: A destructor for the objects. 2115 * @dtor: A destructor for the objects (not implemented anymore).
2128 * 2116 *
2129 * Returns a ptr to the cache on success, NULL on failure. 2117 * Returns a ptr to the cache on success, NULL on failure.
2130 * Cannot be called within a int, but can be interrupted. 2118 * Cannot be called within a int, but can be interrupted.
@@ -2159,7 +2147,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2159 * Sanity checks... these are all serious usage bugs. 2147 * Sanity checks... these are all serious usage bugs.
2160 */ 2148 */
2161 if (!name || in_interrupt() || (size < BYTES_PER_WORD) || 2149 if (!name || in_interrupt() || (size < BYTES_PER_WORD) ||
2162 (size > (1 << MAX_OBJ_ORDER) * PAGE_SIZE) || (dtor && !ctor)) { 2150 (size > (1 << MAX_OBJ_ORDER) * PAGE_SIZE) || dtor) {
2163 printk(KERN_ERR "%s: Early error in slab %s\n", __FUNCTION__, 2151 printk(KERN_ERR "%s: Early error in slab %s\n", __FUNCTION__,
2164 name); 2152 name);
2165 BUG(); 2153 BUG();
@@ -2213,9 +2201,6 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2213 if (flags & SLAB_DESTROY_BY_RCU) 2201 if (flags & SLAB_DESTROY_BY_RCU)
2214 BUG_ON(flags & SLAB_POISON); 2202 BUG_ON(flags & SLAB_POISON);
2215#endif 2203#endif
2216 if (flags & SLAB_DESTROY_BY_RCU)
2217 BUG_ON(dtor);
2218
2219 /* 2204 /*
2220 * Always checks flags, a caller might be expecting debug support which 2205 * Always checks flags, a caller might be expecting debug support which
2221 * isn't available. 2206 * isn't available.
@@ -2370,7 +2355,6 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2370 BUG_ON(!cachep->slabp_cache); 2355 BUG_ON(!cachep->slabp_cache);
2371 } 2356 }
2372 cachep->ctor = ctor; 2357 cachep->ctor = ctor;
2373 cachep->dtor = dtor;
2374 cachep->name = name; 2358 cachep->name = name;
2375 2359
2376 if (setup_cpu_cache(cachep)) { 2360 if (setup_cpu_cache(cachep)) {
@@ -2835,7 +2819,6 @@ failed:
2835 * Perform extra freeing checks: 2819 * Perform extra freeing checks:
2836 * - detect bad pointers. 2820 * - detect bad pointers.
2837 * - POISON/RED_ZONE checking 2821 * - POISON/RED_ZONE checking
2838 * - destructor calls, for caches with POISON+dtor
2839 */ 2822 */
2840static void kfree_debugcheck(const void *objp) 2823static void kfree_debugcheck(const void *objp)
2841{ 2824{
@@ -2894,12 +2877,6 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
2894 BUG_ON(objnr >= cachep->num); 2877 BUG_ON(objnr >= cachep->num);
2895 BUG_ON(objp != index_to_obj(cachep, slabp, objnr)); 2878 BUG_ON(objp != index_to_obj(cachep, slabp, objnr));
2896 2879
2897 if (cachep->flags & SLAB_POISON && cachep->dtor) {
2898 /* we want to cache poison the object,
2899 * call the destruction callback
2900 */
2901 cachep->dtor(objp + obj_offset(cachep), cachep, 0);
2902 }
2903#ifdef CONFIG_DEBUG_SLAB_LEAK 2880#ifdef CONFIG_DEBUG_SLAB_LEAK
2904 slab_bufctl(slabp)[objnr] = BUFCTL_FREE; 2881 slab_bufctl(slabp)[objnr] = BUFCTL_FREE;
2905#endif 2882#endif