pages_compacted  the number of pages freed during compaction
  huge_pages      the number of incompressible pages
 
+File /sys/block/zram<id>/bd_stat
+
+The stat file represents device's backing device statistics. It consists of
+a single line of text and contains the following stats separated by whitespace:
+ bd_count      size of data written in backing device.
+               Unit: 4K bytes
+ bd_reads      the number of reads from backing device
+               Unit: 4K bytes
+ bd_writes     the number of writes to backing device
+               Unit: 4K bytes
+
 9) Deactivate:
        swapoff /dev/zram0
        umount /dev/zram1
 
        if (test_and_set_bit(blk_idx, zram->bitmap))
                goto retry;
 
+       atomic64_inc(&zram->stats.bd_count);
        return blk_idx;
 }
 
 
        was_set = test_and_clear_bit(blk_idx, zram->bitmap);
        WARN_ON_ONCE(!was_set);
+       atomic64_dec(&zram->stats.bd_count);
 }
 
 static void zram_page_end_io(struct bio *bio)
                        continue;
                }
 
+               atomic64_inc(&zram->stats.bd_writes);
                /*
                 * We released zram_slot_lock so need to check if the slot was
                 * changed. If there is freeing for the slot, we can catch it
 static int read_from_bdev(struct zram *zram, struct bio_vec *bvec,
                        unsigned long entry, struct bio *parent, bool sync)
 {
+       atomic64_inc(&zram->stats.bd_reads);
        if (sync)
                return read_from_bdev_sync(zram, bvec, entry, parent);
        else
        return ret;
 }
 
+#ifdef CONFIG_ZRAM_WRITEBACK
+static ssize_t bd_stat_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct zram *zram = dev_to_zram(dev);
+       ssize_t ret;
+
+       down_read(&zram->init_lock);
+       ret = scnprintf(buf, PAGE_SIZE,
+               "%8llu %8llu %8llu\n",
+               (u64)atomic64_read(&zram->stats.bd_count) * (PAGE_SHIFT - 12),
+               (u64)atomic64_read(&zram->stats.bd_reads) * (PAGE_SHIFT - 12),
+               (u64)atomic64_read(&zram->stats.bd_writes) * (PAGE_SHIFT - 12));
+       up_read(&zram->init_lock);
+
+       return ret;
+}
+#endif
+
 static ssize_t debug_stat_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
 
 static DEVICE_ATTR_RO(io_stat);
 static DEVICE_ATTR_RO(mm_stat);
+#ifdef CONFIG_ZRAM_WRITEBACK
+static DEVICE_ATTR_RO(bd_stat);
+#endif
 static DEVICE_ATTR_RO(debug_stat);
 
 static void zram_meta_free(struct zram *zram, u64 disksize)
 #endif
        &dev_attr_io_stat.attr,
        &dev_attr_mm_stat.attr,
+#ifdef CONFIG_ZRAM_WRITEBACK
+       &dev_attr_bd_stat.attr,
+#endif
        &dev_attr_debug_stat.attr,
        NULL,
 };