From owner-freebsd-fs@freebsd.org Sat Aug 8 11:23:34 2015 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3EAE39B5EFC for ; Sat, 8 Aug 2015 11:23:34 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 237E8DA3 for ; Sat, 8 Aug 2015 11:23:34 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: by mailman.ysv.freebsd.org (Postfix) id 22B259B5EFB; Sat, 8 Aug 2015 11:23:34 +0000 (UTC) Delivered-To: fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 087289B5EFA for ; Sat, 8 Aug 2015 11:23:34 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from smtp.digiware.nl (smtp.digiware.nl [31.223.170.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8260ADA2 for ; Sat, 8 Aug 2015 11:23:33 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from rack1.digiware.nl (unknown [127.0.0.1]) by smtp.digiware.nl (Postfix) with ESMTP id 4D1401534C8; Sat, 8 Aug 2015 13:23:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at digiware.nl Received: from smtp.digiware.nl ([127.0.0.1]) by rack1.digiware.nl (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6sRRi-b6HbSJ; Sat, 8 Aug 2015 13:23:03 +0200 (CEST) Received: from [192.168.10.10] (asus [192.168.10.10]) by smtp.digiware.nl (Postfix) with ESMTPA id 79E991534C0; Sat, 8 Aug 2015 13:23:03 +0200 (CEST) Subject: Re: Using SSDs as swap To: Konstantin Belousov References: <55C5D48E.6010605@digiware.nl> <20150808102900.GA2072@kib.kiev.ua> <20150808103810.GB2072@kib.kiev.ua> Cc: fs@freebsd.org From: Willem Jan Withagen Message-ID: <55C5E697.4080102@digiware.nl> Date: Sat, 8 Aug 2015 13:23:03 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150808103810.GB2072@kib.kiev.ua> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Aug 2015 11:23:34 -0000 On 8-8-2015 12:38, Konstantin Belousov wrote: > On Sat, Aug 08, 2015 at 01:29:00PM +0300, Konstantin Belousov wrote: >> 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. > > One additional thing: while BIO_DELETE is in progress, the swap block > cannot be marked free, since otherwise we could write other page and > get it obliterated with the TRIM. This can be done async, but the > consequence is that swap space would be released and usable some time > after the page-in. This will affect loads which are close to OOM. Sort of makes sense to me... I take it that BIO_DELETE fires and returns before TRIM is completed? But then the SSD accepts writes to a TRIMmed block, but then mixes this up? Possibly deleting a write to a to be trimmed block? This sort of strikes me as odd, but then I do not know the full intricate details of TRIM on SSD Would it be possible to be notified that a TRIM has completed, only then to actually free the swap sectors? And then perhaps the swap bookkeeping does not yet accommodate for a possible extra state? Speaking about blocks.... Does Swap take into account that disks could be of a sectorsize other than 512 bytes. I would guess so, since we could have a 4K disk as swap disk, and doing read-modify-write for swap is sure going to kill performance. --WjW