From owner-freebsd-fs@freebsd.org Sat Aug 8 18:51:44 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 BCB269B6284 for ; Sat, 8 Aug 2015 18:51:44 +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 A17331950 for ; Sat, 8 Aug 2015 18:51:44 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: by mailman.ysv.freebsd.org (Postfix) id A0AED9B6283; Sat, 8 Aug 2015 18:51:44 +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 868759B6282 for ; Sat, 8 Aug 2015 18:51:44 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from smtp.digiware.nl (unknown [IPv6:2001:4cb8:90:ffff::3]) (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 4B90F194F for ; Sat, 8 Aug 2015 18:51:44 +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 043CC153413; Sat, 8 Aug 2015 20:51:40 +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 NCEwvqnFOBKn; Sat, 8 Aug 2015 20:51:29 +0200 (CEST) Received: from [192.168.10.10] (asus [192.168.10.10]) by smtp.digiware.nl (Postfix) with ESMTPA id 4803215340A; Sat, 8 Aug 2015 20:51:29 +0200 (CEST) Subject: Re: Using SSDs as swap To: Konstantin Belousov , Warren Block References: <55C5D48E.6010605@digiware.nl> <20150808102900.GA2072@kib.kiev.ua> <55C5E34B.9010905@digiware.nl> <20150808113750.GC2072@kib.kiev.ua> <55C60441.7040906@digiware.nl> <20150808183234.GG2072@kib.kiev.ua> Cc: fs@freebsd.org From: Willem Jan Withagen Message-ID: <55C64FB1.9070402@digiware.nl> Date: Sat, 8 Aug 2015 20:51:29 +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: <20150808183234.GG2072@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 18:51:44 -0000 On 8-8-2015 20:32, Konstantin Belousov wrote: > On Sat, Aug 08, 2015 at 12:26:38PM -0600, Warren Block wrote: >> On Sat, 8 Aug 2015, Willem Jan Withagen wrote: >>> >>> So perhaps the nicest thing to do for the SSDs is TRIM swap at >>> startup??? So the the SSD controller van do its garbage collection and >>> then keep the remainder of the stuff as it is. >> >> This can be done now by using a swap file on a UFS partition with trim >> enabled. The catch is that the swap file has to be deleted and >> recreated to trigger the trim. The delete is quick, but the create >> depends on the size of the file and the speed of the hardware. (And no, >> sparse files do not work as swap files.) > This could work, in the sense that swap would indeed work as a swap, > and not as a deadlock generator. But it adds very significant (up to > 100% in the CPU time, I think) overhead. > > Note that you cannot swap to file directly, you must create md(4) over > the file and swap to it. > > But doing such layer over layer to get the TRIM is somewhat silly. Right, added layering is not really something you'd be looking for here. We talking about incidental swapping to SSD, so then the system is already under pressure. >> Maybe rotate swap files like log files, so they could be created when >> the system is idle. 'mmm, once swap is in use, I do not think you can unswap? So even if the sytem is idle, was was not swapped back in because it is needed stays out on swap. Look at my curent swap on a ZFS file server, I added 2 SSDs partitions about 1,2 ago. But even the old swap was not released.... { swap on SSD's are on ad{2,3}p2 } Device 1K-blocks Used Avail Capacity /dev/ada2p2 8388608 122M 7.9G 1% /dev/ada3p2 8388608 123M 7.9G 2% /dev/gpt/swap0 8388608 4.6M 8.0G 0% /dev/gpt/swap1 8388608 5.0M 8.0G 0% Total 33554432 255M 32G 1% (Yes, I realise that 32Gb swap for a 8Gb system is somewhat silly) Different idea if we do not want to TRIM from the kernel when issueing swapon: Would it be possible to use camcontrol to issue a "trim" on a (GPT) swap partition? Or does gpart anything that could be conceived as a TRIM. Because then the initscript would first check for saved cores, and once done that trim the swappartition with a commandline tool? --WjW