From owner-freebsd-bugs@freebsd.org Tue Jun 2 16:58:53 2020 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DDA7A2F45C4 for ; Tue, 2 Jun 2020 16:58:53 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 49bytP5bN8z4H65 for ; Tue, 2 Jun 2020 16:58:53 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id BDE3E2F4738; Tue, 2 Jun 2020 16:58:53 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BC7352F45C3 for ; Tue, 2 Jun 2020 16:58:53 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49bytP4QVtz4H4S for ; Tue, 2 Jun 2020 16:58:53 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8EA2C20015 for ; Tue, 2 Jun 2020 16:58:53 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 052GwrKd065804 for ; Tue, 2 Jun 2020 16:58:53 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 052GwrNA065803 for bugs@FreeBSD.org; Tue, 2 Jun 2020 16:58:53 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 246940] [wishlist/enhancement, patch incl.]: idle user tasks should be charged as "nice" or "user" CPU time Date: Tue, 02 Jun 2020 16:58:48 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: torsten.eichstaedt@web.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jun 2020 16:58:53 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D246940 Bug ID: 246940 Summary: [wishlist/enhancement, patch incl.]: idle user tasks should be charged as "nice" or "user" CPU time Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: torsten.eichstaedt@web.de Created attachment 215172 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D215172&action= =3Dedit Patch for FreeBSD-12: sys.kern.kern_clock.c.diff Currently idle user tasks are charged as "user" CPU time. 1. This is counter-intuitive. Instead, one would expect the requested behaviour. 2. The chargement of user tasks affects the decisions taken by a CPU freq manager (i.e. powerd(8), sysutils/powerdxx(8) and the according kernel modu= les) and thus can result in great power savings for mobile users, and/or a less noisier system for desktop users, provided the user does not care about the runtime of background tasks, since power managers do not increase CPU freq = on behalve of idle user tasks. 3. The patch might affect the CPU scheduler, please check. I have no clue about this. 4. The patch introduces a new global integer sysctl "kern.cp_time_mode": [value: behaviour; use-case] 1: charge idle threads as "nice" CPU time; suggested as server mode 2: " "idle" CPU time; suggested as mobile/desktop = mode 0/any other: " "user" CPU time; (default); current behaviour I would be interested in how such "static" sysctl's are handled on a SMP system. If "OID_AUTO" results in a per-CPU var, a system could be partitio= ned to have "interesting" behaviour :) Onother question I have is if kernel tasks (other than the idle task itself) could ever be in the idle class. I ran this trivial patch on two laptops for several years w/o problems. There might be implicit assumptions on the CPU scheduling class beeing "use= r" or "nice" in some base system tasks or scripts, though. Suggested application is to switch between "server" and "mobile" mode from /etc/power_profile (I'm willing to patch that, it's trivial) and to allow security.bsd.unprivileged_idprio=3D1. Then a desktop/mobile user can choos= e to run cron(8), sysutils/anacron(8) and his own user background tasks as "idle= ", and enjoy increased battery runtime and a quiter system. How can I add more than one attachment? The patch for FreeBSD 10/11 is slightly different, statclock() was named statclock_cnt() and did not have a comment. With kind regards, Torsten --=20 You are receiving this mail because: You are the assignee for the bug.=