summaryrefslogtreecommitdiffstats
path: root/mm/z3fold.c
diff options
context:
space:
mode:
authorVitaly Wool <vitalywool@gmail.com>2017-02-24 17:57:15 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-24 20:46:54 -0500
commit12d59ae678242b383671abb7ffa3c94bb2d6c4de (patch)
tree10fefbc7ddf553a1399ef0fad0afd59bda0bc7d3 /mm/z3fold.c
parent220ced1676c490c3192dd9bc1a06be86dee88a56 (diff)
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>
Diffstat (limited to 'mm/z3fold.c')
-rw-r--r--mm/z3fold.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/mm/z3fold.c b/mm/z3fold.c
index 207e5ddc87a2..227378991ecf 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -80,7 +80,7 @@ struct z3fold_pool {
80 struct list_head unbuddied[NCHUNKS]; 80 struct list_head unbuddied[NCHUNKS];
81 struct list_head buddied; 81 struct list_head buddied;
82 struct list_head lru; 82 struct list_head lru;
83 u64 pages_nr; 83 atomic64_t pages_nr;
84 const struct z3fold_ops *ops; 84 const struct z3fold_ops *ops;
85 struct zpool *zpool; 85 struct zpool *zpool;
86 const struct zpool_ops *zpool_ops; 86 const struct zpool_ops *zpool_ops;
@@ -238,7 +238,7 @@ static struct z3fold_pool *z3fold_create_pool(gfp_t gfp,
238 INIT_LIST_HEAD(&pool->unbuddied[i]); 238 INIT_LIST_HEAD(&pool->unbuddied[i]);
239 INIT_LIST_HEAD(&pool->buddied); 239 INIT_LIST_HEAD(&pool->buddied);
240 INIT_LIST_HEAD(&pool->lru); 240 INIT_LIST_HEAD(&pool->lru);
241 pool->pages_nr = 0; 241 atomic64_set(&pool->pages_nr, 0);
242 pool->ops = ops; 242 pool->ops = ops;
243 return pool; 243 return pool;
244} 244}
@@ -350,7 +350,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp,
350 if (!page) 350 if (!page)
351 return -ENOMEM; 351 return -ENOMEM;
352 spin_lock(&pool->lock); 352 spin_lock(&pool->lock);
353 pool->pages_nr++; 353 atomic64_inc(&pool->pages_nr);
354 zhdr = init_z3fold_page(page); 354 zhdr = init_z3fold_page(page);
355 355
356 if (bud == HEADLESS) { 356 if (bud == HEADLESS) {
@@ -443,10 +443,9 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
443 return; 443 return;
444 } 444 }
445 445
446 if (bud != HEADLESS) { 446 /* Remove from existing buddy list */
447 /* Remove from existing buddy list */ 447 if (bud != HEADLESS)
448 list_del(&zhdr->buddy); 448 list_del(&zhdr->buddy);
449 }
450 449
451 if (bud == HEADLESS || 450 if (bud == HEADLESS ||
452 (zhdr->first_chunks == 0 && zhdr->middle_chunks == 0 && 451 (zhdr->first_chunks == 0 && zhdr->middle_chunks == 0 &&
@@ -455,7 +454,7 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
455 list_del(&page->lru); 454 list_del(&page->lru);
456 clear_bit(PAGE_HEADLESS, &page->private); 455 clear_bit(PAGE_HEADLESS, &page->private);
457 free_z3fold_page(zhdr); 456 free_z3fold_page(zhdr);
458 pool->pages_nr--; 457 atomic64_dec(&pool->pages_nr);
459 } else { 458 } else {
460 z3fold_compact_page(zhdr); 459 z3fold_compact_page(zhdr);
461 /* Add to the unbuddied list */ 460 /* Add to the unbuddied list */
@@ -573,7 +572,7 @@ next:
573 */ 572 */
574 clear_bit(PAGE_HEADLESS, &page->private); 573 clear_bit(PAGE_HEADLESS, &page->private);
575 free_z3fold_page(zhdr); 574 free_z3fold_page(zhdr);
576 pool->pages_nr--; 575 atomic64_dec(&pool->pages_nr);
577 spin_unlock(&pool->lock); 576 spin_unlock(&pool->lock);
578 return 0; 577 return 0;
579 } else if (!test_bit(PAGE_HEADLESS, &page->private)) { 578 } else if (!test_bit(PAGE_HEADLESS, &page->private)) {
@@ -676,12 +675,11 @@ static void z3fold_unmap(struct z3fold_pool *pool, unsigned long handle)
676 * z3fold_get_pool_size() - gets the z3fold pool size in pages 675 * z3fold_get_pool_size() - gets the z3fold pool size in pages
677 * @pool: pool whose size is being queried 676 * @pool: pool whose size is being queried
678 * 677 *
679 * Returns: size in pages of the given pool. The pool lock need not be 678 * Returns: size in pages of the given pool.
680 * taken to access pages_nr.
681 */ 679 */
682static u64 z3fold_get_pool_size(struct z3fold_pool *pool) 680static u64 z3fold_get_pool_size(struct z3fold_pool *pool)
683{ 681{
684 return pool->pages_nr; 682 return atomic64_read(&pool->pages_nr);
685} 683}
686 684
687/***************** 685/*****************