mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
system: Align zram priority with swap-space spec to clarify.
Fixes <https://issues.guix.gnu.org/54783>. * gnu/services/linux.scm (zram-device-configuration) [priority]: Adapt to use #f or an integer from 0 to 32767. Add sanitizer to warn for the change and delay the field. (zram-device-configuration->udev-string): Adapt as above. * doc/guix.texi (Zram Device Service): Remove double copyright line. Change priority description to refer to the Swap Space one, and suggest not leaving the default #f on to properly use zram. Reported-by: Stefan Baums <baums@stefanbaums.com> Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
parent
8649ac5eaa
commit
a99015c878
2 changed files with 30 additions and 10 deletions
|
@ -96,10 +96,9 @@ Copyright @copyright{} 2021 Domagoj Stolfa@*
|
|||
Copyright @copyright{} 2021 Hui Lu@*
|
||||
Copyright @copyright{} 2021 pukkamustard@*
|
||||
Copyright @copyright{} 2021 Alice Brenon@*
|
||||
Copyright @copyright{} 2021 Josselin Poiret@*
|
||||
Copyright @copyright{} 2021, 2022 Josselin Poiret@*
|
||||
Copyright @copyright{} 2021 Andrew Tropin@*
|
||||
Copyright @copyright{} 2021 Sarah Morgensen@*
|
||||
Copyright @copyright{} 2021 Josselin Poiret@*
|
||||
Copyright @copyright{} 2022 Remco van 't Veer@*
|
||||
Copyright @copyright{} 2022 Aleksandr Vityazev@*
|
||||
Copyright @copyright{} 2022 Philip M@sup{c}Grath@*
|
||||
|
@ -35202,11 +35201,11 @@ 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.: @code{"2G"}.
|
||||
@item @code{priority} (default @code{-1})
|
||||
@item @code{priority} (default @code{#f})
|
||||
This is the priority of the swap device created from the zram device.
|
||||
@code{swapon} accepts values between -1 and 32767, with higher values
|
||||
indicating higher priority. Higher priority swap will generally be used
|
||||
first.
|
||||
@xref{Swap Space} for a description of swap priorities. You might want
|
||||
to set a specific priority for the zram device, otherwise it could end
|
||||
up not being used much for the reasons described there.
|
||||
@end table
|
||||
|
||||
@end deftp
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
|
||||
;;; Copyright © 2021 raid5atemyhomework <raid5atemyhomework@protonmail.com>
|
||||
;;; Copyright © 2021 B. Wilson <elaexuotee@wilsonb.com>
|
||||
;;; Copyright © 2022 Josselin Poiret <dev@jpoiret.xyz>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
|
@ -21,9 +22,12 @@
|
|||
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (gnu services linux)
|
||||
#:use-module (guix diagnostics)
|
||||
#:use-module (guix gexp)
|
||||
#:use-module (guix records)
|
||||
#:use-module (guix modules)
|
||||
#:use-module (guix i18n)
|
||||
#:use-module (guix ui)
|
||||
#:use-module (gnu services)
|
||||
#:use-module (gnu services base)
|
||||
#:use-module (gnu services shepherd)
|
||||
|
@ -252,7 +256,21 @@ (define-record-type* <zram-device-configuration>
|
|||
(memory-limit zram-device-configuration-memory-limit
|
||||
(default 0)) ; string or integer
|
||||
(priority zram-device-configuration-priority
|
||||
(default -1))) ; integer
|
||||
(default #f) ; integer | #f
|
||||
(delayed) ; to avoid printing the deprecation
|
||||
; warning multiple times
|
||||
(sanitize warn-zram-priority-change)))
|
||||
|
||||
(define-with-syntax-properties
|
||||
(warn-zram-priority-change (priority properties))
|
||||
(if (eqv? priority -1)
|
||||
(begin
|
||||
(warning (source-properties->location properties)
|
||||
(G_ "using -1 for zram priority is deprecated~%"))
|
||||
(display-hint (G_ "Use #f or leave as default instead (@pxref{Linux \
|
||||
Services})."))
|
||||
#f)
|
||||
priority))
|
||||
|
||||
(define (zram-device-configuration->udev-string config)
|
||||
"Translate a <zram-device-configuration> into a string which can be
|
||||
|
@ -278,9 +296,12 @@ (define (zram-device-configuration->udev-string config)
|
|||
"")
|
||||
"RUN+=\"/run/current-system/profile/sbin/mkswap /dev/zram0\" "
|
||||
"RUN+=\"/run/current-system/profile/sbin/swapon "
|
||||
(if (not (equal? -1 priority))
|
||||
(string-append "--priority " (number->string priority) " ")
|
||||
"")
|
||||
;; TODO: Revert to simply use 'priority' after removing the deprecation
|
||||
;; warning and the delayed property of the field.
|
||||
(let ((priority* (force priority)))
|
||||
(if priority*
|
||||
(format #f "--priority ~a " priority*)
|
||||
""))
|
||||
"/dev/zram0\"\n"))))
|
||||
|
||||
(define %zram-device-config
|
||||
|
|
Loading…
Reference in a new issue