From: Hui Zhu Date: Sat, 7 Nov 2015 00:29:26 +0000 (-0800) Subject: zsmalloc: fix obj_to_head use page_private(page) as value but not pointer X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=12a7bfad58cd604616dd5205efa6dc2be6f299eb;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git zsmalloc: fix obj_to_head use page_private(page) as value but not pointer In obj_malloc(): if (!class->huge) /* record handle in the header of allocated chunk */ link->handle = handle; else /* record handle in first_page->private */ set_page_private(first_page, handle); In the hugepage we save handle to private directly. But in obj_to_head(): if (class->huge) { VM_BUG_ON(!is_first_page(page)); return *(unsigned long *)page_private(page); } else return *(unsigned long *)obj; It is used as a pointer. The reason why there is no problem until now is huge-class page is born with ZS_FULL so it can't be migrated. However, we need this patch for future work: "VM-aware zsmalloced page migration" to reduce external fragmentation. Signed-off-by: Hui Zhu Acked-by: Minchan Kim Cc: Sergey Senozhatsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 4396b82fabaf..1fe9928d0ff1 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -825,7 +825,7 @@ static unsigned long obj_to_head(struct size_class *class, struct page *page, { if (class->huge) { VM_BUG_ON(!is_first_page(page)); - return *(unsigned long *)page_private(page); + return page_private(page); } else return *(unsigned long *)obj; }