linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nitin Gupta <ngupta@vflare.org>
To: Konrad Rzeszutek Wilk <konrad@darnok.org>
Cc: Greg KH <greg@kroah.com>,
	Dan Magenheimer <dan.magenheimer@oracle.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Seth Jennings <sjenning@linux.vnet.ibm.com>,
	Minchan Kim <minchan.kim@gmail.com>,
	linux-mm <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] zsmalloc documentation
Date: Sat, 09 Jun 2012 17:04:15 -0700	[thread overview]
Message-ID: <4FD3E47F.4070903@vflare.org> (raw)
In-Reply-To: <20120609112934.GE16034@localhost.localdomain>

On 06/09/2012 04:29 AM, Konrad Rzeszutek Wilk wrote:

> On Sun, Jun 03, 2012 at 01:20:05PM -0700, Nitin Gupta wrote:
>> Signed-off-by: Nitin Gupta <ngupta@vflare.org>
>> ---
>>  drivers/staging/zsmalloc/zsmalloc-main.c |   49 ++++++++++++++++++++++++++++++
>>  1 file changed, 49 insertions(+)
>>
>> diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
>> index 4496737..f80f2fd 100644
>> --- a/drivers/staging/zsmalloc/zsmalloc-main.c
>> +++ b/drivers/staging/zsmalloc/zsmalloc-main.c
>> @@ -10,6 +10,55 @@
>>   * 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:
> 
> I took your definition and grouped them a bit differently:
> Not sure if it is more easier to read?
> 
> 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


This regrouping indeed looks cleaner. I will send the revised patch soon.

Thanks,
Nitin

--
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>

      reply	other threads:[~2012-06-10  0:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-03 20:20 Nitin Gupta
2012-06-09 11:29 ` Konrad Rzeszutek Wilk
2012-06-10  0:04   ` Nitin Gupta [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FD3E47F.4070903@vflare.org \
    --to=ngupta@vflare.org \
    --cc=dan.magenheimer@oracle.com \
    --cc=greg@kroah.com \
    --cc=konrad.wilk@oracle.com \
    --cc=konrad@darnok.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan.kim@gmail.com \
    --cc=sjenning@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox