Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

zram: move bd_stat to writeback section

Move bd_stat function and attribute declaration to
existing CONFIG_WRITEBACK ifdef-sections.

Link: https://lkml.kernel.org/r/20251201094754.4149975-5-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Brian Geffon <bgeffon@google.com>
Cc: David Stevens <stevensd@google.com>
Cc: Minchan Kim <minchan@google.com>
Cc: Richard Chang <richardycc@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Sergey Senozhatsky and committed by
Andrew Morton
910bbb44 2502673a

+21 -27
+21 -27
drivers/block/zram/zram_drv.c
··· 539 539 u32 index; 540 540 }; 541 541 542 + #define FOUR_K(x) ((x) * (1 << (PAGE_SHIFT - 12))) 543 + static ssize_t bd_stat_show(struct device *dev, struct device_attribute *attr, 544 + char *buf) 545 + { 546 + struct zram *zram = dev_to_zram(dev); 547 + ssize_t ret; 548 + 549 + down_read(&zram->init_lock); 550 + ret = sysfs_emit(buf, 551 + "%8llu %8llu %8llu\n", 552 + FOUR_K((u64)atomic64_read(&zram->stats.bd_count)), 553 + FOUR_K((u64)atomic64_read(&zram->stats.bd_reads)), 554 + FOUR_K((u64)atomic64_read(&zram->stats.bd_writes))); 555 + up_read(&zram->init_lock); 556 + 557 + return ret; 558 + } 559 + 542 560 static ssize_t writeback_compressed_store(struct device *dev, 543 561 struct device_attribute *attr, 544 562 const char *buf, size_t len) ··· 1994 1976 return ret; 1995 1977 } 1996 1978 1997 - #ifdef CONFIG_ZRAM_WRITEBACK 1998 - #define FOUR_K(x) ((x) * (1 << (PAGE_SHIFT - 12))) 1999 - static ssize_t bd_stat_show(struct device *dev, 2000 - struct device_attribute *attr, char *buf) 2001 - { 2002 - struct zram *zram = dev_to_zram(dev); 2003 - ssize_t ret; 2004 - 2005 - down_read(&zram->init_lock); 2006 - ret = sysfs_emit(buf, 2007 - "%8llu %8llu %8llu\n", 2008 - FOUR_K((u64)atomic64_read(&zram->stats.bd_count)), 2009 - FOUR_K((u64)atomic64_read(&zram->stats.bd_reads)), 2010 - FOUR_K((u64)atomic64_read(&zram->stats.bd_writes))); 2011 - up_read(&zram->init_lock); 2012 - 2013 - return ret; 2014 - } 2015 - #endif 2016 - 2017 1979 static ssize_t debug_stat_show(struct device *dev, 2018 - struct device_attribute *attr, char *buf) 1980 + struct device_attribute *attr, char *buf) 2019 1981 { 2020 1982 int version = 1; 2021 1983 struct zram *zram = dev_to_zram(dev); ··· 2013 2015 2014 2016 static DEVICE_ATTR_RO(io_stat); 2015 2017 static DEVICE_ATTR_RO(mm_stat); 2016 - #ifdef CONFIG_ZRAM_WRITEBACK 2017 - static DEVICE_ATTR_RO(bd_stat); 2018 - #endif 2019 2018 static DEVICE_ATTR_RO(debug_stat); 2020 2019 2021 2020 static void zram_meta_free(struct zram *zram, u64 disksize) ··· 3074 3079 static DEVICE_ATTR_WO(idle); 3075 3080 static DEVICE_ATTR_RW(comp_algorithm); 3076 3081 #ifdef CONFIG_ZRAM_WRITEBACK 3082 + static DEVICE_ATTR_RO(bd_stat); 3077 3083 static DEVICE_ATTR_RW(backing_dev); 3078 3084 static DEVICE_ATTR_WO(writeback); 3079 3085 static DEVICE_ATTR_RW(writeback_limit); ··· 3098 3102 &dev_attr_idle.attr, 3099 3103 &dev_attr_comp_algorithm.attr, 3100 3104 #ifdef CONFIG_ZRAM_WRITEBACK 3105 + &dev_attr_bd_stat.attr, 3101 3106 &dev_attr_backing_dev.attr, 3102 3107 &dev_attr_writeback.attr, 3103 3108 &dev_attr_writeback_limit.attr, ··· 3108 3111 #endif 3109 3112 &dev_attr_io_stat.attr, 3110 3113 &dev_attr_mm_stat.attr, 3111 - #ifdef CONFIG_ZRAM_WRITEBACK 3112 - &dev_attr_bd_stat.attr, 3113 - #endif 3114 3114 &dev_attr_debug_stat.attr, 3115 3115 #ifdef CONFIG_ZRAM_MULTI_COMP 3116 3116 &dev_attr_recomp_algorithm.attr,