Commit 12a7bfad authored by Hui Zhu's avatar Hui Zhu Committed by Linus Torvalds

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;
		/* 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) {
		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
Signed-off-by: default avatarHui Zhu <>
Acked-by: default avatarMinchan Kim <>
Cc: Sergey Senozhatsky <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 8f958c98
......@@ -825,7 +825,7 @@ static unsigned long obj_to_head(struct size_class *class, struct page *page,
if (class->huge) {
return *(unsigned long *)page_private(page);
return page_private(page);
} else
return *(unsigned long *)obj;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment