Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp743416imu; Mon, 5 Nov 2018 08:09:15 -0800 (PST) X-Google-Smtp-Source: AJdET5e4mnIcsrwW/Lm86v7XN1Y7Ym9a805ikI0LwRddBsve6rMZ3/iscZs8bKXYilXvcY+h9X1I X-Received: by 2002:a63:b105:: with SMTP id r5mr6070220pgf.442.1541434155304; Mon, 05 Nov 2018 08:09:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541434155; cv=none; d=google.com; s=arc-20160816; b=rQUZdKUdpoAjDFIpmcOFBKQGPzpp+zv8nOqDjZ/zM/G88X7AvdZ5hQfNLpPyk7EdPN ZV14z2BtGh9VA2I6UWJ/PzVqyqlbdWmfciW48xWOWCaHRDPynQLr8q3rSB2U9dToP5UO +HgXW24IW1VfH1U9+ioGO6G7GyO0CJtUS/qYU/eo06bmdazbfpGnEPD7GLucUIYQPcEm cgrTc8SXpkyCQtwFD3fhFrNPsYIUmXUCAsZBZJk8GwilqGYy6n6ByOWvFA0qr64E3wMC r/MV83Ls+CV0E2Cjfg9uMrnFwco+Pxn98pTANO07yXfwlovulBC1owHIr4TyMsfnRnIE RZLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=k9p+tBu5HvWbjVvK+KG64/i7HPnw3HQt2b0njU5ufOg=; b=KGAv6zQl7myZZGbK+94pQE5zWmutNCfmTBii4PJHqjLPuv5d9rfYhryAH0KhaUNido 53wtlYubVh8SzLi5zxi2BPqVM0M/FY9y8GaB69rxOm9mZkt0Cea0GeQVOvAgcVfcnAWh vjoc1YH5nqeXK+GW+VXFNFyJSI7nFdkSPU2sSsJz+M0upQU96DCZ14ZbAxOd4SJslW3F u+o/PrVb/FfuiP/dCmtBX49+OlxKiEvI1m75eA2HYMuPmaZeNANkHjIBrJBTxsfUnISI XhPki0nZ72YV+stYsureH2RIvKQVgK6l07hA6m64Jb0ihnqULQP1PoODsyEQn0CPAYYb Ey/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UQXr5oHD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 30-v6si23139623plb.342.2018.11.05.08.08.37; Mon, 05 Nov 2018 08:09:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UQXr5oHD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387483AbeKFB2G (ORCPT + 99 others); Mon, 5 Nov 2018 20:28:06 -0500 Received: from mail-io1-f54.google.com ([209.85.166.54]:46420 "EHLO mail-io1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387398AbeKFB2G (ORCPT ); Mon, 5 Nov 2018 20:28:06 -0500 Received: by mail-io1-f54.google.com with SMTP id y22-v6so6836169ioj.13 for ; Mon, 05 Nov 2018 08:07:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=k9p+tBu5HvWbjVvK+KG64/i7HPnw3HQt2b0njU5ufOg=; b=UQXr5oHDBc74XwmpgdW+NCg+pphV6IWkQEfgLb6T08mCr/a9PS4+0eduhe3OOe9OAj psf8YZKaFyZTqBkdz7CuGBm+T3NEkJStqDCc+07Uoq0wSL/GFejuQz+d4rLjye5sNrRS h7q0M2jF4a/9J9mxj1uLdW3cwZli4NskUhG8oZTRn0fKpdPx/tLYIKOk3Cc82+G0uc9w l79adcjfvjX/gVify+EUnJD0dWlRwp+j99r3aONqzq966IetNnLWXQvGK9Q8DP3Y60Px k5tfXGzCrzvz1KfO56MUFXGj6ZAHwok4T0HBP/jgwomMde3dlumBclMG978Fsxo3tR6k qaCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=k9p+tBu5HvWbjVvK+KG64/i7HPnw3HQt2b0njU5ufOg=; b=GFA+VhMu+tZZTfcmctjSOprwU9Zw+Dy+tDMAJLP3y6bKllB+MopslYBwcdLofaMpwa CJRXQxMRJu7r37e4dmixYnX4WRFnUpfrH0ZMRladAPiZlAhNlYNARc1+qhm48v4+VWku 4qQgkuL4kgVCuBirl70SSrZwlbBxPjfG7wHGoLEex6ketp3anR0ZGXk5TZGvPIYGpW7x 2j2+FuoJA1MtvdHIzTbevbmcEuKslo+O+2+4dyH0e8jtClepBAKqmIEAD29TpKIB7Tz2 0n/EJv9VjHFTjFsN5VKRP+4LFwEZe91qVuQ4IcBc0KmzkJAvaj+RRiPzWqJT+dhuHzo1 LV1Q== X-Gm-Message-State: AGRZ1gKkj/fg+yccCkF0RGUyTM6VwAfGq6cmiegQkK4NXhbummgL6CLr KU4feyduugO5RVxhVjHuNBw= X-Received: by 2002:a6b:8e44:: with SMTP id q65-v6mr11534227iod.197.1541434062444; Mon, 05 Nov 2018 08:07:42 -0800 (PST) Received: from [191.9.209.46] (rrcs-147-0-47-180.central.biz.rr.com. [147.0.47.180]) by smtp.gmail.com with ESMTPSA id k3-v6sm2698375iop.26.2018.11.05.08.07.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 08:07:41 -0800 (PST) Subject: Re: Creating compressed backing_store as swapfile To: Adam Borowski , Pintu Agarwal Cc: linux-mm@kvack.org, open list , kernelnewbies@kernelnewbies.org References: <20181105155815.i654i5ctmfpqhggj@angband.pl> From: "Austin S. Hemmelgarn" Message-ID: <79d0c96a-a0a2-63ec-db91-42fd349d50c1@gmail.com> Date: Mon, 5 Nov 2018 11:07:12 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181105155815.i654i5ctmfpqhggj@angband.pl> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/5/2018 10:58 AM, Adam Borowski wrote: > On Mon, Nov 05, 2018 at 08:31:46PM +0530, Pintu Agarwal wrote: >> Hi, >> >> I have one requirement: >> I wanted to have a swapfile (64MB to 256MB) on my system. >> But I wanted the data to be compressed and stored on the disk in my swapfile. >> [Similar to zram, but compressed data should be moved to disk, instead of RAM]. >> >> Note: I wanted to optimize RAM space, so performance is not important >> right now for our requirement. >> >> So, what are the options available, to perform this in 4.x kernel version. >> My Kernel: 4.9.x >> Board: any - (arm64 mostly). >> >> As I know, following are the choices: >> 1) ZRAM: But it compresses and store data in RAM itself >> 2) frontswap + zswap : Didn't explore much on this, not sure if this >> is helpful for our case. >> 3) Manually creating swapfile: but how to compress it ? >> 4) Any other options ? > > Loop device on any filesystem that can compress (such as btrfs)? The > performance would suck, though -- besides the indirection of loop, btrfs > compresses in blocks of 128KB while swap wants 4KB writes. Other similar > option is qemu-nbd -- it can use compressed disk images and expose them to a > (local) nbd client. Swap on any type of a networked storage device (NBD, iSCSI, ATAoE, etc) served from the local system is _really_ risky. The moment the local server process for the storage device gets forced out to swap, you deadlock. Performance isn't _too_ bad for the BTRFS case though (I've actually tested this before), just make sure you disable direct I/O mode on the loop device, otherwise you run the risk of data corruption.