From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752400AbbJGEqF (ORCPT ); Wed, 7 Oct 2015 00:46:05 -0400 Received: from outboundhk.mxmail.xiaomi.com ([207.226.244.122]:18157 "EHLO xiaomi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750931AbbJGEqD (ORCPT ); Wed, 7 Oct 2015 00:46:03 -0400 From: Hui Zhu To: , , , CC: , , , Hui Zhu Subject: [PATCH v2] zsmalloc: fix obj_to_head use page_private(page) as value but not pointer Date: Wed, 7 Oct 2015 12:45:52 +0800 Message-ID: <1444193152-17473-1-git-send-email-zhuhui@xiaomi.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20151006135303.GA31853@blaptop> References: <20151006135303.GA31853@blaptop> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.235.171.10] X-ClientProxiedBy: CNCAS1.mioffice.cn (10.237.8.131) To cnbox3.mioffice.cn (10.237.8.143) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In function 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); The huge's page 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 couldn't be migrated. Therefore, it shouldn't be real bug in practice. 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 --- mm/zsmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index f135b1b..e881d4f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -824,7 +824,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; } -- 1.9.1