all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ian Eure <ian@retrospec.tv>
To: 68309@debbugs.gnu.org
Cc: Ian Eure <ian@retrospec.tv>
Subject: [bug#68309] [PATCH 1/2] gnu: Add powertop-service-type.
Date: Sat, 13 Jan 2024 16:40:17 -0800	[thread overview]
Message-ID: <20240114004019.5019-1-ian@retrospec.tv> (raw)
In-Reply-To: <20240107212122.21810-1-ian@retrospec.tv>

* 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       | 24 ++++++++++++++++++++++++
 gnu/services/pm.scm | 43 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 811edd0bf7..a48aa655ae 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -34798,6 +34798,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/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@gmail.com>
+;;; Copyright © 2024 Ian Eure <ian@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.")))
+
+\f
+
+;;;
+;;; 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





  parent reply	other threads:[~2024-01-14  0:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-07 21:21 [bug#68309] [PATCH] gnu: Add powertop-service-type Ian Eure
2024-01-08  9:10 ` Mathieu Othacehe
2024-01-13 21:23   ` Ian Eure
2024-01-14  0:40 ` Ian Eure [this message]
2024-01-14  0:40   ` [bug#68309] [PATCH 2/2] gnu: Correct package description Ian Eure
2024-01-17 10:15   ` [bug#68309] [PATCH 1/2] gnu: Add powertop-service-type Mathieu Othacehe
2024-06-01 18:18     ` Ian Eure
2024-06-01 18:15 ` [bug#68309] [PATCH v3] " Ian Eure

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240114004019.5019-1-ian@retrospec.tv \
    --to=ian@retrospec.tv \
    --cc=68309@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.