Using SSDs as swap

Konstantin Belousov kostikbel at gmail.com
Sat Aug 8 10:29:13 UTC 2015


On Sat, Aug 08, 2015 at 12:06:06PM +0200, Willem Jan Withagen wrote:
> one of the following commits just passed with this in the log, and it
> triggered again a question I've been having for some time again already.
> 
> ----
> Log:
>   Enable BIO_DELETE passthru in GELI, so TRIM/UNMAP can work as expected
> when
>   GELI is used on a SSD or inside virtual machine, so that guest can tell
>   host that it is no longer using some of the storage.
> -----
> 
> In ZFS I slice my SSD's into log and caches, but on a a server with
> little memory (which can't be grown) I use a partion on each ssd as swap
> as well. So swappinging does not have to seek, and has faster loading
> time. To allocate a few GB on aan SSD to swap is not really all that
> painfull, given current sizes, but the speed difference with regular
> spindels is impressive.
> 
> But the questions are:
> 1) Does the swap driver understand that backing-store needs a TRIM?
No.

> 1a) if not would it be useful, and what would it take to implement?
One good thing is that it is simply the question of coding: the VM
already has a place where it informs the swap pager that the page copy
in swap is no longer needed. this is the vm_pager_page_unswapped() call
and swap pager method swap_pager_unswapped(). swp_pager_meta_ctl() would
need to issue BIO_DELETE to the backing storage.

On the other hand, note that this would increase the amount of work
performed, even for the swap volumes located on the rotating media,
which is more typical and reasonable setup.

I think an implementation and a knob to turn it off, or configure per
swap partition, would be reasonable.

> 2) Does the SSD "suffer" unneeded from swapping on it?
Depends on your swapping activity, but yes, I believe that intense swapping
would wear SSD in the short time.


More information about the freebsd-fs mailing list