From: Dan Streetman <ddstreet@ieee.org>
To: Vitaly Wool <vitalywool@gmail.com>
Cc: Linux-MM <linux-mm@kvack.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH/RESEND v2 1/5] z3fold: make pages_nr atomic
Date: Wed, 11 Jan 2017 11:09:42 -0500 [thread overview]
Message-ID: <CALZtONC8h1AgxpE7QiKeb1P59X5yXa5+QCTmpWKOQKFc5Y-WDA@mail.gmail.com> (raw)
In-Reply-To: <20170111160608.ca2048b68779129e4de70a1e@gmail.com>
On Wed, Jan 11, 2017 at 10:06 AM, Vitaly Wool <vitalywool@gmail.com> wrote:
> This patch converts pages_nr per-pool counter to atomic64_t.
>
> Signed-off-by: Vitaly Wool <vitalywool@gmail.com>
Acked-by: Dan Streetman <ddstreet@ieee.org>
> ---
> mm/z3fold.c | 20 +++++++++-----------
> 1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/mm/z3fold.c b/mm/z3fold.c
> index 207e5dd..2273789 100644
> --- a/mm/z3fold.c
> +++ b/mm/z3fold.c
> @@ -80,7 +80,7 @@ struct z3fold_pool {
> struct list_head unbuddied[NCHUNKS];
> struct list_head buddied;
> struct list_head lru;
> - u64 pages_nr;
> + atomic64_t pages_nr;
> const struct z3fold_ops *ops;
> struct zpool *zpool;
> const struct zpool_ops *zpool_ops;
> @@ -238,7 +238,7 @@ static struct z3fold_pool *z3fold_create_pool(gfp_t gfp,
> INIT_LIST_HEAD(&pool->unbuddied[i]);
> INIT_LIST_HEAD(&pool->buddied);
> INIT_LIST_HEAD(&pool->lru);
> - pool->pages_nr = 0;
> + atomic64_set(&pool->pages_nr, 0);
> pool->ops = ops;
> return pool;
> }
> @@ -350,7 +350,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,
> if (!page)
> return -ENOMEM;
> spin_lock(&pool->lock);
> - pool->pages_nr++;
> + atomic64_inc(&pool->pages_nr);
> zhdr = init_z3fold_page(page);
>
> if (bud == HEADLESS) {
> @@ -443,10 +443,9 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
> return;
> }
>
> - if (bud != HEADLESS) {
> - /* Remove from existing buddy list */
> + /* Remove from existing buddy list */
> + if (bud != HEADLESS)
> list_del(&zhdr->buddy);
> - }
>
> if (bud == HEADLESS ||
> (zhdr->first_chunks == 0 && zhdr->middle_chunks == 0 &&
> @@ -455,7 +454,7 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
> list_del(&page->lru);
> clear_bit(PAGE_HEADLESS, &page->private);
> free_z3fold_page(zhdr);
> - pool->pages_nr--;
> + atomic64_dec(&pool->pages_nr);
> } else {
> z3fold_compact_page(zhdr);
> /* Add to the unbuddied list */
> @@ -573,7 +572,7 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries)
> */
> clear_bit(PAGE_HEADLESS, &page->private);
> free_z3fold_page(zhdr);
> - pool->pages_nr--;
> + atomic64_dec(&pool->pages_nr);
> spin_unlock(&pool->lock);
> return 0;
> } else if (!test_bit(PAGE_HEADLESS, &page->private)) {
> @@ -676,12 +675,11 @@ static void z3fold_unmap(struct z3fold_pool *pool, unsigned long handle)
> * z3fold_get_pool_size() - gets the z3fold pool size in pages
> * @pool: pool whose size is being queried
> *
> - * Returns: size in pages of the given pool. The pool lock need not be
> - * taken to access pages_nr.
> + * Returns: size in pages of the given pool.
> */
> static u64 z3fold_get_pool_size(struct z3fold_pool *pool)
> {
> - return pool->pages_nr;
> + return atomic64_read(&pool->pages_nr);
> }
>
> /*****************
> --
> 2.4.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>
next prev parent reply other threads:[~2017-01-11 16:10 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-11 14:59 [PATCH/RESEND v2 0/5] z3fold optimizations and fixes Vitaly Wool
2017-01-11 15:06 ` [PATCH/RESEND v2 1/5] z3fold: make pages_nr atomic Vitaly Wool
2017-01-11 16:09 ` Dan Streetman [this message]
2017-01-11 15:06 ` [PATCH/RESEND v2 2/5] z3fold: fix header size related issues Vitaly Wool
2017-01-11 16:24 ` Dan Streetman
2017-01-11 15:06 ` [PATCH/RESEND v2 3/5] z3fold: extend compaction function Vitaly Wool
2017-01-11 16:28 ` Dan Streetman
2017-01-11 16:43 ` Vitaly Wool
2017-01-11 20:52 ` Vitaly Wool
2017-01-12 17:50 ` Dan Streetman
2017-01-11 15:06 ` [PATCH/RESEND v2 4/5] z3fold: use per-page spinlock Vitaly Wool
2017-01-11 16:42 ` Dan Streetman
2017-01-11 15:06 ` [PATCH/RESEND v2 5/5] z3fold: add kref refcounting Vitaly Wool
2017-01-11 17:08 ` Dan Streetman
2017-01-11 17:27 ` Vitaly Wool
2017-01-11 17:39 ` Dan Streetman
2017-01-11 17:51 ` Vitaly Wool
2017-01-11 18:03 ` Dan Streetman
2017-01-11 20:51 ` Vitaly Wool
2017-01-12 17:49 ` Dan Streetman
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=CALZtONC8h1AgxpE7QiKeb1P59X5yXa5+QCTmpWKOQKFc5Y-WDA@mail.gmail.com \
--to=ddstreet@ieee.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vitalywool@gmail.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