From patchwork Sun Jan 7 21:21:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ian Eure X-Patchwork-Id: 58459 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 DB09A27BBEA; Sun, 7 Jan 2024 21:23:20 +0000 (GMT) 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 9105F27BBE9 for ; Sun, 7 Jan 2024 21:23:18 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMabj-0002pC-RX; Sun, 07 Jan 2024 16:22:59 -0500 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 1rMabh-0002oo-H7 for guix-patches@gnu.org; Sun, 07 Jan 2024 16:22:57 -0500 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 1rMabh-0000iX-92 for guix-patches@gnu.org; Sun, 07 Jan 2024 16:22:57 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rMabm-0004tp-J7 for guix-patches@gnu.org; Sun, 07 Jan 2024 16:23:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68309] [PATCH] gnu: Add powertop-service-type. Resent-From: Ian Eure Original-Sender: "Debbugs-submit" Resent-CC: , guix-patches@gnu.org Resent-Date: Sun, 07 Jan 2024 21:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68309 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68309@debbugs.gnu.org Cc: Ian Eure , ( , Christopher Baines , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Raghav Gururajan , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice , jgart X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: ( , Christopher Baines , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Raghav Gururajan , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice , jgart Received: via spool by submit@debbugs.gnu.org id=B.170466252318750 (code B ref -1); Sun, 07 Jan 2024 21:23:02 +0000 Received: (at submit) by debbugs.gnu.org; 7 Jan 2024 21:22:03 +0000 Received: from localhost ([127.0.0.1]:34031 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rMaao-0004sL-VS for submit@debbugs.gnu.org; Sun, 07 Jan 2024 16:22:03 -0500 Received: from lists.gnu.org ([2001:470:142::17]:38210) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rMaan-0004rs-Bo for submit@debbugs.gnu.org; Sun, 07 Jan 2024 16:22:01 -0500 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 1rMaac-0002iV-9Z for guix-patches@gnu.org; Sun, 07 Jan 2024 16:21:50 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rMaaa-0000Xh-25 for guix-patches@gnu.org; Sun, 07 Jan 2024 16:21:50 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 38DF65C122F; Sun, 7 Jan 2024 16:21:45 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sun, 07 Jan 2024 16:21:45 -0500 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=fm1; t=1704662505; x=1704748905; bh=Lk BAkNAoPU8qGkNgRcp5oABL3L3fpCu+Zc7z3MxBMrw=; b=SYg+tPkHKkAJ+FWOYE WPB+A3bWsOAUQMEQ6SksK0FN7qeRU8xCpakhaAPc8tfpqyt96hP2XXtc6pPFj1Sk yjsG5Yp1pG4W2eJfnJGgg3aBFW/irb19sKF7Y0t3LBUhst06x2iAssBLS/yOPplm 1+Y8u5ZYFAuJbOBMgX6ivpFJDq0Kbosmc8OBNYXjPSt9egGJqyqHJkPtUs8AIL3+ gSVm/CA0t/nGfQNMT4nybxTh/1/+HuwPMLZ1J0sFIjCEVbMkNMP6g1CPn1r8I/wU x3NsJuGYW3VCXtaFSVWIMKCBRWPxG0KIjbBfPVITzJmRKDChhQ+RsIUFOZe/Ql59 jEUA== 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=fm2; t=1704662505; x=1704748905; bh=LkBAkNAoPU8qG kNgRcp5oABL3L3fpCu+Zc7z3MxBMrw=; b=xnKkGtsQnVkLeeBrdTgGMy6iBz67y PTqV65eF8SIej/THu+zgqHojkCiM0jIqbk3JfI8IrLdVPA17+nyeBOE+Xq1uY0y/ Ku5+fRwdcuz/LY/Z2EkH2skWh2XLgqMiUHvpSV6ovpkpw1G3hW+abn1Ajy4p0O0X v29uUK5TnJiWHaFQ3bSZIEDliuk3trZ/gyV0wq7zNVbh0QIOtB+NlydjUMlcc04w /Z6Zm+PnRfqhgHmkQmKU4+7JaSL27mBRxk3fAv4fxPgQWIfS4N0MM/lVlBQ8QnC9 HR6oLS/YWrBYpYNyuE1R3u3FpAGtDBRrdHV1XpRYO0sA4i4D59xaruH2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdehgedgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffogggtgfesthekre dtredtjeenucfhrhhomhepkfgrnhcugfhurhgvuceoihgrnhesrhgvthhrohhsphgvtgdr thhvqeenucggtffrrghtthgvrhhnpeelhffgteelveejjeelffekhfehgfehtdefgfduvd duieffjedugedvhfevjeetteenucffohhmrghinheptddurdhorhhgpdhgnhhurdhorhhg necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihgrnh esrhgvthhrohhsphgvtgdrthhv X-ME-Proxy: Feedback-ID: id9014242:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Jan 2024 16:21:44 -0500 (EST) From: Ian Eure Date: Sun, 7 Jan 2024 13:21:21 -0800 Message-ID: <20240107212122.21810-1-ian@retrospec.tv> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=66.111.4.25; envelope-from=ian@retrospec.tv; helo=out1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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. * 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 +;;; Copyright © 2024 Ian Eure ;;; ;;; This file is part of GNU Guix. ;;; @@ -17,6 +18,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) @@ -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) + (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.")))