Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1240449 > unrolled thread

Re: [PATCH] zsmalloc: fix obj_to_head use page_private(page) as value but not pointer

Started byMinchan Kim <minchan@kernel.org>
First post2015-10-06 16:00 +0200
Last post2015-10-07 06:50 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] zsmalloc: fix obj_to_head use page_private(page) as  value but not pointer Minchan Kim <minchan@kernel.org> - 2015-10-06 16:00 +0200
    [PATCH v2] zsmalloc: fix obj_to_head use page_private(page) as value but not pointer Hui Zhu <zhuhui@xiaomi.com> - 2015-10-07 06:50 +0200
    Re: [PATCH] zsmalloc: fix obj_to_head use page_private(page) as value  but not pointer Hui Zhu <teawater@gmail.com> - 2015-10-07 06:50 +0200

#1240449 — Re: [PATCH] zsmalloc: fix obj_to_head use page_private(page) as value but not pointer

FromMinchan Kim <minchan@kernel.org>
Date2015-10-06 16:00 +0200
SubjectRe: [PATCH] zsmalloc: fix obj_to_head use page_private(page) as value but not pointer
Message-ID<qgAWC-7WB-15@gated-at.bofh.it>
Hello,

On Mon, Oct 05, 2015 at 04:23:01PM +0800, Hui Zhu wrote:
> 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 page_private(page);

Typo.
 		return *(unsigned long*)page_private(page);

Please fix the description.

> 	} else
> 		return *(unsigned long *)obj;
> It is used as a pointer.
> 
> So change obj_to_head use page_private(page) as value but not pointer
> in obj_to_head.

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 <zhuhui@xiaomi.com>

With fixing the comment,

Acked-by: Minchan Kim <minchan@kernel.org>

Thanks for the fix, Hui.

-- 
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1241151 — [PATCH v2] zsmalloc: fix obj_to_head use page_private(page) as value but not pointer

FromHui Zhu <zhuhui@xiaomi.com>
Date2015-10-07 06:50 +0200
Subject[PATCH v2] zsmalloc: fix obj_to_head use page_private(page) as value but not pointer
Message-ID<qgOPT-2Ls-3@gated-at.bofh.it>
In reply to#1240449
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 <zhuhui@xiaomi.com>
Acked-by: Minchan Kim <minchan@kernel.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1241152 — Re: [PATCH] zsmalloc: fix obj_to_head use page_private(page) as value but not pointer

FromHui Zhu <teawater@gmail.com>
Date2015-10-07 06:50 +0200
SubjectRe: [PATCH] zsmalloc: fix obj_to_head use page_private(page) as value but not pointer
Message-ID<qgOPU-2Ls-5@gated-at.bofh.it>
In reply to#1240449
On Tue, Oct 6, 2015 at 9:54 PM, Minchan Kim <minchan@kernel.org> wrote:
> Hello,
>
> On Mon, Oct 05, 2015 at 04:23:01PM +0800, Hui Zhu wrote:
>> 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 page_private(page);
>
> Typo.
>                 return *(unsigned long*)page_private(page);
>
> Please fix the description.
>
>>       } else
>>               return *(unsigned long *)obj;
>> It is used as a pointer.
>>
>> So change obj_to_head use page_private(page) as value but not pointer
>> in obj_to_head.
>
> 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 <zhuhui@xiaomi.com>
>
> With fixing the comment,
>
> Acked-by: Minchan Kim <minchan@kernel.org>
>
> Thanks for the fix, Hui.
>

Thanks!  I will post a new version.

Best,
Hui

> --
> Kind regards,
> Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web