From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id mC9cLJFlHF/qXAAA0tVLHw (envelope-from ) for ; Sat, 25 Jul 2020 17:02:09 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id WLouKJFlHF9XYAAA1q6Kng (envelope-from ) for ; Sat, 25 Jul 2020 17:02:09 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CAC919409E8 for ; Sat, 25 Jul 2020 17:02:08 +0000 (UTC) Received: from localhost ([::1]:41060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jzNYk-0007SW-L0 for larch@yhetil.org; Sat, 25 Jul 2020 13:02:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jzNYg-0007SP-Kk for guix-patches@gnu.org; Sat, 25 Jul 2020 13:02:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jzNYg-0002dy-Bz for guix-patches@gnu.org; Sat, 25 Jul 2020 13:02:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jzNYg-0006BP-AP for guix-patches@gnu.org; Sat, 25 Jul 2020 13:02:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42478] [PATCH] services: Add zram-device-service. Resent-From: Marius Bakke Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 25 Jul 2020 17:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42478 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Efraim Flashner , 42478@debbugs.gnu.org Cc: Efraim Flashner Received: via spool by 42478-submit@debbugs.gnu.org id=B42478.159569648023718 (code B ref 42478); Sat, 25 Jul 2020 17:02:02 +0000 Received: (at 42478) by debbugs.gnu.org; 25 Jul 2020 17:01:20 +0000 Received: from localhost ([127.0.0.1]:51035 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jzNY0-0006AU-1I for submit@debbugs.gnu.org; Sat, 25 Jul 2020 13:01:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jzNXy-0006AG-TB for 42478@debbugs.gnu.org; Sat, 25 Jul 2020 13:01:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47232) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jzNXt-0002ad-AP; Sat, 25 Jul 2020 13:01:13 -0400 Received: from 84-52-226.102.3p.ntebredband.no ([84.52.226.102]:45158 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jzNXs-0003ti-OW; Sat, 25 Jul 2020 13:01:13 -0400 From: Marius Bakke In-Reply-To: <20200722181025.29413-1-efraim@flashner.co.il> References: <20200722181025.29413-1-efraim@flashner.co.il> Date: Sat, 25 Jul 2020 19:00:54 +0200 Message-ID: <87eeozsf5l.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -0.61 X-TUID: 2qeOGl1UDPEh --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Efraim Flashner writes: > * gnu/services/linux.scm (): New record. > (zram-device-service-type): New variable. > * doc/guix.texi (Linux Services): Document it. > * tests/services/linux.scm (zram-device-configuration->udev-string): New > test. [...] > diff --git a/doc/guix.texi b/doc/guix.texi > index 8696a9b554..f656c31fab 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -27127,6 +27127,51 @@ parameters, can be done as follow: > @end lisp > @end deffn >=20=20 > +@cindex zram > +@cindex compressed swap > +@cindex Compressed RAM-based block devices > +@subsubheading Zram Device Service > + > +The Zram device service provides a compressed swap device in system > +memory. The Linux Kernel documentation has more information about > +@uref{https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.h= tml,zram} > +devices. > + > +@deffn {Scheme Variable} zram-device-service-type > +This service creates the zram block device, formats it as swap and > +enables it as a swap device. The service's value is a > +@code{zram-device-configuration} record. > + > +@deftp {Data Type} zram-device-configuration > +This is the data type representing the configuration for the zram-device > +service. > + > +@table @asis > +@item @code{disksize} (default @var{"0"}) > +This is the amount of space you wish to provide for the zram device. It > +accepts a string and can be a number of bytes or use a suffix, eg.: > +@var{2G}. Perhaps this could accept both an integer and a string? What does a size 0 device do, would it make sense to not have a default here? Also, would it make sense to name it "size" instad of "disksize"? > +@item @code{comp_algorithm} (default @var{"lzo"}) > +This is the compression algorithm you wish to use. It is difficult to > +list all the possible compression options, but common ones supported by > +Guix's Linux Libre Kernel include @var{lzo}, @var{lz4} and @var{zstd}. "comp_algorithm" is not very idiomatic :-) Either "compression-algorithm" or just "compression" IMO. I'd also prefer a symbol instead of a string (or both!), but no strong opinion. > +@item @code{mem_limit} (default @var{"0"}) "mem_limit" should instead be "memory-limit" or just "limit". Accepting an integer here too would be nice! :-) > +This is the maximum amount of memory which the zram device can use. > +Setting it to '0' disables the limit. While it is generally expected > +that compression will be 2:1, it is possible that uncompressable data > +can be written to swap and this is a method to limit how much memory can > +be used. It accepts a string and can be a number of bytes or use a > +suffix, eg.: @var{2G}. > +@item @code{priority} (default @var{"-1"}) Just an integer I suppose? =20=20 > + > +;;; > +;;; Zram swap device. > +;;; > + > +(define zram-device-configuration->udev-string > + (@@ (gnu services linux) zram-device-configuration->udev-string)) Would it make sense to export this, or is it strictly for internal use? Great that you were able to add unit tests for the functionality. I think in this case we could also have a system test that checks that a zram device was created? But it can come later. Other than the cosmetic/idiomatic issues looks great to me! --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl8cZUYACgkQoqBt8qM6 VPq1kAf7B3s/qVh2ivlOG5eL9hkJ10lfsWEqoFokkk56o4YhcCNHEVcGhYF3ZQyH hMvdj9aBmrLht1gUrpPBqhkRL1ccp0Nz3Af/gFh7UVra51IWfNp+WWnKHOQvDAB+ ooNlZi0b1QJykEpRpAJ5PEY2/9mLIyl9q8PvKvfOehC67aclhGn0ZnBRlFzCsjUB /EBMYUP7vDcb1gze2hWHSTa3R7CmrXH1Q8pVIdCi3U3HE6TSKJfCnM8qLuVdWL6S C4eE5Uj7dv2YQvjTvCxlciJOz0MGqO5ki87GqkUtUiIGm2k+0yF5fVdj0ZsCVa/q zdsUkUj8KFvfpyX2dTf89BFzBjMFxw== =mv2B -----END PGP SIGNATURE----- --=-=-=--