Minchan Kim bb416d18b8 zram: writeback throttle
If there are lots of write IO with flash device, it could have a
wearout problem of storage. To overcome the problem, admin needs
to design write limitation to guarantee flash health
for entire product life.

This patch creates a new knob "writeback_limit" for zram.

writeback_limit's default value is 0 so that it doesn't limit
any writeback. If admin want to measure writeback count in a
certain period, he could know it via /sys/block/zram0/bd_stat's
3rd column.

If admin want to limit writeback as per-day 400M, he could do it
like below.

	MB_SHIFT=20
	4K_SHIFT=12
	echo $((400<<MB_SHIFT>>4K_SHIFT)) > \
		/sys/block/zram0/writeback_limit.

If admin want to allow further write again, he could do it like below

	echo 0 > /sys/block/zram0/writeback_limit

If admin want to see remaining writeback budget,

	cat /sys/block/zram0/writeback_limit

The writeback_limit count will reset whenever you reset zram (e.g., system
reboot, echo 1 > /sys/block/zramX/reset) so keeping how many of writeback
happened until you reset the zram to allocate extra writeback budget in
next setting is user's job.

[minchan@kernel.org: v4]
  Link: http://lkml.kernel.org/r/20181203024045.153534-8-minchan@kernel.org
Link: http://lkml.kernel.org/r/20181127055429.251614-8-minchan@kernel.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Joey Pabalinas <joeypabalinas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-28 12:11:49 -08:00
..
2018-12-27 11:15:21 -08:00
2018-12-28 12:11:49 -08:00
2018-10-29 15:16:01 -07:00
2018-12-27 10:43:24 -08:00
2018-12-27 10:43:24 -08:00
2018-12-03 17:40:18 +01:00
2018-10-16 11:13:50 +02:00
2018-12-25 14:48:06 -08:00
2018-10-11 12:12:55 +02:00
2018-12-25 11:04:17 -08:00
2018-12-27 10:43:24 -08:00
2018-12-25 11:04:17 -08:00
2018-12-18 18:37:27 +01:00
2018-12-25 14:52:50 -08:00
2018-12-13 16:40:03 +00:00
2018-12-25 14:43:54 -08:00
2018-10-26 14:36:21 -07:00
2018-12-24 12:06:56 +01:00
2018-10-29 15:16:01 -07:00
2018-10-31 08:54:16 -07:00
2018-12-25 14:43:54 -08:00
2018-10-11 09:16:44 -07:00
2018-12-27 11:58:50 -08:00
2018-12-11 14:23:17 +01:00
2018-12-25 11:48:26 -08:00
2018-11-12 10:33:49 +01:00
2018-11-12 10:33:49 +01:00