From: Seth Jennings <sjenning@linux.vnet.ibm.com>
To: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Bob Liu <bob.liu@oracle.com>, Mel Gorman <mgorman@suse.de>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Tomasz Stanislawski <t.stanislaws@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Dave Hansen <dave.hansen@intel.com>,
Minchan Kim <minchan@kernel.org>
Subject: Re: [PATCH v3 1/6] zbud: use page ref counter for zbud pages
Date: Tue, 8 Oct 2013 15:43:17 -0500 [thread overview]
Message-ID: <20131008204317.GA8798@medulla.variantweb.net> (raw)
In-Reply-To: <1381238980-2491-2-git-send-email-k.kozlowski@samsung.com>
On Tue, Oct 08, 2013 at 03:29:35PM +0200, Krzysztof Kozlowski wrote:
> Use page reference counter for zbud pages. The ref counter replaces
> zbud_header.under_reclaim flag and ensures that zbud page won't be freed
> when zbud_free() is called during reclaim. It allows implementation of
> additional reclaim paths.
>
> The page count is incremented when:
> - a handle is created and passed to zswap (in zbud_alloc()),
> - user-supplied eviction callback is called (in zbud_reclaim_page()).
>
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
> Reviewed-by: Bob Liu <bob.liu@oracle.com>
Other than the nit below:
Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
> ---
> mm/zbud.c | 117 +++++++++++++++++++++++++++++++++----------------------------
> 1 file changed, 64 insertions(+), 53 deletions(-)
>
> diff --git a/mm/zbud.c b/mm/zbud.c
> index 9451361..7574289 100644
> --- a/mm/zbud.c
> +++ b/mm/zbud.c
> @@ -109,7 +109,6 @@ struct zbud_header {
> struct list_head lru;
> unsigned int first_chunks;
> unsigned int last_chunks;
> - bool under_reclaim;
> };
>
> /*****************
> @@ -138,16 +137,9 @@ static struct zbud_header *init_zbud_page(struct page *page)
> zhdr->last_chunks = 0;
> INIT_LIST_HEAD(&zhdr->buddy);
> INIT_LIST_HEAD(&zhdr->lru);
> - zhdr->under_reclaim = 0;
> return zhdr;
> }
>
> -/* Resets the struct page fields and frees the page */
> -static void free_zbud_page(struct zbud_header *zhdr)
> -{
> - __free_page(virt_to_page(zhdr));
> -}
> -
> /*
> * Encodes the handle of a particular buddy within a zbud page
> * Pool lock should be held as this function accesses first|last_chunks
> @@ -188,6 +180,31 @@ static int num_free_chunks(struct zbud_header *zhdr)
> return NCHUNKS - zhdr->first_chunks - zhdr->last_chunks - 1;
> }
>
> +/*
> + * Increases ref count for zbud page.
> + */
> +static void get_zbud_page(struct zbud_header *zhdr)
> +{
> + get_page(virt_to_page(zhdr));
> +}
> +
> +/*
> + * Decreases ref count for zbud page and frees the page if it reaches 0
> + * (no external references, e.g. handles).
> + *
> + * Returns 1 if page was freed and 0 otherwise.
> + */
> +static int put_zbud_page(struct zbud_header *zhdr)
> +{
> + struct page *page = virt_to_page(zhdr);
> + if (put_page_testzero(page)) {
> + free_hot_cold_page(page, 0);
> + return 1;
> + }
> + return 0;
> +}
> +
> +
> /*****************
> * API Functions
> *****************/
> @@ -273,6 +290,7 @@ int zbud_alloc(struct zbud_pool *pool, int size, gfp_t gfp,
> bud = FIRST;
> else
> bud = LAST;
> + get_zbud_page(zhdr);
> goto found;
> }
> }
> @@ -284,6 +302,10 @@ int zbud_alloc(struct zbud_pool *pool, int size, gfp_t gfp,
> return -ENOMEM;
> spin_lock(&pool->lock);
> pool->pages_nr++;
> + /*
> + * We will be using zhdr instead of page, so
> + * don't increase the page count.
> + */
This comment isn't very clear. I think what you mean to say is that
we already have the page ref'ed for this entry because of the initial
ref count done by alloc_page().
So maybe:
/*
* Page count is incremented by alloc_page() for the initial
* reference so no need to call zbud_get_page() here.
*/
Thanks,
Seth
--
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>
next prev parent reply other threads:[~2013-10-08 20:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-08 13:29 [PATCH v3 0/6] mm: migrate " Krzysztof Kozlowski
2013-10-08 13:29 ` [PATCH v3 1/6] zbud: use page ref counter for " Krzysztof Kozlowski
2013-10-08 20:43 ` Seth Jennings [this message]
2013-10-09 7:08 ` Krzysztof Kozlowski
2013-10-08 13:29 ` [PATCH v3 2/6] zbud: make freechunks a block local variable Krzysztof Kozlowski
2013-10-08 20:46 ` Seth Jennings
2013-10-08 13:29 ` [PATCH v3 3/6] mm: use mapcount for identifying zbud pages Krzysztof Kozlowski
2013-10-08 13:29 ` [PATCH v3 4/6] zbud: memset zbud_header to 0 during init Krzysztof Kozlowski
2013-10-08 20:48 ` Seth Jennings
2013-10-08 13:29 ` [PATCH v3 5/6] zswap: replace tree in zswap with radix tree in zbud Krzysztof Kozlowski
2013-10-09 15:30 ` Seth Jennings
2013-10-09 17:16 ` Seth Jennings
2013-10-10 7:01 ` Krzysztof Kozlowski
2013-10-08 13:29 ` [PATCH v3 6/6] mm: migrate zbud pages Krzysztof Kozlowski
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=20131008204317.GA8798@medulla.variantweb.net \
--to=sjenning@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=b.zolnierkie@samsung.com \
--cc=bob.liu@oracle.com \
--cc=dave.hansen@intel.com \
--cc=k.kozlowski@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=m.szyprowski@samsung.com \
--cc=mgorman@suse.de \
--cc=minchan@kernel.org \
--cc=t.stanislaws@samsung.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