[PATCH] zram-swap: enable swap discard
Rui Salvaterra
rsalvaterra at gmail.com
Wed Jun 24 18:39:27 EDT 2020
Hi, Emil,
On Wed, 24 Jun 2020 at 20:30, Emil Muratov <gpm at hotplug.ru> wrote:
>
> zram swap discard is enabled by default, no need to specify additional
> option. Pls, check for example info output in
> https://github.com/openwrt/openwrt/pull/1515
Unfortunately, that's not quite right. This has nothing to do with
zram itself, but with the way swapon syscall works. Yes, both discard
*policies* are enabled by default if, *and only if* the syscall is
invoked with *only* the SWAP_FLAG_DISCARD flag set [1].
Anyway, it's easy to see if the swap device is issuing trim/discard
commands. For example, on my router, with my patch:
root at heimdal:~# dmesg | grep swap
[ 12.302928] Adding 1036284k swap on /dev/zram0. Priority:-2
extents:1 across:1036284k SSDsc
root at heimdal:~#
According to the relevant section of the kernel source code [2], The
last letters, SSDsc mean:
SS: solid state (obviously, it's a RAM-based device)
D: supports discard
s: area-based discard is enabled
c: page-based discard is enabled
Consequently, if a system only shows SS, discard commands aren't being issued.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/swap.h?h=linux-4.14.y#n24
[2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/mm/swapfile.c?h=linux-4.14.y#n3283
Cheers,
Rui
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
http://lists.infradead.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list