Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e571b0ad authored by Christoph Lameter's avatar Christoph Lameter Committed by Pekka Enberg
Browse files

slab: Use page struct fields instead of casting



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: default avatarGlauber Costa <glommer@parallels.com>
Reviewed-by: default avatarJoonsoo Kim <js1304@gmail.com>
Signed-off-by: default avatarChristoph Lameter <cl@linux.com>
Signed-off-by: default avatarPekka Enberg <penberg@kernel.org>
parent b5568280
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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 */
+4 −4
Original line number Diff line number Diff line
@@ -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)