]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - mm/slub.c
slub: Add kmem_cache_order_objects struct
[linux-2.6-omap-h63xx.git] / mm / slub.c
index b72bc98e2dc19814405764de399a0d4276232028..0a220df5ed7c7ee0720a5e96f9af65407e45f2c9 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -301,7 +301,7 @@ static inline int check_valid_pointer(struct kmem_cache *s,
                return 1;
 
        base = page_address(page);
-       if (object < base || object >= base + s->objects * s->size ||
+       if (object < base || object >= base + page->objects * s->size ||
                (object - base) % s->size) {
                return 0;
        }
@@ -327,8 +327,8 @@ static inline void set_freepointer(struct kmem_cache *s, void *object, void *fp)
 }
 
 /* Loop over all objects in a slab */
-#define for_each_object(__p, __s, __addr) \
-       for (__p = (__addr); __p < (__addr) + (__s)->objects * (__s)->size;\
+#define for_each_object(__p, __s, __addr, __objects) \
+       for (__p = (__addr); __p < (__addr) + (__objects) * (__s)->size;\
                        __p += (__s)->size)
 
 /* Scan freelist */
@@ -341,6 +341,26 @@ static inline int slab_index(void *p, struct kmem_cache *s, void *addr)
        return (p - addr) / s->size;
 }
 
+static inline struct kmem_cache_order_objects oo_make(int order,
+                                               unsigned long size)
+{
+       struct kmem_cache_order_objects x = {
+               (order << 16) + (PAGE_SIZE << order) / size
+       };
+
+       return x;
+}
+
+static inline int oo_order(struct kmem_cache_order_objects x)
+{
+       return x.x >> 16;
+}
+
+static inline int oo_objects(struct kmem_cache_order_objects x)
+{
+       return x.x & ((1 << 16) - 1);
+}
+
 #ifdef CONFIG_SLUB_DEBUG
 /*
  * Debug settings:
@@ -451,8 +471,8 @@ static void print_tracking(struct kmem_cache *s, void *object)
 
 static void print_page_info(struct page *page)
 {
-       printk(KERN_ERR "INFO: Slab 0x%p used=%u fp=0x%p flags=0x%04lx\n",
-               page, page->inuse, page->freelist, page->flags);
+       printk(KERN_ERR "INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=0x%04lx\n",
+               page, page->objects, page->inuse, page->freelist, page->flags);
 
 }
 
@@ -521,7 +541,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)
 static void object_err(struct kmem_cache *s, struct page *page,
                        u8 *object, char *reason)
 {
-       slab_bug(s, reason);
+       slab_bug(s, "%s", reason);
        print_trailer(s, page, object);
 }
 
@@ -533,7 +553,7 @@ static void slab_err(struct kmem_cache *s, struct page *page, char *fmt, ...)
        va_start(args, fmt);
        vsnprintf(buf, sizeof(buf), fmt, args);
        va_end(args);
-       slab_bug(s, fmt);
+       slab_bug(s, "%s", buf);
        print_page_info(page);
        dump_stack();
 }
@@ -652,6 +672,7 @@ static int check_pad_bytes(struct kmem_cache *s, struct page *page, u8 *p)
                                p + off, POISON_INUSE, s->size - off);
 }
 
+/* Check the pad bytes at the end of a slab page */
 static int slab_pad_check(struct kmem_cache *s, struct page *page)
 {
        u8 *start;
@@ -664,20 +685,20 @@ static int slab_pad_check(struct kmem_cache *s, struct page *page)
                return 1;
 
        start = page_address(page);
-       end = start + (PAGE_SIZE << s->order);
-       length = s->objects * s->size;
-       remainder = end - (start + length);
+       length = (PAGE_SIZE << compound_order(page));
+       end = start + length;
+       remainder = length % s->size;
        if (!remainder)
                return 1;
 
-       fault = check_bytes(start + length, POISON_INUSE, remainder);
+       fault = check_bytes(end - remainder, POISON_INUSE, remainder);
        if (!fault)
                return 1;
        while (end > fault && end[-1] == POISON_INUSE)
                end--;
 
        slab_err(s, page, "Padding overwritten. 0x%p-0x%p", fault, end - 1);
-       print_section("Padding", start, length);
+       print_section("Padding", end - remainder, remainder);
 
        restore_bytes(s, "slab padding", POISON_INUSE, start, end);
        return 0;
@@ -739,15 +760,24 @@ static int check_object(struct kmem_cache *s, struct page *page,
 
 static int check_slab(struct kmem_cache *s, struct page *page)
 {
+       int maxobj;
+
        VM_BUG_ON(!irqs_disabled());
 
        if (!PageSlab(page)) {
                slab_err(s, page, "Not a valid slab page");
                return 0;
        }
-       if (page->inuse > s->objects) {
+
+       maxobj = (PAGE_SIZE << compound_order(page)) / s->size;
+       if (page->objects > maxobj) {
+               slab_err(s, page, "objects %u > max %u",
+                       s->name, page->objects, maxobj);
+               return 0;
+       }
+       if (page->inuse > page->objects) {
                slab_err(s, page, "inuse %u > max %u",
-                       s->name, page->inuse, s->objects);
+                       s->name, page->inuse, page->objects);
                return 0;
        }
        /* Slab_pad_check fixes things up after itself */
@@ -764,8 +794,9 @@ static int on_freelist(struct kmem_cache *s, struct page *page, void *search)
        int nr = 0;
        void *fp = page->freelist;
        void *object = NULL;
+       unsigned long max_objects;
 
-       while (fp && nr <= s->objects) {
+       while (fp && nr <= page->objects) {
                if (fp == search)
                        return 1;
                if (!check_valid_pointer(s, page, fp)) {
@@ -777,7 +808,7 @@ static int on_freelist(struct kmem_cache *s, struct page *page, void *search)
                        } else {
                                slab_err(s, page, "Freepointer corrupt");
                                page->freelist = NULL;
-                               page->inuse = s->objects;
+                               page->inuse = page->objects;
                                slab_fix(s, "Freelist cleared");
                                return 0;
                        }
@@ -788,10 +819,20 @@ static int on_freelist(struct kmem_cache *s, struct page *page, void *search)
                nr++;
        }
 
-       if (page->inuse != s->objects - nr) {
+       max_objects = (PAGE_SIZE << compound_order(page)) / s->size;
+       if (max_objects > 65535)
+               max_objects = 65535;
+
+       if (page->objects != max_objects) {
+               slab_err(s, page, "Wrong number of objects. Found %d but "
+                       "should be %d", page->objects, max_objects);
+               page->objects = max_objects;
+               slab_fix(s, "Number of objects adjusted.");
+       }
+       if (page->inuse != page->objects - nr) {
                slab_err(s, page, "Wrong object count. Counter is %d but "
-                       "counted were %d", page->inuse, s->objects - nr);
-               page->inuse = s->objects - nr;
+                       "counted were %d", page->inuse, page->objects - nr);
+               page->inuse = page->objects - nr;
                slab_fix(s, "Object count adjusted.");
        }
        return search == NULL;
@@ -837,6 +878,35 @@ static void remove_full(struct kmem_cache *s, struct page *page)
        spin_unlock(&n->list_lock);
 }
 
+/* Tracking of the number of slabs for debugging purposes */
+static inline unsigned long slabs_node(struct kmem_cache *s, int node)
+{
+       struct kmem_cache_node *n = get_node(s, node);
+
+       return atomic_long_read(&n->nr_slabs);
+}
+
+static inline void inc_slabs_node(struct kmem_cache *s, int node)
+{
+       struct kmem_cache_node *n = get_node(s, node);
+
+       /*
+        * May be called early in order to allocate a slab for the
+        * kmem_cache_node structure. Solve the chicken-egg
+        * dilemma by deferring the increment of the count during
+        * bootstrap (see early_kmem_cache_node_alloc).
+        */
+       if (!NUMA_BUILD || n)
+               atomic_long_inc(&n->nr_slabs);
+}
+static inline void dec_slabs_node(struct kmem_cache *s, int node)
+{
+       struct kmem_cache_node *n = get_node(s, node);
+
+       atomic_long_dec(&n->nr_slabs);
+}
+
+/* Object debug checks for alloc/free paths */
 static void setup_object_debug(struct kmem_cache *s, struct page *page,
                                                                void *object)
 {
@@ -881,7 +951,7 @@ bad:
                 * as used avoids touching the remaining objects.
                 */
                slab_fix(s, "Marking all objects used");
-               page->inuse = s->objects;
+               page->inuse = page->objects;
                page->freelist = NULL;
        }
        return 0;
@@ -1028,6 +1098,11 @@ static inline unsigned long kmem_cache_flags(unsigned long objsize,
        return flags;
 }
 #define slub_debug 0
+
+static inline unsigned long slabs_node(struct kmem_cache *s, int node)
+                                                       { return 0; }
+static inline void inc_slabs_node(struct kmem_cache *s, int node) {}
+static inline void dec_slabs_node(struct kmem_cache *s, int node) {}
 #endif
 /*
  * Slab allocation and freeing
@@ -1035,18 +1110,21 @@ static inline unsigned long kmem_cache_flags(unsigned long objsize,
 static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
 {
        struct page *page;
-       int pages = 1 << s->order;
+       struct kmem_cache_order_objects oo = s->oo;
+       int order = oo_order(oo);
+       int pages = 1 << order;
 
        flags |= s->allocflags;
 
        if (node == -1)
-               page = alloc_pages(flags, s->order);
+               page = alloc_pages(flags, order);
        else
-               page = alloc_pages_node(node, flags, s->order);
+               page = alloc_pages_node(node, flags, order);
 
        if (!page)
                return NULL;
 
+       page->objects = oo_objects(oo);
        mod_zone_page_state(page_zone(page),
                (s->flags & SLAB_RECLAIM_ACCOUNT) ?
                NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
@@ -1066,7 +1144,6 @@ static void setup_object(struct kmem_cache *s, struct page *page,
 static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
 {
        struct page *page;
-       struct kmem_cache_node *n;
        void *start;
        void *last;
        void *p;
@@ -1078,9 +1155,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
        if (!page)
                goto out;
 
-       n = get_node(s, page_to_nid(page));
-       if (n)
-               atomic_long_inc(&n->nr_slabs);
+       inc_slabs_node(s, page_to_nid(page));
        page->slab = s;
        page->flags |= 1 << PG_slab;
        if (s->flags & (SLAB_DEBUG_FREE | SLAB_RED_ZONE | SLAB_POISON |
@@ -1090,10 +1165,10 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
        start = page_address(page);
 
        if (unlikely(s->flags & SLAB_POISON))
-               memset(start, POISON_INUSE, PAGE_SIZE << s->order);
+               memset(start, POISON_INUSE, PAGE_SIZE << compound_order(page));
 
        last = start;
-       for_each_object(p, s, start) {
+       for_each_object(p, s, start, page->objects) {
                setup_object(s, page, last);
                set_freepointer(s, last, p);
                last = p;
@@ -1109,13 +1184,15 @@ out:
 
 static void __free_slab(struct kmem_cache *s, struct page *page)
 {
-       int pages = 1 << s->order;
+       int order = compound_order(page);
+       int pages = 1 << order;
 
        if (unlikely(SlabDebug(page))) {
                void *p;
 
                slab_pad_check(s, page);
-               for_each_object(p, s, page_address(page))
+               for_each_object(p, s, page_address(page),
+                                               page->objects)
                        check_object(s, page, p, 0);
                ClearSlabDebug(page);
        }
@@ -1125,7 +1202,9 @@ static void __free_slab(struct kmem_cache *s, struct page *page)
                NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
                -pages);
 
-       __free_pages(page, s->order);
+       __ClearPageSlab(page);
+       reset_page_mapcount(page);
+       __free_pages(page, order);
 }
 
 static void rcu_free_slab(struct rcu_head *h)
@@ -1151,11 +1230,7 @@ static void free_slab(struct kmem_cache *s, struct page *page)
 
 static void discard_slab(struct kmem_cache *s, struct page *page)
 {
-       struct kmem_cache_node *n = get_node(s, page_to_nid(page));
-
-       atomic_long_dec(&n->nr_slabs);
-       reset_page_mapcount(page);
-       __ClearPageSlab(page);
+       dec_slabs_node(s, page_to_nid(page));
        free_slab(s, page);
 }
 
@@ -1470,6 +1545,9 @@ static void *__slab_alloc(struct kmem_cache *s,
        void **object;
        struct page *new;
 
+       /* We handle __GFP_ZERO in the caller */
+       gfpflags &= ~__GFP_ZERO;
+
        if (!c->page)
                goto new_slab;
 
@@ -1487,7 +1565,7 @@ load_freelist:
                goto debug;
 
        c->freelist = object[c->offset];
-       c->page->inuse = s->objects;
+       c->page->inuse = c->page->objects;
        c->page->freelist = NULL;
        c->node = page_to_nid(c->page);
 unlock_out:
@@ -1786,6 +1864,9 @@ static inline int slab_order(int size, int min_objects,
        int rem;
        int min_order = slub_min_order;
 
+       if ((PAGE_SIZE << min_order) / size > 65535)
+               return get_order(size * 65535) - 1;
+
        for (order = max(min_order,
                                fls(min_objects * size - 1) - PAGE_SHIFT);
                        order <= max_order; order++) {
@@ -1883,15 +1964,18 @@ static void init_kmem_cache_cpu(struct kmem_cache *s,
        c->node = 0;
        c->offset = s->offset / sizeof(void *);
        c->objsize = s->objsize;
+#ifdef CONFIG_SLUB_STATS
+       memset(c->stat, 0, NR_SLUB_STAT_ITEMS * sizeof(unsigned));
+#endif
 }
 
 static void init_kmem_cache_node(struct kmem_cache_node *n)
 {
        n->nr_partial = 0;
-       atomic_long_set(&n->nr_slabs, 0);
        spin_lock_init(&n->list_lock);
        INIT_LIST_HEAD(&n->partial);
 #ifdef CONFIG_SLUB_DEBUG
+       atomic_long_set(&n->nr_slabs, 0);
        INIT_LIST_HEAD(&n->full);
 #endif
 }
@@ -2060,7 +2144,7 @@ static struct kmem_cache_node *early_kmem_cache_node_alloc(gfp_t gfpflags,
        init_tracking(kmalloc_caches, n);
 #endif
        init_kmem_cache_node(n);
-       atomic_long_inc(&n->nr_slabs);
+       inc_slabs_node(kmalloc_caches, node);
 
        /*
         * lockdep requires consistent irq usage for each lock
@@ -2141,6 +2225,7 @@ static int calculate_sizes(struct kmem_cache *s)
        unsigned long flags = s->flags;
        unsigned long size = s->objsize;
        unsigned long align = s->align;
+       int order;
 
        /*
         * Round up object size to the next word boundary. We can only
@@ -2233,17 +2318,17 @@ static int calculate_sizes(struct kmem_cache *s)
                 * page allocator order 0 allocs so take a reasonably large
                 * order that will allows us a good number of objects.
                 */
-               s->order = max(slub_max_order, PAGE_ALLOC_COSTLY_ORDER);
+               order = max(slub_max_order, PAGE_ALLOC_COSTLY_ORDER);
                s->flags |= __PAGE_ALLOC_FALLBACK;
                s->allocflags |= __GFP_NOWARN;
        } else
-               s->order = calculate_order(size);
+               order = calculate_order(size);
 
-       if (s->order < 0)
+       if (order < 0)
                return 0;
 
        s->allocflags = 0;
-       if (s->order)
+       if (order)
                s->allocflags |= __GFP_COMP;
 
        if (s->flags & SLAB_CACHE_DMA)
@@ -2255,9 +2340,9 @@ static int calculate_sizes(struct kmem_cache *s)
        /*
         * Determine the number of objects per slab
         */
-       s->objects = (PAGE_SIZE << s->order) / size;
+       s->oo = oo_make(order, size);
 
-       return !!s->objects;
+       return !!oo_objects(s->oo);
 
 }
 
@@ -2290,7 +2375,7 @@ error:
        if (flags & SLAB_PANIC)
                panic("Cannot create slab %s size=%lu realsize=%u "
                        "order=%u offset=%u flags=%lx\n",
-                       s->name, (unsigned long)size, s->size, s->order,
+                       s->name, (unsigned long)size, s->size, oo_order(s->oo),
                        s->offset, flags);
        return 0;
 }
@@ -2336,26 +2421,52 @@ const char *kmem_cache_name(struct kmem_cache *s)
 }
 EXPORT_SYMBOL(kmem_cache_name);
 
+static void list_slab_objects(struct kmem_cache *s, struct page *page,
+                                                       const char *text)
+{
+#ifdef CONFIG_SLUB_DEBUG
+       void *addr = page_address(page);
+       void *p;
+       DECLARE_BITMAP(map, page->objects);
+
+       bitmap_zero(map, page->objects);
+       slab_err(s, page, "%s", text);
+       slab_lock(page);
+       for_each_free_object(p, s, page->freelist)
+               set_bit(slab_index(p, s, addr), map);
+
+       for_each_object(p, s, addr, page->objects) {
+
+               if (!test_bit(slab_index(p, s, addr), map)) {
+                       printk(KERN_ERR "INFO: Object 0x%p @offset=%tu\n",
+                                                       p, p - addr);
+                       print_tracking(s, p);
+               }
+       }
+       slab_unlock(page);
+#endif
+}
+
 /*
- * Attempt to free all slabs on a node. Return the number of slabs we
- * were unable to free.
+ * Attempt to free all partial slabs on a node.
  */
-static int free_list(struct kmem_cache *s, struct kmem_cache_node *n,
-                       struct list_head *list)
+static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
 {
-       int slabs_inuse = 0;
        unsigned long flags;
        struct page *page, *h;
 
        spin_lock_irqsave(&n->list_lock, flags);
-       list_for_each_entry_safe(page, h, list, lru)
+       list_for_each_entry_safe(page, h, &n->partial, lru) {
                if (!page->inuse) {
                        list_del(&page->lru);
                        discard_slab(s, page);
-               } else
-                       slabs_inuse++;
+                       n->nr_partial--;
+               } else {
+                       list_slab_objects(s, page,
+                               "Objects remaining on kmem_cache_close()");
+               }
+       }
        spin_unlock_irqrestore(&n->list_lock, flags);
-       return slabs_inuse;
 }
 
 /*
@@ -2372,8 +2483,8 @@ static inline int kmem_cache_close(struct kmem_cache *s)
        for_each_node_state(node, N_NORMAL_MEMORY) {
                struct kmem_cache_node *n = get_node(s, node);
 
-               n->nr_partial -= free_list(s, n, &n->partial);
-               if (atomic_long_read(&n->nr_slabs))
+               free_partial(s, n);
+               if (n->nr_partial || slabs_node(s, node))
                        return 1;
        }
        free_kmem_cache_nodes(s);
@@ -2391,8 +2502,11 @@ void kmem_cache_destroy(struct kmem_cache *s)
        if (!s->refcount) {
                list_del(&s->list);
                up_write(&slub_lock);
-               if (kmem_cache_close(s))
-                       WARN_ON(1);
+               if (kmem_cache_close(s)) {
+                       printk(KERN_ERR "SLUB %s: %s called for cache that "
+                               "still has objects.\n", s->name, __func__);
+                       dump_stack();
+               }
                sysfs_slab_remove(s);
        } else
                up_write(&slub_lock);
@@ -2406,10 +2520,6 @@ EXPORT_SYMBOL(kmem_cache_destroy);
 struct kmem_cache kmalloc_caches[PAGE_SHIFT + 1] __cacheline_aligned;
 EXPORT_SYMBOL(kmalloc_caches);
 
-#ifdef CONFIG_ZONE_DMA
-static struct kmem_cache *kmalloc_caches_dma[PAGE_SHIFT + 1];
-#endif
-
 static int __init setup_slub_min_order(char *str)
 {
        get_option(&str, &slub_min_order);
@@ -2469,6 +2579,7 @@ panic:
 }
 
 #ifdef CONFIG_ZONE_DMA
+static struct kmem_cache *kmalloc_caches_dma[PAGE_SHIFT + 1];
 
 static void sysfs_add_func(struct work_struct *w)
 {
@@ -2685,21 +2796,6 @@ void kfree(const void *x)
 }
 EXPORT_SYMBOL(kfree);
 
-#if defined(SLUB_DEBUG) || defined(CONFIG_SLABINFO)
-static unsigned long count_partial(struct kmem_cache_node *n)
-{
-       unsigned long flags;
-       unsigned long x = 0;
-       struct page *page;
-
-       spin_lock_irqsave(&n->list_lock, flags);
-       list_for_each_entry(page, &n->partial, lru)
-               x += page->inuse;
-       spin_unlock_irqrestore(&n->list_lock, flags);
-       return x;
-}
-#endif
-
 /*
  * kmem_cache_shrink removes empty slabs from the partial lists and sorts
  * the remaining slabs by the number of items in use. The slabs with the
@@ -2717,8 +2813,9 @@ int kmem_cache_shrink(struct kmem_cache *s)
        struct kmem_cache_node *n;
        struct page *page;
        struct page *t;
+       int objects = oo_objects(s->oo);
        struct list_head *slabs_by_inuse =
-               kmalloc(sizeof(struct list_head) * s->objects, GFP_KERNEL);
+               kmalloc(sizeof(struct list_head) * objects, GFP_KERNEL);
        unsigned long flags;
 
        if (!slabs_by_inuse)
@@ -2731,7 +2828,7 @@ int kmem_cache_shrink(struct kmem_cache *s)
                if (!n->nr_partial)
                        continue;
 
-               for (i = 0; i < s->objects; i++)
+               for (i = 0; i < objects; i++)
                        INIT_LIST_HEAD(slabs_by_inuse + i);
 
                spin_lock_irqsave(&n->list_lock, flags);
@@ -2763,7 +2860,7 @@ int kmem_cache_shrink(struct kmem_cache *s)
                 * Rebuild the partial list with the slabs filled up most
                 * first and the least used slabs at the end.
                 */
-               for (i = s->objects - 1; i >= 0; i--)
+               for (i = objects - 1; i >= 0; i--)
                        list_splice(slabs_by_inuse + i, n->partial.prev);
 
                spin_unlock_irqrestore(&n->list_lock, flags);
@@ -2813,7 +2910,7 @@ static void slab_mem_offline_callback(void *arg)
                         * and offline_pages() function shoudn't call this
                         * callback. So, we must fail.
                         */
-                       BUG_ON(atomic_long_read(&n->nr_slabs));
+                       BUG_ON(slabs_node(s, offline_node));
 
                        s->node[offline_node] = NULL;
                        kmem_cache_free(kmalloc_caches, n);
@@ -3178,6 +3275,21 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
        return slab_alloc(s, gfpflags, node, caller);
 }
 
+#if (defined(CONFIG_SYSFS) && defined(CONFIG_SLUB_DEBUG)) || defined(CONFIG_SLABINFO)
+static unsigned long count_partial(struct kmem_cache_node *n)
+{
+       unsigned long flags;
+       unsigned long x = 0;
+       struct page *page;
+
+       spin_lock_irqsave(&n->list_lock, flags);
+       list_for_each_entry(page, &n->partial, lru)
+               x += page->inuse;
+       spin_unlock_irqrestore(&n->list_lock, flags);
+       return x;
+}
+#endif
+
 #if defined(CONFIG_SYSFS) && defined(CONFIG_SLUB_DEBUG)
 static int validate_slab(struct kmem_cache *s, struct page *page,
                                                unsigned long *map)
@@ -3190,7 +3302,7 @@ static int validate_slab(struct kmem_cache *s, struct page *page,
                return 0;
 
        /* Now we know that a valid freelist exists */
-       bitmap_zero(map, s->objects);
+       bitmap_zero(map, page->objects);
 
        for_each_free_object(p, s, page->freelist) {
                set_bit(slab_index(p, s, addr), map);
@@ -3198,7 +3310,7 @@ static int validate_slab(struct kmem_cache *s, struct page *page,
                        return 0;
        }
 
-       for_each_object(p, s, addr)
+       for_each_object(p, s, addr, page->objects)
                if (!test_bit(slab_index(p, s, addr), map))
                        if (!check_object(s, page, p, 1))
                                return 0;
@@ -3264,7 +3376,7 @@ static long validate_slab_cache(struct kmem_cache *s)
 {
        int node;
        unsigned long count = 0;
-       unsigned long *map = kmalloc(BITS_TO_LONGS(s->objects) *
+       unsigned long *map = kmalloc(BITS_TO_LONGS(oo_objects(s->oo)) *
                                sizeof(unsigned long), GFP_KERNEL);
 
        if (!map)
@@ -3467,14 +3579,14 @@ static void process_slab(struct loc_track *t, struct kmem_cache *s,
                struct page *page, enum track_item alloc)
 {
        void *addr = page_address(page);
-       DECLARE_BITMAP(map, s->objects);
+       DECLARE_BITMAP(map, page->objects);
        void *p;
 
-       bitmap_zero(map, s->objects);
+       bitmap_zero(map, page->objects);
        for_each_free_object(p, s, page->freelist)
                set_bit(slab_index(p, s, addr), map);
 
-       for_each_object(p, s, addr)
+       for_each_object(p, s, addr, page->objects)
                if (!test_bit(slab_index(p, s, addr), map))
                        add_location(t, s, get_track(s, p, alloc));
 }
@@ -3632,7 +3744,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s,
                                        - n->nr_partial;
 
                        if (flags & SO_OBJECTS)
-                               x = full_slabs * s->objects;
+                               x = full_slabs * oo_objects(s->oo);
                        else
                                x = full_slabs;
                        total += x;
@@ -3711,13 +3823,13 @@ SLAB_ATTR_RO(object_size);
 
 static ssize_t objs_per_slab_show(struct kmem_cache *s, char *buf)
 {
-       return sprintf(buf, "%d\n", s->objects);
+       return sprintf(buf, "%d\n", oo_objects(s->oo));
 }
 SLAB_ATTR_RO(objs_per_slab);
 
 static ssize_t order_show(struct kmem_cache *s, char *buf)
 {
-       return sprintf(buf, "%d\n", s->order);
+       return sprintf(buf, "%d\n", oo_order(s->oo));
 }
 SLAB_ATTR_RO(order);
 
@@ -3976,10 +4088,12 @@ static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si)
 
        len = sprintf(buf, "%lu", sum);
 
+#ifdef CONFIG_SMP
        for_each_online_cpu(cpu) {
                if (data[cpu] && len < PAGE_SIZE - 20)
-                       len += sprintf(buf + len, " c%d=%u", cpu, data[cpu]);
+                       len += sprintf(buf + len, " C%d=%u", cpu, data[cpu]);
        }
+#endif
        kfree(data);
        return len + sprintf(buf + len, "\n");
 }
@@ -4362,11 +4476,12 @@ static int s_show(struct seq_file *m, void *p)
                nr_inuse += count_partial(n);
        }
 
-       nr_objs = nr_slabs * s->objects;
-       nr_inuse += (nr_slabs - nr_partials) * s->objects;
+       nr_objs = nr_slabs * oo_objects(s->oo);
+       nr_inuse += (nr_slabs - nr_partials) * oo_objects(s->oo);
 
        seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d", s->name, nr_inuse,
-                  nr_objs, s->size, s->objects, (1 << s->order));
+                  nr_objs, s->size, oo_objects(s->oo),
+                  (1 << oo_order(s->oo)));
        seq_printf(m, " : tunables %4u %4u %4u", 0, 0, 0);
        seq_printf(m, " : slabdata %6lu %6lu %6lu", nr_slabs, nr_slabs,
                   0UL);