From patchwork Sat Jun 1 18:15:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ian Eure X-Patchwork-Id: 65119 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id BA2C427BBEA; Sat, 1 Jun 2024 19:17:09 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E2A3C27BBE9 for ; Sat, 1 Jun 2024 19:17:06 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sDTHh-00058D-EF; Sat, 01 Jun 2024 14:16:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sDTHe-00056Y-CO for guix-patches@gnu.org; Sat, 01 Jun 2024 14:16:50 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sDTHe-00082d-4M for guix-patches@gnu.org; Sat, 01 Jun 2024 14:16:50 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sDTHp-0004kj-Ro for guix-patches@gnu.org; Sat, 01 Jun 2024 14:17:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#68309] [PATCH v3] gnu: Add powertop-service-type. References: <20240107212122.21810-1-ian@retrospec.tv> In-Reply-To: <20240107212122.21810-1-ian@retrospec.tv> Resent-From: Ian Eure Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 01 Jun 2024 18:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68309 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68309@debbugs.gnu.org Cc: Ian Eure Received: via spool by 68309-submit@debbugs.gnu.org id=B68309.171726578118216 (code B ref 68309); Sat, 01 Jun 2024 18:17:01 +0000 Received: (at 68309) by debbugs.gnu.org; 1 Jun 2024 18:16:21 +0000 Received: from localhost ([127.0.0.1]:57379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sDTHA-0004jk-M3 for submit@debbugs.gnu.org; Sat, 01 Jun 2024 14:16:21 -0400 Received: from wfout4-smtp.messagingengine.com ([64.147.123.147]:42195) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sDTH3-0004j4-Nt for 68309@debbugs.gnu.org; Sat, 01 Jun 2024 14:16:19 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id 7EAE21C000AF; Sat, 1 Jun 2024 14:15:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 01 Jun 2024 14:15:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=retrospec.tv; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:message-id:mime-version:reply-to :subject:subject:to:to; s=fm3; t=1717265755; x=1717352155; bh=dM bKW8SE/go6ph/7Ku0UJ85ojxBwwMPZ0lsW+VDxsys=; b=a44ikf6HqvFUQUVFkU vCbCe/9IRDWDbMtvgy9nlBbZVJNdnkyjBuPWSROvwzEOJG/B7WprK2bWO1RV3iTQ 3rGGZgBgC8OTX2XBUWLUVOphzKBYnaq81Uj/oqzE2XXe7jJ9YvcwgMC/zzksL4n0 S2eEJJfDd30Vjgz6WimxcppjXZ9K7lXcbHUYncvqPo4awzXmQ8lJ+gg20GpQ7U+L 0Eto+i9eDGPOTKOzTs+0oID/THL5y2xe0iU9ccpLozRMLqyM2JVDKghVnDaiO887 9ZFwjTEABvpba79pIP/zVxv7wzwQIrn3UnTiDVsjFJQ7HcrbKc8HJwAinvyl1nz1 j65g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1717265755; x=1717352155; bh=dMbKW8SE/go6p h/7Ku0UJ85ojxBwwMPZ0lsW+VDxsys=; b=mGVflGCRC4AgqYG2Gnfbtu5nomVrX dN461n6oWdqYh/Mnk/wE2rcSifSfjBQVsC2XSO9jlK7fOHZ/N9QWABBChkuttYE6 IVcW0rWMjBq9Ik0oci+v3GAhoU90flHTo4Os03YJ6m/yt16xWhJ9DtGuBbPoZ90d gfw4VEgIEOF3SebxFXDvzae9ZuyjTVdqe6jcqRDxn6ErRag38OTKoOJ5dWCzKvhC /mc0L/cjeMb7izSel2dr2BeqeDlwbeFv7jPg3VHWWzK8qzHXgeMz1s/z5CCUMECT Ap7Q2Ho7YT1WHunFc07WyfKBvGUdCb7RiZnS657Kr6MwOKFWtpTydMXwA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdekkedguddvudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofggtgfgsehtke ertdertdejnecuhfhrohhmpefkrghnucfguhhrvgcuoehirghnsehrvghtrhhoshhpvggt rdhtvheqnecuggftrfgrthhtvghrnhepjeeugfehgffffeethedvtdduudethfdvtdefud fhudfgvddvueelgfefhfehhfehnecuffhomhgrihhnpehgnhhurdhorhhgnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihgrnhesrhgvthhroh hsphgvtgdrthhv X-ME-Proxy: Feedback-ID: id9014242:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 1 Jun 2024 14:15:54 -0400 (EDT) From: Ian Eure Date: Sat, 1 Jun 2024 11:15:49 -0700 Message-ID: <20240601181549.16529-1-ian@retrospec.tv> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/pm.scm (powertop-shepherd-service): New variable. * gnu/services/pm.scm (powertop-service-type): New variable. * gnu/services/pm.scm (powertop-configuration): New variable. * doc/guix.texi (Power Management Services): Document powertop-service-type. Change-Id: I1c5ef855526458ad54f62ca6e755da82acce1c4a --- doc/guix.texi | 25 +++++++++++++++++++++++++ gnu/services/pm.scm | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1224104038..031a4e61c2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35375,6 +35375,31 @@ Ignore cpuid check for supported CPU models. @item @code{thermald} (default: @var{thermald}) Package object of thermald. +@cindex powertop +@cindex Power tuning with PowerTOP +@subsubheading PowerTOP + +The @code{(gnu services pm)} module provides a Guix service definition +for PowerTOP. When started, it tunes kernel settings to reduce power +consumption. + +@defvar powertop-service-type +The service type for PowerTOP. No configuration is necessary. When the +service starts, it executes @code{powertop --auto-tune}. + +@lisp +(service powertop-service-type) +@end lisp +@end defvar + +Available @code{powertop-configuration} fields are: + +@deftypevr {@code{powertop-configuration} parameter} package powertop +The PowerTOP package. Defaults to @code{powertop} in the @code{(gnu +packages linux)} module + +@end deftypevr + @end table @end deftp diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm index 47f0bf7812..1793bc873d 100644 --- a/gnu/services/pm.scm +++ b/gnu/services/pm.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2024 Dariqq +;;; Copyright © 2024 Ian Eure ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,6 +19,8 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu services pm) + #:use-module (srfi srfi-1) + #:use-module (ice-9 match) #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix records) @@ -37,7 +40,10 @@ (define-module (gnu services pm) tlp-configuration thermald-configuration - thermald-service-type)) + thermald-service-type + + powertop-configuration + powertop-service-type)) ;;; ;;; power-profiles-daemon @@ -524,3 +530,37 @@ (define thermald-service-type (default-value (thermald-configuration)) (description "Run thermald, a CPU frequency scaling service that helps prevent overheating."))) + + + +;;; +;;; powertop +;;; +;;; Calls `powertop --auto-tune' to reduce energy consumption. + +(define-configuration powertop-configuration + (powertop (package powertop) "PowerTOP package to use.")) + +(define powertop-shepherd-service + (match-lambda + (($ powertop) + (shepherd-service + (documentation "Tune kernel power settings at boot.") + (provision '(powertop powertop-auto-tune)) + (requirement '(user-processes)) + (one-shot? #t) + (start #~(lambda _ + (zero? (system* #$(file-append powertop "/sbin/powertop") + "--auto-tune")))))))) + +(define powertop-service-type + (service-type + (name 'powertop) + (extensions + (list + (service-extension shepherd-root-service-type + (compose list powertop-shepherd-service)))) + (compose concatenate) + (default-value (powertop-configuration)) + (description "Tune power-related kernel parameters to reduce energy + consumption.")))