z3fold: make pages_nr atomic
Convert pages_nr per-pool counter to atomic64_t. Link: http://lkml.kernel.org/r/20170131213946.b828676ab17bbea42022c213@gmail.com Signed-off-by: Vitaly Wool <vitalywool@gmail.com> Reviewed-by: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
220ced1676
commit
12d59ae678
20
mm/z3fold.c
20
mm/z3fold.c
|
@ -80,7 +80,7 @@ struct z3fold_pool {
|
||||||
struct list_head unbuddied[NCHUNKS];
|
struct list_head unbuddied[NCHUNKS];
|
||||||
struct list_head buddied;
|
struct list_head buddied;
|
||||||
struct list_head lru;
|
struct list_head lru;
|
||||||
u64 pages_nr;
|
atomic64_t pages_nr;
|
||||||
const struct z3fold_ops *ops;
|
const struct z3fold_ops *ops;
|
||||||
struct zpool *zpool;
|
struct zpool *zpool;
|
||||||
const struct zpool_ops *zpool_ops;
|
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->unbuddied[i]);
|
||||||
INIT_LIST_HEAD(&pool->buddied);
|
INIT_LIST_HEAD(&pool->buddied);
|
||||||
INIT_LIST_HEAD(&pool->lru);
|
INIT_LIST_HEAD(&pool->lru);
|
||||||
pool->pages_nr = 0;
|
atomic64_set(&pool->pages_nr, 0);
|
||||||
pool->ops = ops;
|
pool->ops = ops;
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,
|
||||||
if (!page)
|
if (!page)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
spin_lock(&pool->lock);
|
spin_lock(&pool->lock);
|
||||||
pool->pages_nr++;
|
atomic64_inc(&pool->pages_nr);
|
||||||
zhdr = init_z3fold_page(page);
|
zhdr = init_z3fold_page(page);
|
||||||
|
|
||||||
if (bud == HEADLESS) {
|
if (bud == HEADLESS) {
|
||||||
|
@ -443,10 +443,9 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bud != HEADLESS) {
|
/* Remove from existing buddy list */
|
||||||
/* Remove from existing buddy list */
|
if (bud != HEADLESS)
|
||||||
list_del(&zhdr->buddy);
|
list_del(&zhdr->buddy);
|
||||||
}
|
|
||||||
|
|
||||||
if (bud == HEADLESS ||
|
if (bud == HEADLESS ||
|
||||||
(zhdr->first_chunks == 0 && zhdr->middle_chunks == 0 &&
|
(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);
|
list_del(&page->lru);
|
||||||
clear_bit(PAGE_HEADLESS, &page->private);
|
clear_bit(PAGE_HEADLESS, &page->private);
|
||||||
free_z3fold_page(zhdr);
|
free_z3fold_page(zhdr);
|
||||||
pool->pages_nr--;
|
atomic64_dec(&pool->pages_nr);
|
||||||
} else {
|
} else {
|
||||||
z3fold_compact_page(zhdr);
|
z3fold_compact_page(zhdr);
|
||||||
/* Add to the unbuddied list */
|
/* Add to the unbuddied list */
|
||||||
|
@ -573,7 +572,7 @@ next:
|
||||||
*/
|
*/
|
||||||
clear_bit(PAGE_HEADLESS, &page->private);
|
clear_bit(PAGE_HEADLESS, &page->private);
|
||||||
free_z3fold_page(zhdr);
|
free_z3fold_page(zhdr);
|
||||||
pool->pages_nr--;
|
atomic64_dec(&pool->pages_nr);
|
||||||
spin_unlock(&pool->lock);
|
spin_unlock(&pool->lock);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!test_bit(PAGE_HEADLESS, &page->private)) {
|
} 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
|
* z3fold_get_pool_size() - gets the z3fold pool size in pages
|
||||||
* @pool: pool whose size is being queried
|
* @pool: pool whose size is being queried
|
||||||
*
|
*
|
||||||
* Returns: size in pages of the given pool. The pool lock need not be
|
* Returns: size in pages of the given pool.
|
||||||
* taken to access pages_nr.
|
|
||||||
*/
|
*/
|
||||||
static u64 z3fold_get_pool_size(struct z3fold_pool *pool)
|
static u64 z3fold_get_pool_size(struct z3fold_pool *pool)
|
||||||
{
|
{
|
||||||
return pool->pages_nr;
|
return atomic64_read(&pool->pages_nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************
|
/*****************
|
||||||
|
|
Loading…
Reference in New Issue