GNU bug report logs - #68309
[PATCH] gnu: Add powertop-service-type.

Previous Next

Package: guix-patches;

Reported by: Ian Eure <ian <at> retrospec.tv>

Date: Sun, 7 Jan 2024 21:23:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#68309: closed ([PATCH] gnu: Add powertop-service-type.)
Date: Sat, 23 Nov 2024 15:10:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 23 Nov 2024 16:09:09 +0100
with message-id <874j3yq962.fsf <at> gnu.org>
and subject line Re: [bug#68309] [PATCH v3] gnu: Add powertop-service-type.
has caused the debbugs.gnu.org bug report #68309,
regarding [PATCH] gnu: Add powertop-service-type.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
68309: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68309
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Ian Eure <ian <at> retrospec.tv>
To: guix-patches <at> gnu.org
Cc: Ian Eure <ian <at> retrospec.tv>
Subject: [PATCH] gnu: Add powertop-service-type.
Date: Sun,  7 Jan 2024 13:21:21 -0800
* 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.
* gnu/packages/linux.scm (powertop): Correct package description.
* doc/guix.texi (Power Management Services): Document powertop-service-type.

Change-Id: I1c5ef855526458ad54f62ca6e755da82acce1c4a
---
 doc/guix.texi          | 24 +++++++++++++++++++++++
 gnu/packages/linux.scm |  2 +-
 gnu/services/pm.scm    | 43 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index a648a106b3..e95ae140f2 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -34755,6 +34755,30 @@ 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 defvar
+
+Available @code{powertop-configuration} fields are:
+
+@deftypevr {@code{powertop-configuration} parameter} package powertop
+The PowerTOP package.  Defaults to @code{powertop}.
+
+@end deftypevr
+
 @end table
 @end deftp
 
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 0fe64bacf3..c53d8f82bd 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -3634,7 +3634,7 @@ (define-public powertop
     (inputs
      (list kmod libnl ncurses pciutils zlib))
     (home-page "https://01.org/powertop/")
-    (synopsis "Analyze power consumption on Intel-based laptops")
+    (synopsis "Analyze power consumption on x86-based laptops")
     (description
      "PowerTOP is a Linux tool to diagnose issues with power consumption and
 power management.  In addition to being a diagnostic tool, PowerTOP also has
diff --git a/gnu/services/pm.scm b/gnu/services/pm.scm
index 3daf484cc1..13a153ab1d 100644
--- a/gnu/services/pm.scm
+++ b/gnu/services/pm.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe <at> gmail.com>
+;;; Copyright © 2024 Ian Eure <ian <at> retrospec.tv>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -17,6 +18,8 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (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)
@@ -31,7 +34,10 @@ (define-module (gnu services pm)
             tlp-configuration
 
             thermald-configuration
-            thermald-service-type))
+            thermald-service-type
+
+            powertop-configuration
+            powertop-service-type))
 
 (define (uglify-field-name field-name)
   (let ((str (symbol->string field-name)))
@@ -466,3 +472,38 @@ (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-configuration> 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.")))
-- 
2.41.0



[Message part 3 (message/rfc822, inline)]
From: Ludovic Courtès <ludo <at> gnu.org>
To: Ian Eure <ian <at> retrospec.tv>
Cc: 68309-done <at> debbugs.gnu.org
Subject: Re: [bug#68309] [PATCH v3] gnu: Add powertop-service-type.
Date: Sat, 23 Nov 2024 16:09:09 +0100
[Message part 4 (text/plain, inline)]
Hi Ian,

Ian Eure <ian <at> retrospec.tv> skribis:

> * 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

Applied with the tweaks below.

Thanks!

Ludo’.

[Message part 5 (text/x-patch, inline)]
diff --git a/doc/guix.texi b/doc/guix.texi
index d421d422a8..454dd66c18 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -35800,13 +35800,14 @@ Power Management Services
 @item @code{thermald} (default: @var{thermald})
 Package object of thermald.
 
-@cindex powertop
-@cindex Power tuning with PowerTOP
+@cindex PowerTOP
+@cindex power consumption 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.
+The @code{(gnu services pm)} module also provides a service definition
+for @uref{https://01.org/powertop/, PowerTOP}, a power consumption
+analysis and tuning tool.  When started, it tunes Linux kernel settings
+to reduce power consumption.
 
 @defvar powertop-service-type
 The service type for PowerTOP.  No configuration is necessary.  When the

This bug report was last modified 236 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.