From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 8JObHDNhYWLOewAAbAwnHQ (envelope-from ) for ; Thu, 21 Apr 2022 15:50:43 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id gLemHDNhYWJvowAAauVa8A (envelope-from ) for ; Thu, 21 Apr 2022 15:50:43 +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 D673EED5B for ; Thu, 21 Apr 2022 15:50:42 +0200 (CEST) Received: from localhost ([::1]:51594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhXCj-0002Qx-2v for larch@yhetil.org; Thu, 21 Apr 2022 09:50:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhXC8-0002O4-F3 for bug-guix@gnu.org; Thu, 21 Apr 2022 09:50:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhXC7-0005oB-B5 for bug-guix@gnu.org; Thu, 21 Apr 2022 09:50:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nhXC7-0007xV-8M for bug-guix@gnu.org; Thu, 21 Apr 2022 09:50:03 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#54783: [PATCH 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: Thu, 21 Apr 2022 13:50:03 +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: Stefan Baums , 54783@debbugs.gnu.org Cc: Josselin Poiret Received: via spool by 54783-submit@debbugs.gnu.org id=B54783.165054897130500 (code B ref 54783); Thu, 21 Apr 2022 13:50:03 +0000 Received: (at 54783) by debbugs.gnu.org; 21 Apr 2022 13:49:31 +0000 Received: from localhost ([127.0.0.1]:48767 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nhXBa-0007vl-OS for submit@debbugs.gnu.org; Thu, 21 Apr 2022 09:49:31 -0400 Received: from jpoiret.xyz ([206.189.101.64]:35610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nhXBY-0007vR-Li for 54783@debbugs.gnu.org; Thu, 21 Apr 2022 09:49:29 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 5490F184BF2; Thu, 21 Apr 2022 13:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1650548966; 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=UIwK70k46IKPm09KBnzmf7zUFPzerlQnvzCfGbyB08k=; b=BOkMdSx0cIG3/QNVCiK/G7qs+40L//LAHL3IJhBa46CXR0EQaXKTySPRUOuvLK8dRbh0Qt Z5XowrD2nVKMhlzQAV2Um1cCSkZ5f6FY24kkTpgVaSVyuWXgpuKU33WwyiI2e4xvAmztSo UWAv3fmOmex4N6skneXLVVJWYwZsLz5H31a/S3vQ+qliQI7pXBe/llsfQM5hwcKji/ACgS CJwjYRywHXm8w0+pcGDq7Wo62m23JCXcAbu4sQ+o+F+j1lu7AsLMXQpFh9aHqcW07aTLuK Co9w+qosb4hni86eTjG2nVzUdMorswN4auB1J8IbbugqSCv6/3wrDy0UkZ1xfg== Date: Thu, 21 Apr 2022 15:49:20 +0200 Message-Id: <20220421134921.1505-1-dev@jpoiret.xyz> In-Reply-To: <87sfq6g96j.fsf@jpoiret.xyz> References: <87sfq6g96j.fsf@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=1650549043; 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=UIwK70k46IKPm09KBnzmf7zUFPzerlQnvzCfGbyB08k=; b=KmQIbksfo87fCgX/3ny7F0pBC300LJ9ZPPOARAciOybnaLJTdga/l4b06YPdXCW3sl5GR4 3CvdKrXtog6JIFMNBGeKA9dcx0AlNSOico7MBC9JL90UWtj0CrlpFlHXLk3+DnrHrgQAmi sVKLezLZ2Frd1y93GRb9ujk1bOzL6T3ql55XpVctn9yiBayX384M3CB5woiYk16YfXxRls 2cgrACUMcHSiGbhMYl8X8vVh+ZBfssQFwUMjjJT2nmwW9k0Yac5NBjRzo8a5EmLuThws+Q zV+ip755OKYVPsOhUOz9G8CSDlTZgq9q/FlaTTUFqpSIYVDNE7iTp3EYM6xyfQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650549043; a=rsa-sha256; cv=none; b=U/mky3P4jZpdeBeR6VaxVdME1lY5kItvJVEJEIbhcuNG0ZSOCSPJFLbakmD2Pl06tKZOge 9li0bG8VUisnY22MSrcG5SYoOMZIHoIqZXqi5xiim+QNDamRQX7IZTRvXW8ph3RszX+RDK 1QC+sGnQhw2+Xhg4UgT3nDC628hw9GLlztYD/WCrb1y8tLu77OeA6UDGFySNEiHEuXTkVg lS5RoudV3l1hKRwB4x+CVTdThJB7MhNmT9hwOVqKRy/3gdSTcIY/ZJm4fQT1FrcnQg+cGa MQQWX3HMJX9cbKo+ijwOsDVokwSc8JCz0duUZTKpulSTvjFq8acfa+DlTSkxiw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b=BOkMdSx0; 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: -3.54 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b=BOkMdSx0; 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: D673EED5B X-Spam-Score: -3.54 X-Migadu-Scanner: scn1.migadu.com X-TUID: xJddzF2ujZzW * 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 | 26 +++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index b7005f0ef1..31f391357d 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@* @@ -34650,11 +34650,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..9f598b2826 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,11 @@ ;;; 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 (gnu services) #:use-module (gnu services base) #:use-module (gnu services shepherd) @@ -252,7 +255,19 @@ (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) + (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 to align with \ +the corresponding swap-space field, please use #f from now on.~%")) + #f) + priority)) (define (zram-device-configuration->udev-string config) "Translate a into a string which can be @@ -278,8 +293,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.34.0