slab: Use page struct fields instead of casting
authorChristoph Lameter <cl@linux.com>
Wed, 13 Jun 2012 15:24:55 +0000 (10:24 -0500)
committerPekka Enberg <penberg@kernel.org>
Thu, 14 Jun 2012 06:19:56 +0000 (09:19 +0300)
Add fields to the page struct so that it is properly documented that
slab overlays the lru fields.

This cleans up some casts in slab.

Reviewed-by: Glauber Costa <glommer@parallels.com>
Reviewed-by: Joonsoo Kim <js1304@gmail.com>
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
include/linux/mm_types.h
mm/slab.c

index 5922c345259272fac8db30b6f1bf4905301012b5..680a5e4e8cd50b2db17cc8b7c42f189e4747abcb 100644 (file)
@@ -110,6 +110,10 @@ struct page {
                };
 
                struct list_head list;  /* slobs list of pages */
+               struct {                /* slab fields */
+                       struct kmem_cache *slab_cache;
+                       struct slab *slab_page;
+               };
        };
 
        /* Remainder is not double word aligned */
index e901a36e2520c2b7aa5123ddcd0553415b764397..af05147d7abde6593192d472f54acd1db03719ec 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -496,25 +496,25 @@ static bool slab_max_order_set __initdata;
  */
 static inline void page_set_cache(struct page *page, struct kmem_cache *cache)
 {
-       page->lru.next = (struct list_head *)cache;
+       page->slab_cache = cache;
 }
 
 static inline struct kmem_cache *page_get_cache(struct page *page)
 {
        page = compound_head(page);
        BUG_ON(!PageSlab(page));
-       return (struct kmem_cache *)page->lru.next;
+       return page->slab_cache;
 }
 
 static inline void page_set_slab(struct page *page, struct slab *slab)
 {
-       page->lru.prev = (struct list_head *)slab;
+       page->slab_page = slab;
 }
 
 static inline struct slab *page_get_slab(struct page *page)
 {
        BUG_ON(!PageSlab(page));
-       return (struct slab *)page->lru.prev;
+       return page->slab_page;
 }
 
 static inline struct kmem_cache *virt_to_cache(const void *obj)