linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] zsmalloc documentation
@ 2012-06-10  0:41 Nitin Gupta
  2012-06-10  0:44 ` Konrad Rzeszutek Wilk
  2012-06-11  2:25 ` Minchan Kim
  0 siblings, 2 replies; 5+ messages in thread
From: Nitin Gupta @ 2012-06-10  0:41 UTC (permalink / raw)
  To: Greg KH
  Cc: Dan Magenheimer, Konrad Rzeszutek Wilk, Seth Jennings,
	Minchan Kim, linux-mm, linux-kernel, Nitin Gupta

Documentation of various struct page fields
used by zsmalloc.

Signed-off-by: Nitin Gupta <ngupta@vflare.org>

Changes for v2:
	- Regroup descriptions as suggested by Seth
---
 drivers/staging/zsmalloc/zsmalloc-main.c |   48 ++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
index 4496737..1db76ec 100644
--- a/drivers/staging/zsmalloc/zsmalloc-main.c
+++ b/drivers/staging/zsmalloc/zsmalloc-main.c
@@ -10,6 +10,54 @@
  * Released under the terms of GNU General Public License Version 2.0
  */
 
+
+/*
+ * This allocator is designed for use with zcache and zram. Thus, the
+ * allocator is supposed to work well under low memory conditions. In
+ * particular, it never attempts higher order page allocation which is
+ * very likely to fail under memory pressure. On the other hand, if we
+ * just use single (0-order) pages, it would suffer from very high
+ * fragmentation -- any object of size PAGE_SIZE/2 or larger would occupy
+ * an entire page. This was one of the major issues with its predecessor
+ * (xvmalloc).
+ *
+ * To overcome these issues, zsmalloc allocates a bunch of 0-order pages
+ * and links them together using various 'struct page' fields. These linked
+ * pages act as a single higher-order page i.e. an object can span 0-order
+ * page boundaries. The code refers to these linked pages as a single entity
+ * called zspage.
+ *
+ * Following is how we use various fields and flags of underlying
+ * struct page(s) to form a zspage.
+ *
+ * Usage of struct page fields:
+ *	page->first_page: points to the first component (0-order) page
+ *	page->index (union with page->freelist): offset of the first object
+ *		starting in this page. For the first page, this is
+ *		always 0, so we use this field (aka freelist) to point
+ *		to the first free object in zspage.
+ *	page->lru: links together all component pages (except the first page)
+ *		of a zspage
+ *
+ *	For _first_ page only:
+ *
+ *	page->private (union with page->first_page): refers to the
+ *		component page after the first page
+ *	page->freelist: points to the first free object in zspage.
+ *		Free objects are linked together using in-place
+ *		metadata.
+ *	page->objects: maximum number of objects we can store in this
+ *		zspage (class->zspage_order * PAGE_SIZE / class->size)
+ *	page->lru: links together first pages of various zspages.
+ *		Basically forming list of zspages in a fullness group.
+ *	page->mapping: class index and fullness group of the zspage
+ *
+ * Usage of struct page flags:
+ *	PG_private: identifies the first component page
+ *	PG_private2: identifies the last component page
+ *
+ */
+
 #ifdef CONFIG_ZSMALLOC_DEBUG
 #define DEBUG
 #endif
-- 
1.7.10.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] zsmalloc documentation
  2012-06-10  0:41 [PATCH v2] zsmalloc documentation Nitin Gupta
@ 2012-06-10  0:44 ` Konrad Rzeszutek Wilk
  2012-06-10  0:49   ` Nitin Gupta
  2012-06-11  2:25 ` Minchan Kim
  1 sibling, 1 reply; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-06-10  0:44 UTC (permalink / raw)
  To: Nitin Gupta
  Cc: Greg KH, Dan Magenheimer, Konrad Rzeszutek Wilk, Seth Jennings,
	Minchan Kim, linux-mm, linux-kernel

On Sat, Jun 09, 2012 at 05:41:14PM -0700, Nitin Gupta wrote:
> Documentation of various struct page fields
> used by zsmalloc.
> 
> Signed-off-by: Nitin Gupta <ngupta@vflare.org>
> 
> Changes for v2:
> 	- Regroup descriptions as suggested by Seth
                                               ^^ - Konrad

Otherwise: Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

> ---
>  drivers/staging/zsmalloc/zsmalloc-main.c |   48 ++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
> 
> diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
> index 4496737..1db76ec 100644
> --- a/drivers/staging/zsmalloc/zsmalloc-main.c
> +++ b/drivers/staging/zsmalloc/zsmalloc-main.c
> @@ -10,6 +10,54 @@
>   * Released under the terms of GNU General Public License Version 2.0
>   */
>  
> +
> +/*
> + * This allocator is designed for use with zcache and zram. Thus, the
> + * allocator is supposed to work well under low memory conditions. In
> + * particular, it never attempts higher order page allocation which is
> + * very likely to fail under memory pressure. On the other hand, if we
> + * just use single (0-order) pages, it would suffer from very high
> + * fragmentation -- any object of size PAGE_SIZE/2 or larger would occupy
> + * an entire page. This was one of the major issues with its predecessor
> + * (xvmalloc).
> + *
> + * To overcome these issues, zsmalloc allocates a bunch of 0-order pages
> + * and links them together using various 'struct page' fields. These linked
> + * pages act as a single higher-order page i.e. an object can span 0-order
> + * page boundaries. The code refers to these linked pages as a single entity
> + * called zspage.
> + *
> + * Following is how we use various fields and flags of underlying
> + * struct page(s) to form a zspage.
> + *
> + * Usage of struct page fields:
> + *	page->first_page: points to the first component (0-order) page
> + *	page->index (union with page->freelist): offset of the first object
> + *		starting in this page. For the first page, this is
> + *		always 0, so we use this field (aka freelist) to point
> + *		to the first free object in zspage.
> + *	page->lru: links together all component pages (except the first page)
> + *		of a zspage
> + *
> + *	For _first_ page only:
> + *
> + *	page->private (union with page->first_page): refers to the
> + *		component page after the first page
> + *	page->freelist: points to the first free object in zspage.
> + *		Free objects are linked together using in-place
> + *		metadata.
> + *	page->objects: maximum number of objects we can store in this
> + *		zspage (class->zspage_order * PAGE_SIZE / class->size)
> + *	page->lru: links together first pages of various zspages.
> + *		Basically forming list of zspages in a fullness group.
> + *	page->mapping: class index and fullness group of the zspage
> + *
> + * Usage of struct page flags:
> + *	PG_private: identifies the first component page
> + *	PG_private2: identifies the last component page
> + *
> + */
> +
>  #ifdef CONFIG_ZSMALLOC_DEBUG
>  #define DEBUG
>  #endif
> -- 
> 1.7.10.2
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] zsmalloc documentation
  2012-06-10  0:44 ` Konrad Rzeszutek Wilk
@ 2012-06-10  0:49   ` Nitin Gupta
  2012-06-11 16:01     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Nitin Gupta @ 2012-06-10  0:49 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Greg KH, Dan Magenheimer, Konrad Rzeszutek Wilk, Seth Jennings,
	Minchan Kim, linux-mm, linux-kernel

On 06/09/2012 05:44 PM, Konrad Rzeszutek Wilk wrote:

> On Sat, Jun 09, 2012 at 05:41:14PM -0700, Nitin Gupta wrote:
>> Documentation of various struct page fields
>> used by zsmalloc.
>>
>> Signed-off-by: Nitin Gupta <ngupta@vflare.org>
>>
>> Changes for v2:
>> 	- Regroup descriptions as suggested by Seth
>                                                ^^ - Konrad
> 
> Otherwise: Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> 


Sorry about that, Konrad!
Greg: Please let me know if I should resend the patch with corrected
name in the changelog.

Thanks,
Nitin

>> ---
>>  drivers/staging/zsmalloc/zsmalloc-main.c |   48 ++++++++++++++++++++++++++++++
>>  1 file changed, 48 insertions(+)
>>
>> diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
>> index 4496737..1db76ec 100644
>> --- a/drivers/staging/zsmalloc/zsmalloc-main.c
>> +++ b/drivers/staging/zsmalloc/zsmalloc-main.c
>> @@ -10,6 +10,54 @@
>>   * Released under the terms of GNU General Public License Version 2.0
>>   */
>>  
>> +
>> +/*
>> + * This allocator is designed for use with zcache and zram. Thus, the
>> + * allocator is supposed to work well under low memory conditions. In
>> + * particular, it never attempts higher order page allocation which is
>> + * very likely to fail under memory pressure. On the other hand, if we
>> + * just use single (0-order) pages, it would suffer from very high
>> + * fragmentation -- any object of size PAGE_SIZE/2 or larger would occupy
>> + * an entire page. This was one of the major issues with its predecessor
>> + * (xvmalloc).
>> + *
>> + * To overcome these issues, zsmalloc allocates a bunch of 0-order pages
>> + * and links them together using various 'struct page' fields. These linked
>> + * pages act as a single higher-order page i.e. an object can span 0-order
>> + * page boundaries. The code refers to these linked pages as a single entity
>> + * called zspage.
>> + *
>> + * Following is how we use various fields and flags of underlying
>> + * struct page(s) to form a zspage.
>> + *
>> + * Usage of struct page fields:
>> + *	page->first_page: points to the first component (0-order) page
>> + *	page->index (union with page->freelist): offset of the first object
>> + *		starting in this page. For the first page, this is
>> + *		always 0, so we use this field (aka freelist) to point
>> + *		to the first free object in zspage.
>> + *	page->lru: links together all component pages (except the first page)
>> + *		of a zspage
>> + *
>> + *	For _first_ page only:
>> + *
>> + *	page->private (union with page->first_page): refers to the
>> + *		component page after the first page
>> + *	page->freelist: points to the first free object in zspage.
>> + *		Free objects are linked together using in-place
>> + *		metadata.
>> + *	page->objects: maximum number of objects we can store in this
>> + *		zspage (class->zspage_order * PAGE_SIZE / class->size)
>> + *	page->lru: links together first pages of various zspages.
>> + *		Basically forming list of zspages in a fullness group.
>> + *	page->mapping: class index and fullness group of the zspage
>> + *
>> + * Usage of struct page flags:
>> + *	PG_private: identifies the first component page
>> + *	PG_private2: identifies the last component page
>> + *
>> + */
>> +
>>  #ifdef CONFIG_ZSMALLOC_DEBUG
>>  #define DEBUG
>>  #endif
>> -- 
>> 1.7.10.2
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to majordomo@kvack.org.  For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>>


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] zsmalloc documentation
  2012-06-10  0:41 [PATCH v2] zsmalloc documentation Nitin Gupta
  2012-06-10  0:44 ` Konrad Rzeszutek Wilk
@ 2012-06-11  2:25 ` Minchan Kim
  1 sibling, 0 replies; 5+ messages in thread
From: Minchan Kim @ 2012-06-11  2:25 UTC (permalink / raw)
  To: Nitin Gupta
  Cc: Greg KH, Dan Magenheimer, Konrad Rzeszutek Wilk, Seth Jennings,
	Minchan Kim, linux-mm, linux-kernel

On 06/10/2012 09:41 AM, Nitin Gupta wrote:

> Documentation of various struct page fields
> used by zsmalloc.
> 
> Signed-off-by: Nitin Gupta <ngupta@vflare.org>
> 


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

-- 
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] zsmalloc documentation
  2012-06-10  0:49   ` Nitin Gupta
@ 2012-06-11 16:01     ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2012-06-11 16:01 UTC (permalink / raw)
  To: Nitin Gupta
  Cc: Konrad Rzeszutek Wilk, Dan Magenheimer, Konrad Rzeszutek Wilk,
	Seth Jennings, Minchan Kim, linux-mm, linux-kernel

On Sat, Jun 09, 2012 at 05:49:42PM -0700, Nitin Gupta wrote:
> On 06/09/2012 05:44 PM, Konrad Rzeszutek Wilk wrote:
> 
> > On Sat, Jun 09, 2012 at 05:41:14PM -0700, Nitin Gupta wrote:
> >> Documentation of various struct page fields
> >> used by zsmalloc.
> >>
> >> Signed-off-by: Nitin Gupta <ngupta@vflare.org>
> >>
> >> Changes for v2:
> >> 	- Regroup descriptions as suggested by Seth
> >                                                ^^ - Konrad
> > 
> > Otherwise: Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > 
> 
> 
> Sorry about that, Konrad!
> Greg: Please let me know if I should resend the patch with corrected
> name in the changelog.

No need, I've fixed it up.

greg k-h

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-06-11 16:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-10  0:41 [PATCH v2] zsmalloc documentation Nitin Gupta
2012-06-10  0:44 ` Konrad Rzeszutek Wilk
2012-06-10  0:49   ` Nitin Gupta
2012-06-11 16:01     ` Greg KH
2012-06-11  2:25 ` Minchan Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).