zram: use notify_free to account all free notifications
Subsystems (2)
PATCH v3 1/1 zram: use notify_free to account all free notifications
Hello,
This patch change the way zram uses notify_free' stat attr. Currently, this attr accounts only swap free notifications, iow used only when zram device is a swap device. The patch preserves the existing behaviour and additionally makes notify_free' universal, so it's also used by zram to account REQ_DISCARDs when zram is not used as a swap device.
Please refer to:
https://lkml.org/lkml/2014/9/3/1115
V3:
-- account all notifications, including those that hit ZRAM_ZERO page V2:
-- fix accounting error found by Minchan Kim.
Sergey Senozhatsky (1):
zram: use notify_free to account all free notifications
Documentation/ABI/testing/sysfs-block-zram | 13 ++++++++----- drivers/block/zram/zram_drv.c | 1 + 2 files changed, 9 insertions(+), 5 deletions(-)
Signature · 1 line
2.1.0.350.g8b25fe0
PATCH v3 1/1 zram: use notify_free to account all free notifications
`notify_free' device attribute accounts the number of slot free notifications and internally represents the number of zram_free_page() calls. Slot free notifications are sent only when device is used as a swap device, hence `notify_free' is used only for swap devices. Since f4659d8e620d08 (zram:
support REQ_DISCARD) ZRAM handles yet another one free notification (also via zram_free_page() call) -- REQ_DISCARD requests, which are sent by a filesystem, whenever some data blocks are discarded. However, there is no way to know the number of notifications in the latter case.
Use notify_free' to account the number of pages freed by zram_bio_discard() and zram_slot_free_notify(). Depending on usage scenario notify_free' represents:
a) the number of pages freed because of slot free notifications, which is equal to the number of swap_slot_free_notify() calls, so there is no behaviour change
b) the number of pages freed because of REQ_DISCARD notifications
--- Documentation/ABI/testing/sysfs-block-zram | 13 ++++++++----- drivers/block/zram/zram_drv.c | 1 + 2 files changed, 9 insertions(+), 5 deletions(-)
Documentation/ABI/testing/sysfs-block-zram +8 -5
@@ -77,11 +77,14 @@ What: /sys/block/zram<id>/notify_free Date: August 2010 Contact: Nitin Gupta <[email protected]> Description: - The notify_free file is read-only and specifies the number of - swap slot free notifications received by this device. These - notifications are sent to a swap block device when a swap slot - is freed. This statistic is applicable only when this disk is - being used as a swap disk. + The notify_free file is read-only. Depending on device usage + scenario it may account a) the number of pages freed because + of swap slot free notifications or b) the number of pages freed + because of REQ_DISCARD requests sent by bio. The former ones + are sent to a swap block device when a swap slot is freed, which + implies that this disk is being used as a swap disk. The latter + ones are sent by filesystem mounted with discard option, + whenever some data blocks are getting discarded. What: /sys/block/zram<id>/zero_pages Date: August 2010
drivers/block/zram/zram_drv.c +1 -0
@@ -698,6 +698,7 @@ static void zram_bio_discard(struct zram *zram, u32 index,bit_spin_lock (ZRAM_ACCESS , &meta->table[index].value);zram_free_page (zram, index);bit_spin_unlock (ZRAM_ACCESS , &meta->table[index].value); +atomic64_inc (&zram->stats.notify_free); index++; n -=PAGE_SIZE ; }
Signature · 1 line
2.1.0.350.g8b25fe0
Quoted 16 lines · Sergey Senozhatsky
`notify_free' device attribute accounts the number of slot free notifications and internally represents the number of
zram_free_page()calls. Slot free notifications are sent only when device is used as a swap device, hence `notify_free' is used only for swap devices. Sincef4659d8e620d08(zram:
supportREQ_DISCARD) ZRAM handles yet another one free notification (also viazram_free_page()call) --REQ_DISCARDrequests, which are sent by a filesystem, whenever some data blocks are discarded. However, there is no way to know the number of notifications in the latter case.Use
notify_free' to account the number of pages freed by zram_bio_discard() and zram_slot_free_notify(). Depending on usage scenarionotify_free' represents:
a) the number of pages freed because of slot free notifications, which is equal to the number ofswap_slot_free_notify()calls, so there is no behaviour change
Quoted 3 lines
b) the number of pages freed because of
REQ_DISCARDnotificationsSigned-off-by Sergey Senozhatsky <[email protected]>
Thanks a lot!
Signature · 2 lines
Kind regards, Minchan Kim
Quoted 16 lines · Sergey Senozhatsky
`notify_free' device attribute accounts the number of slot free notifications and internally represents the number of
zram_free_page()calls. Slot free notifications are sent only when device is used as a swap device, hence `notify_free' is used only for swap devices. Sincef4659d8e620d08(zram:
supportREQ_DISCARD) ZRAM handles yet another one free notification (also viazram_free_page()call) --REQ_DISCARDrequests, which are sent by a filesystem, whenever some data blocks are discarded. However, there is no way to know the number of notifications in the latter case.Use
notify_free' to account the number of pages freed by zram_bio_discard() and zram_slot_free_notify(). Depending on usage scenarionotify_free' represents:
a) the number of pages freed because of slot free notifications, which is equal to the number ofswap_slot_free_notify()calls, so there is no behaviour change
Quoted 3 lines
b) the number of pages freed because of
REQ_DISCARDnotificationsSigned-off-by Sergey Senozhatsky <[email protected]>
Quoted 42 lines
--- Documentation/ABI/testing/sysfs-block-zram | 13 ++++++++----- drivers/block/zram/zram_drv.c | 1 + 2 files changed, 9 insertions(+), 5 deletions(-)Documentation/ABI/testing/sysfs-block-zram +8
-5@@ -77,11 +77,14 @@ What: /sys/block/zram<id>/notify_free Date: August 2010 Contact: Nitin Gupta <[email protected]> Description: - The notify_free file is read-only and specifies the number of - swap slot free notifications received by this device. These - notifications are sent to a swap block device when a swap slot - is freed. This statistic is applicable only when this disk is - being used as a swap disk. + The notify_free file is read-only. Depending on device usage + scenario it may account a) the number of pages freed because + of swap slot free notifications or b) the number of pages freed + because of REQ_DISCARD requests sent by bio. The former ones + are sent to a swap block device when a swap slot is freed, which + implies that this disk is being used as a swap disk. The latter + ones are sent by filesystem mounted with discard option, + whenever some data blocks are getting discarded. What: /sys/block/zram<id>/zero_pages Date: August 2010drivers/block/zram/zram_drv.c +1
-0@@ -698,6 +698,7 @@ static void zram_bio_discard(struct zram *zram, u32 index,bit_spin_lock (ZRAM_ACCESS , &meta->table[index].value);zram_free_page (zram, index);bit_spin_unlock (ZRAM_ACCESS , &meta->table[index].value); +atomic64_inc (&zram->stats.notify_free); index++; n -=PAGE_SIZE ; }