From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4OHZBDgTjWKouwAAbAwnHQ (envelope-from ) for ; Tue, 24 May 2022 19:17:44 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id aLTVAzgTjWINMwEAG6o9tA (envelope-from ) for ; Tue, 24 May 2022 19:17:44 +0200 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 902D8144B1 for ; Tue, 24 May 2022 19:17:43 +0200 (CEST) Received: from localhost ([::1]:57436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntYAA-00071I-Q5 for larch@yhetil.org; Tue, 24 May 2022 13:17:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntY9W-0006wL-T7 for bug-guix@gnu.org; Tue, 24 May 2022 13:17:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59343) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntY9W-0005Lk-JZ for bug-guix@gnu.org; Tue, 24 May 2022 13:17:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ntY9W-00020e-Fl for bug-guix@gnu.org; Tue, 24 May 2022 13:17:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#54783: [PATCH v2 1/2] system: Align zram priority with swap-space spec to clarify. Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 24 May 2022 17:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54783 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Maxim Cournoyer Cc: 54783@debbugs.gnu.org, Stefan Baums , Josselin Poiret Received: via spool by 54783-submit@debbugs.gnu.org id=B54783.16534126077684 (code B ref 54783); Tue, 24 May 2022 17:17:02 +0000 Received: (at 54783) by debbugs.gnu.org; 24 May 2022 17:16:47 +0000 Received: from localhost ([127.0.0.1]:53238 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ntY9E-0001zo-7C for submit@debbugs.gnu.org; Tue, 24 May 2022 13:16:47 -0400 Received: from jpoiret.xyz ([206.189.101.64]:34632) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ntY98-0001zQ-Cm for 54783@debbugs.gnu.org; Tue, 24 May 2022 13:16:41 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 034691851D2; Tue, 24 May 2022 17:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1653412595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aLveTWhfUN57rqAPomWZbpKXknSPcnz9eVeKV2zTrXg=; b=geRKuJP3/9F7W9iO8/Kc40K90UdHnNtTZiPqG8jQU03RgCSs3xgiWfyZtrrzaSVUP3OYVd P4jg98M12mW7ec20PSAdQJPAQVPHMUTAwmgvwn8CcbOHq68DuQ410iUe4CfFNZTWpnGMMi P4buUqhKoyJQ7fFsa1gGtLo6lFJQuEokXcOeG4Yet/MNP1dbKHzDczi4YtEatwwrhgl9VY vkH6W9FpOK+m7jauZtQaZ5aIY+kD6iw5mm0m+fkAq4tflMxdQbrjy09BQ2k/0bnpqCTdjZ YvUm/vLoo+MsscnkwmYOLl7Wt83SMqi3ihP/MI8lFsTAAVWEl42bZUD9n6xtlg== Date: Tue, 24 May 2022 19:16:30 +0200 Message-Id: <20220524171631.25011-2-dev@jpoiret.xyz> In-Reply-To: <20220524171631.25011-1-dev@jpoiret.xyz> References: <87o7zn3pkf.fsf_-_@gmail.com> <20220524171631.25011-1-dev@jpoiret.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spamd-Bar: - X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" Reply-to: Josselin Poiret From: Josselin Poiret via Bug reports for GNU Guix X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653412663; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=aLveTWhfUN57rqAPomWZbpKXknSPcnz9eVeKV2zTrXg=; b=hl1xGV1jqROW63P3UdexWuehKhbKMQ2juD7cwdyMqPFlJKCPEekiWK2MQ72bUbqx5UMRzM wcAYUmkflYe/K9EX9LWBg37t4Wxq5h9KL1ju6EjL4VB5tZKvBBo/PhrXyWiSEnM8edZhAF vP80z7On4Igpc5N2V3o1sQmpPybYlG2glC3+jiO5vdDJsmAhSf0MGNENWylJ04Pvx8iBgN jNXZ4xCcVUi7VqMO4QnG3IeRk1HAfthxLPDhPfDRkXjCVa/DBpbttqR2DvJTg+RpAGZ7GX HVxWWpey8iR46PEMQQuvNKLJKGT64lBHi1xJW8Fm3VndadTVvd2RxQpFEUJXqA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653412663; a=rsa-sha256; cv=none; b=jLSeSkx0m+KhyHULrr1bXQivHpd4zBJkS2npRxX8krueN2iuePv3TvpLjlH6Zu9d5FxY5T ulIb6u/B+VZ3s0gTwLGnyU3PIk4zTqbimskaOORqHsCzGZj0rZeOig02Z2PLDUFcgFVYF7 ILNeO0l5w3HAcYkDBi8AW6lYPHUkq4ep4OFvs1ObiMa1M7T+E51DIfnc08ucz7h0TwwwCL PNeM9ejiZGJPuxV37+GF4Nxnia9ksdg1m5nzEEu2W1L78LNaHxhwnYjSdTrYzQNQAdIrEX UeHxL9lXurRRtdgOTW5x3b+ODp6i1BAd0KrUd0agzLjhKrxhEK3P1oEI62I5ZA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b=geRKuJP3; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.04 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b=geRKuJP3; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 902D8144B1 X-Spam-Score: -2.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: 3IO2dnZoC6d2 * 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): Change priority description to refer to the Swap Space one, and suggest not leaving the default #f on to properly use zram. --- doc/guix.texi | 10 +++++----- gnu/services/linux.scm | 29 ++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 184206bec8..5f0120a3bd 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -96,7 +96,7 @@ 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@* @@ -35213,11 +35213,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 diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm index 2eb02ac5a3..c6e460597a 100644 --- a/gnu/services/linux.scm +++ b/gnu/services/linux.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2020 Efraim Flashner ;;; Copyright © 2021 raid5atemyhomework ;;; Copyright © 2021 B. Wilson +;;; Copyright © 2022 Josselin Poiret ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,9 +22,12 @@ ;;; along with GNU Guix. If not, see . (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* (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 into a string which can be @@ -278,8 +296,13 @@ (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) " ") + ;; XXX: The field is delayed while the deprecation warning remains in + ;; place, so we can't use match to fetch it (it would give a promise) + (if (zram-device-configuration-priority config) + (string-append "--priority " + (number->string + (zram-device-configuration-priority config)) + " ") "") "/dev/zram0\"\n")))) -- 2.36.0