aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/zram/zram_drv.c
diff options
context:
space:
mode:
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>2014-04-07 18:38:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-07 19:35:59 -0400
commit90a7806ea9b9f7cb4751859cc2506e2d80e36ef1 (patch)
tree412738a9c0df4c46c2346e9365456e357be900bd /drivers/block/zram/zram_drv.c
parentb7cccf8b4009bf74df61f3c9d86b95fabd807c11 (diff)
zram: use atomic64_t for all zram stats
This is a preparation patch for stats code duplication removal. 1) use atomic64_t for `pages_zero' and `pages_stored' zram stats. 2) `compr_size' and `pages_zero' struct zram_stats members did not follow the existing device attr naming scheme: zram_stats.ATTR has ATTR_show() function. rename them: -- compr_size -> compr_data_size -- pages_zero -> zero_pages Minchan Kim's note: If we really have trouble with atomic stat operation, we could change it with percpu_counter so that it could solve atomic overhead and unnecessary memory space by introducing unsigned long instead of 64bit atomic_t. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Acked-by: Minchan Kim <minchan@kernel.org> Acked-by: Jerome Marchand <jmarchan@redhat.com> Cc: Nitin Gupta <ngupta@vflare.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/zram/zram_drv.c')
-rw-r--r--drivers/block/zram/zram_drv.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 995304ef40bb..1bf97b2f8f3f 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -109,7 +109,7 @@ static ssize_t zero_pages_show(struct device *dev,
109{ 109{
110 struct zram *zram = dev_to_zram(dev); 110 struct zram *zram = dev_to_zram(dev);
111 111
112 return sprintf(buf, "%u\n", atomic_read(&zram->stats.pages_zero)); 112 return sprintf(buf, "%llu\n", (u64)atomic64_read(&zram->stats.zero_pages));
113} 113}
114 114
115static ssize_t orig_data_size_show(struct device *dev, 115static ssize_t orig_data_size_show(struct device *dev,
@@ -118,7 +118,7 @@ static ssize_t orig_data_size_show(struct device *dev,
118 struct zram *zram = dev_to_zram(dev); 118 struct zram *zram = dev_to_zram(dev);
119 119
120 return sprintf(buf, "%llu\n", 120 return sprintf(buf, "%llu\n",
121 (u64)(atomic_read(&zram->stats.pages_stored)) << PAGE_SHIFT); 121 (u64)(atomic64_read(&zram->stats.pages_stored)) << PAGE_SHIFT);
122} 122}
123 123
124static ssize_t compr_data_size_show(struct device *dev, 124static ssize_t compr_data_size_show(struct device *dev,
@@ -127,7 +127,7 @@ static ssize_t compr_data_size_show(struct device *dev,
127 struct zram *zram = dev_to_zram(dev); 127 struct zram *zram = dev_to_zram(dev);
128 128
129 return sprintf(buf, "%llu\n", 129 return sprintf(buf, "%llu\n",
130 (u64)atomic64_read(&zram->stats.compr_size)); 130 (u64)atomic64_read(&zram->stats.compr_data_size));
131} 131}
132 132
133static ssize_t mem_used_total_show(struct device *dev, 133static ssize_t mem_used_total_show(struct device *dev,
@@ -301,15 +301,15 @@ static void zram_free_page(struct zram *zram, size_t index)
301 */ 301 */
302 if (zram_test_flag(meta, index, ZRAM_ZERO)) { 302 if (zram_test_flag(meta, index, ZRAM_ZERO)) {
303 zram_clear_flag(meta, index, ZRAM_ZERO); 303 zram_clear_flag(meta, index, ZRAM_ZERO);
304 atomic_dec(&zram->stats.pages_zero); 304 atomic64_dec(&zram->stats.zero_pages);
305 } 305 }
306 return; 306 return;
307 } 307 }
308 308
309 zs_free(meta->mem_pool, handle); 309 zs_free(meta->mem_pool, handle);
310 310
311 atomic64_sub(meta->table[index].size, &zram->stats.compr_size); 311 atomic64_sub(meta->table[index].size, &zram->stats.compr_data_size);
312 atomic_dec(&zram->stats.pages_stored); 312 atomic64_dec(&zram->stats.pages_stored);
313 313
314 meta->table[index].handle = 0; 314 meta->table[index].handle = 0;
315 meta->table[index].size = 0; 315 meta->table[index].size = 0;
@@ -452,7 +452,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
452 zram_set_flag(meta, index, ZRAM_ZERO); 452 zram_set_flag(meta, index, ZRAM_ZERO);
453 write_unlock(&zram->meta->tb_lock); 453 write_unlock(&zram->meta->tb_lock);
454 454
455 atomic_inc(&zram->stats.pages_zero); 455 atomic64_inc(&zram->stats.zero_pages);
456 ret = 0; 456 ret = 0;
457 goto out; 457 goto out;
458 } 458 }
@@ -508,8 +508,8 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
508 write_unlock(&zram->meta->tb_lock); 508 write_unlock(&zram->meta->tb_lock);
509 509
510 /* Update stats */ 510 /* Update stats */
511 atomic64_add(clen, &zram->stats.compr_size); 511 atomic64_add(clen, &zram->stats.compr_data_size);
512 atomic_inc(&zram->stats.pages_stored); 512 atomic64_inc(&zram->stats.pages_stored);
513out: 513out:
514 if (locked) 514 if (locked)
515 mutex_unlock(&meta->buffer_lock); 515 mutex_unlock(&meta->buffer_lock);