From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omr1.cc.ipv6.vt.edu ([2607:b400:92:8300:0:c6:2117:b0e] helo=omr1.cc.vt.edu) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gJhUA-0001eA-Rj for kernelnewbies@kernelnewbies.org; Mon, 05 Nov 2018 11:12:18 -0500 Received: from mr1.cc.vt.edu (inbound.smtp.ipv6.vt.edu [IPv6:2607:b400:92:9:0:9d:8fcb:4116]) by omr1.cc.vt.edu (8.14.4/8.14.4) with ESMTP id wA5GCHBD013177 for ; Mon, 5 Nov 2018 11:12:17 -0500 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mr1.cc.vt.edu (8.14.7/8.14.7) with ESMTP id wA5GCC2j005106 for ; Mon, 5 Nov 2018 11:12:17 -0500 Received: by mail-qk1-f197.google.com with SMTP id s70so22525494qks.4 for ; Mon, 05 Nov 2018 08:12:17 -0800 (PST) From: valdis.kletnieks@vt.edu To: Pintu Agarwal Subject: Re: Creating compressed backing_store as swapfile In-Reply-To: References: Mime-Version: 1.0 Date: Mon, 05 Nov 2018 11:12:08 -0500 Message-ID: <40880.1541434328@turing-police.cc.vt.edu> Cc: linux-mm@kvack.org, open list , kernelnewbies@kernelnewbies.org List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0473842691899491681==" Errors-To: kernelnewbies-bounces@kernelnewbies.org Message-ID: <20181105161208.aJHJomKrmmd-v4IQuAagmIZDNRZHJoDxX46aOz2qKXc@z> --===============0473842691899491681== Content-Type: multipart/signed; boundary="==_Exmh_1541434328_4003P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit --==_Exmh_1541434328_4003P Content-Type: text/plain; charset=us-ascii On Mon, 05 Nov 2018 20:31:46 +0530, Pintu Agarwal said: > 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]. What platform are you on that you're both storage constrained enough to need swap, and also so short on disk space that compressing it makes sense? Understanding the hardware constraints here would help in advising you. > 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 Given that this is a greenfield development, why are you picking a kernel that's 2 years out of date? You *do* realize that 4.9.135 does *not* contain all the bugfixes since then, only that relatively small subset that qualify for 'stable' (see Documentation/process/stable-kernel-rules.rst for the gory details). One possible total hack would be to simply use a file-based swap area, but put the file on a filesystem that supports automatic inline compression. Note that this will probably *totally* suck on performance, because there's no good way to find where 4K block 11,493 starts inside the compressed file, so it would have to read/decompress from the file beginning. Also, if you write data to a previously unused location (or even a previously used spot that compressed the 4K page to a different length), you have a bad time inserting it. (Note that zram can avoid most of this because it can (a) keep a table of pointers to where each page starts and (b) it isn't constrained to writing to 4K blocks on disk, so if the current compression takes a 4K page down to 1,283 bytes, it doesn't have to care *too* much if it stores that someplace that crosses a page boundary. Another thing that you will need to worry about is what happens in low-memory situations - the time you *most* need to do a swap operation, you may not have enough memory to do the I/O. zram basically makes sure it *has* the memory needed beforehand, and swap directly to pre-allocated disk doesn't need much additional memory. --==_Exmh_1541434328_4003P Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Comment: Exmh version 2.8.0 04/21/2017 iQEVAwUBW+Br2I0DS38y7CIcAQJnHwf/Qs6+ukFbpph4XreLTFTClbciDiZRmurD 2m4lrYl698x3E1MfatqrWUgVyjv6hSrfja1rlxHboSEwxhQu5tCXIyTZhMf3JUi8 UYZeuHBA+2tTr8WCqje9zUAIk4L/fKWFcv6KWJMxXSYQVQsHhFG/zXOMAn7EieDH xRGECm7Uv4BQJ20S6krgYLEvAPVOBBwXQzFHGUfuNZ6AwjGMGBGlAN92xCg/Ojao aVU/qGXtjcCsnv3+iEY/ZKN4RqTgE3F0OH+D3UKY7FsT1hXNdGcQTltXQ8CZ7Se+ ZE7RurVFEKvoxdIFswYqwwrD4a+g9mwevwvzt5vRAJE4cimwfwxHWA== =ThRu -----END PGP SIGNATURE----- --==_Exmh_1541434328_4003P-- --===============0473842691899491681== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============0473842691899491681==--