linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Seth Jennings <sjennings@variantweb.net>
To: Dan Streetman <ddstreet@ieee.org>
Cc: Minchan Kim <minchan@kernel.org>,
	Weijie Yang <weijie.yang@samsung.com>,
	Nitin Gupta <ngupta@vflare.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Bob Liu <bob.liu@oracle.com>, Hugh Dickins <hughd@google.com>,
	Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Linux-MM <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCHv2 1/4] mm/zbud: zbud_alloc() minor param change
Date: Thu, 8 May 2014 22:33:04 -0500	[thread overview]
Message-ID: <20140509033304.GA2274@cerebellum.variantweb.net> (raw)
In-Reply-To: <1399499496-3216-2-git-send-email-ddstreet@ieee.org>

On Wed, May 07, 2014 at 05:51:33PM -0400, Dan Streetman wrote:
> Change zbud to store gfp_t flags passed at pool creation to use for
> each alloc; this allows the api to be closer to the existing zsmalloc
> interface, and the only current zbud user (zswap) uses the same gfp
> flags for all allocs.  Update zswap to use changed interface.
> 

Acked-by: Seth Jennings <sjennings@variantweb.net>

> Signed-off-by: Dan Streetman <ddstreet@ieee.org>
> Cc: Seth Jennings <sjennings@variantweb.net>
> Cc: Weijie Yang <weijie.yang@samsung.com>
> ---
> 
> Changes since v1 https://lkml.org/lkml/2014/4/19/98
>  -context changes only; zbud_alloc parameter type changed since
>   last patch
> 
>  include/linux/zbud.h |  2 +-
>  mm/zbud.c            | 27 +++++++++++++++------------
>  mm/zswap.c           |  6 +++---
>  3 files changed, 19 insertions(+), 16 deletions(-)
> 
> diff --git a/include/linux/zbud.h b/include/linux/zbud.h
> index 13af0d4..0b2534e 100644
> --- a/include/linux/zbud.h
> +++ b/include/linux/zbud.h
> @@ -11,7 +11,7 @@ struct zbud_ops {
>  
>  struct zbud_pool *zbud_create_pool(gfp_t gfp, struct zbud_ops *ops);
>  void zbud_destroy_pool(struct zbud_pool *pool);
> -int zbud_alloc(struct zbud_pool *pool, unsigned int size, gfp_t gfp,
> +int zbud_alloc(struct zbud_pool *pool, unsigned int size,
>  	unsigned long *handle);
>  void zbud_free(struct zbud_pool *pool, unsigned long handle);
>  int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries);
> diff --git a/mm/zbud.c b/mm/zbud.c
> index 01df13a..847c01c 100644
> --- a/mm/zbud.c
> +++ b/mm/zbud.c
> @@ -94,6 +94,7 @@ struct zbud_pool {
>  	struct list_head lru;
>  	u64 pages_nr;
>  	struct zbud_ops *ops;
> +	gfp_t gfp;
>  };
>  
>  /*
> @@ -193,9 +194,12 @@ static int num_free_chunks(struct zbud_header *zhdr)
>  *****************/
>  /**
>   * zbud_create_pool() - create a new zbud pool
> - * @gfp:	gfp flags when allocating the zbud pool structure
> + * @gfp:	gfp flags when growing the pool
>   * @ops:	user-defined operations for the zbud pool
>   *
> + * gfp should not set __GFP_HIGHMEM as highmem pages cannot be used
> + * as zbud pool pages.
> + *
>   * Return: pointer to the new zbud pool or NULL if the metadata allocation
>   * failed.
>   */
> @@ -204,7 +208,9 @@ struct zbud_pool *zbud_create_pool(gfp_t gfp, struct zbud_ops *ops)
>  	struct zbud_pool *pool;
>  	int i;
>  
> -	pool = kmalloc(sizeof(struct zbud_pool), gfp);
> +	if (gfp & __GFP_HIGHMEM)
> +		return NULL;
> +	pool = kmalloc(sizeof(struct zbud_pool), GFP_KERNEL);
>  	if (!pool)
>  		return NULL;
>  	spin_lock_init(&pool->lock);
> @@ -214,6 +220,7 @@ struct zbud_pool *zbud_create_pool(gfp_t gfp, struct zbud_ops *ops)
>  	INIT_LIST_HEAD(&pool->lru);
>  	pool->pages_nr = 0;
>  	pool->ops = ops;
> +	pool->gfp = gfp;
>  	return pool;
>  }
>  
> @@ -232,7 +239,6 @@ void zbud_destroy_pool(struct zbud_pool *pool)
>   * zbud_alloc() - allocates a region of a given size
>   * @pool:	zbud pool from which to allocate
>   * @size:	size in bytes of the desired allocation
> - * @gfp:	gfp flags used if the pool needs to grow
>   * @handle:	handle of the new allocation
>   *
>   * This function will attempt to find a free region in the pool large enough to
> @@ -240,14 +246,11 @@ void zbud_destroy_pool(struct zbud_pool *pool)
>   * performed first. If no suitable free region is found, then a new page is
>   * allocated and added to the pool to satisfy the request.
>   *
> - * gfp should not set __GFP_HIGHMEM as highmem pages cannot be used
> - * as zbud pool pages.
> - *
> - * Return: 0 if success and handle is set, otherwise -EINVAL if the size or
> - * gfp arguments are invalid or -ENOMEM if the pool was unable to allocate
> - * a new page.
> + * Return: 0 if success and @handle is set, -ENOSPC if the @size is too large,
> + * -EINVAL if the @size is 0, or -ENOMEM if the pool was unable to
> + * allocate a new page.
>   */
> -int zbud_alloc(struct zbud_pool *pool, unsigned int size, gfp_t gfp,
> +int zbud_alloc(struct zbud_pool *pool, unsigned int size,
>  			unsigned long *handle)
>  {
>  	int chunks, i, freechunks;
> @@ -255,7 +258,7 @@ int zbud_alloc(struct zbud_pool *pool, unsigned int size, gfp_t gfp,
>  	enum buddy bud;
>  	struct page *page;
>  
> -	if (!size || (gfp & __GFP_HIGHMEM))
> +	if (!size)
>  		return -EINVAL;
>  	if (size > PAGE_SIZE - ZHDR_SIZE_ALIGNED - CHUNK_SIZE)
>  		return -ENOSPC;
> @@ -279,7 +282,7 @@ int zbud_alloc(struct zbud_pool *pool, unsigned int size, gfp_t gfp,
>  
>  	/* Couldn't find unbuddied zbud page, create new one */
>  	spin_unlock(&pool->lock);
> -	page = alloc_page(gfp);
> +	page = alloc_page(pool->gfp);
>  	if (!page)
>  		return -ENOMEM;
>  	spin_lock(&pool->lock);
> diff --git a/mm/zswap.c b/mm/zswap.c
> index aeaef0f..1cc6770 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -679,8 +679,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
>  
>  	/* store */
>  	len = dlen + sizeof(struct zswap_header);
> -	ret = zbud_alloc(zswap_pool, len, __GFP_NORETRY | __GFP_NOWARN,
> -		&handle);
> +	ret = zbud_alloc(zswap_pool, len, &handle);
>  	if (ret == -ENOSPC) {
>  		zswap_reject_compress_poor++;
>  		goto freepage;
> @@ -900,7 +899,8 @@ static int __init init_zswap(void)
>  
>  	pr_info("loading zswap\n");
>  
> -	zswap_pool = zbud_create_pool(GFP_KERNEL, &zswap_zbud_ops);
> +	zswap_pool = zbud_create_pool(__GFP_NORETRY | __GFP_NOWARN,
> +			&zswap_zbud_ops);
>  	if (!zswap_pool) {
>  		pr_err("zbud pool creation failed\n");
>  		goto error;
> -- 
> 1.8.3.1
> 
> --
> 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>

  reply	other threads:[~2014-05-09  3:33 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-19 15:52 [PATCH 0/4] mm: zpool: add common api for zswap to use zbud/zsmalloc Dan Streetman
2014-04-19 15:52 ` [PATCH 1/4] mm: zpool: zbud_alloc() minor param change Dan Streetman
2014-04-19 15:52 ` [PATCH 2/4] mm: zpool: implement zsmalloc shrinking Dan Streetman
2014-04-26  8:37   ` Weijie Yang
2014-04-27  4:13     ` Dan Streetman
2014-05-02 20:01     ` Seth Jennings
2014-05-04 20:38       ` Dan Streetman
2014-04-19 15:52 ` [PATCH 3/4] mm: zpool: implement common zpool api to zbud/zsmalloc Dan Streetman
2014-04-22 10:05   ` Sergey Senozhatsky
2014-04-22 13:43     ` Dan Streetman
2014-04-19 15:52 ` [PATCH 4/4] mm: zpool: update zswap to use zpool Dan Streetman
2014-04-21  2:47 ` [PATCH 0/4] mm: zpool: add common api for zswap to use zbud/zsmalloc Weijie Yang
2014-05-07 21:51 ` [PATCHv2 0/4] mm/zpool: " Dan Streetman
2014-05-07 21:51   ` [PATCHv2 1/4] mm/zbud: zbud_alloc() minor param change Dan Streetman
2014-05-09  3:33     ` Seth Jennings [this message]
2014-05-07 21:51   ` [PATCH 2/4] mm/zbud: change zbud_alloc size type to size_t Dan Streetman
2014-05-09  3:33     ` Seth Jennings
2014-05-07 21:51   ` [PATCHv2 3/4] mm/zpool: implement common zpool api to zbud/zsmalloc Dan Streetman
2014-05-09  4:13     ` Seth Jennings
2014-05-10 16:06       ` Dan Streetman
2014-05-07 21:51   ` [PATCHv2 4/4] mm/zswap: update zswap to use zpool Dan Streetman
2014-05-24 19:06   ` [PATCHv3 0/6] mm/zpool: add common api for zswap to use zbud/zsmalloc Dan Streetman
2014-05-24 19:06     ` [PATCHv2 1/6] mm/zbud: zbud_alloc() minor param change Dan Streetman
2014-05-24 19:06     ` [PATCH 2/6] mm/zbud: change zbud_alloc size type to size_t Dan Streetman
2014-05-24 19:06     ` [PATCHv3 3/6] mm/zpool: implement common zpool api to zbud/zsmalloc Dan Streetman
2014-05-27 22:06       ` Seth Jennings
2014-05-27 22:48         ` Seth Jennings
2014-05-28  0:06         ` Dan Streetman
2014-05-29  3:48           ` Seth Jennings
2014-05-24 19:06     ` [PATCH 4/6] mm/zpool: zbud/zsmalloc implement zpool Dan Streetman
2014-05-24 19:06     ` [PATCHv3 5/6] mm/zpool: update zswap to use zpool Dan Streetman
2014-05-24 19:06     ` [PATCH 6/6] mm/zpool: prevent zbud/zsmalloc from unloading when used Dan Streetman
2014-05-27 22:40       ` Seth Jennings
2014-05-28  0:40         ` Dan Streetman
2014-05-27 22:44     ` [PATCHv3 0/6] mm/zpool: add common api for zswap to use zbud/zsmalloc Seth Jennings
2014-06-02 22:19     ` [PATCHv4 " Dan Streetman
2014-06-02 22:19       ` [PATCHv2 1/6] mm/zbud: zbud_alloc() minor param change Dan Streetman
2014-06-23 21:19         ` Andrew Morton
2014-06-24 15:24           ` Dan Streetman
2014-06-02 22:19       ` [PATCH 2/6] mm/zbud: change zbud_alloc size type to size_t Dan Streetman
2014-06-02 22:19       ` [PATCHv4 3/6] mm/zpool: implement common zpool api to zbud/zsmalloc Dan Streetman
2014-06-23 21:46         ` Andrew Morton
2014-06-24 15:39           ` Dan Streetman
2014-06-24 23:08             ` Andrew Morton
2014-06-27 17:11               ` Dan Streetman
2014-06-27 19:17                 ` Andrew Morton
2014-06-02 22:19       ` [PATCHv2 4/6] mm/zpool: zbud/zsmalloc implement zpool Dan Streetman
2014-06-02 22:19       ` [PATCHv4 5/6] mm/zpool: update zswap to use zpool Dan Streetman
2014-06-02 22:19       ` [PATCHv2 6/6] mm/zpool: prevent zbud/zsmalloc from unloading when used Dan Streetman
2014-06-23 21:48         ` Andrew Morton
2014-06-24 15:41           ` Dan Streetman
2014-06-04  1:38       ` [PATCHv4 0/6] mm/zpool: add common api for zswap to use zbud/zsmalloc Bob Liu
2014-06-06 21:01       ` Seth Jennings
2014-07-02 21:43       ` [PATCHv5 0/4] " Dan Streetman
2014-07-02 21:45       ` Dan Streetman
2014-07-02 21:45         ` [PATCHv2 1/4] mm/zbud: change zbud_alloc size type to size_t Dan Streetman
2014-07-02 21:45         ` [PATCHv5 2/4] mm/zpool: implement common zpool api to zbud/zsmalloc Dan Streetman
2014-07-02 21:45         ` [PATCHv3 3/4] mm/zpool: zbud/zsmalloc implement zpool Dan Streetman
2014-07-02 21:45         ` [PATCHv5 4/4] mm/zpool: update zswap to use zpool Dan Streetman
2014-07-14 18:10         ` [PATCHv5 0/4] mm/zpool: add common api for zswap to use zbud/zsmalloc Dan Streetman
2014-07-16 20:59           ` Seth Jennings
2014-07-16 21:05             ` Dan Streetman
2014-07-16 22:00               ` Seth Jennings
2014-07-25 16:59                 ` Dan Streetman
2014-07-28 20:40                   ` Seth Jennings

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=20140509033304.GA2274@cerebellum.variantweb.net \
    --to=sjennings@variantweb.net \
    --cc=akpm@linux-foundation.org \
    --cc=bob.liu@oracle.com \
    --cc=ddstreet@ieee.org \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=riel@redhat.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=weijie.yang@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