Merge ~joalif/ubuntu/+source/systemd:lp1806012 into ubuntu/+source/systemd:ubuntu/eoan-devel

Proposed by Ioanna Alifieraki
Status: Needs review
Proposed branch: ~joalif/ubuntu/+source/systemd:lp1806012
Merge into: ubuntu/+source/systemd:ubuntu/eoan-devel
Diff against target: 66 lines (+30/-22)
1 file modified
debian/extra/set-cpufreq (+30/-22)
Reviewer Review Type Date Requested Status
Steve Langasek (community) Disapprove
Dimitri John Ledkov Pending
Ubuntu Server Dev import team Pending
Review via email: mp+367469@code.launchpad.net

Description of the change

This change adds flexibility to the 'ondemand' service;
it provides the user with the option to configure the cpufreq governor through
/etc/default/cpufrequtils file.

In addition, there is an existing bug when cpufrequtils package is installed;
both 'ondemad' service and cpufrequtils race to set the governor.
In case cpufrequtils is installed and user has chosen a different
governor (by editing the /etc/default/cpufrequtils file) than the one selected
by ondemand service, the ondemand service will overwrite user's settings and
stick to its selection.

With this change the ondemand service will first check if the /etc/default/cpufrequtils
files exist and in case there is a governor defined, the ondemand service will select
the defined governor.
In case there is no such file, ondemand service will behave as it does currently.
The /etc/default/cpufrequtils file is chosen on purpose to provide
compatibility between ondemand service and cpufrequtils package.

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :

I do not agree with the rationale for this change. /etc/default files are not a particularly good interface overall, and the use cases presented are all addressed by disabling the systemd unit completely instead of supporting selection of different governors via this unit.

review: Disapprove
Revision history for this message
Steve Langasek (vorlon) wrote :

I should say that respecting the setting for cpufrequtils is sensible, but I think this should be accomplished by making this unit a no-op in the presence of that file, not having ondemand reapply the same policy.

Revision history for this message
Dan Streetman (ddstreet) wrote :

> I should say that respecting the setting for cpufrequtils is sensible

cpufrequtils has not seen updates since trusty:

$ rmadison cpufrequtils
 cpufrequtils | 007-2 | precise/universe | source, amd64, armel, armhf, i386, powerpc
 cpufrequtils | 008-1 | trusty/universe | source, amd64, arm64, armhf, i386, powerpc, ppc64el
 cpufrequtils | 008-1 | xenial/universe | source, amd64, arm64, armhf, i386, powerpc, ppc64el, s390x
 cpufrequtils | 008-1build1 | bionic/universe | source, amd64, arm64, armhf, i386, ppc64el, s390x
 cpufrequtils | 008-1build1 | cosmic/universe | source, amd64, arm64, armhf, i386, ppc64el, s390x
 cpufrequtils | 008-1.1 | disco/universe | source, amd64, arm64, armhf, i386, s390x
 cpufrequtils | 008-1.1 | eoan/universe | source, amd64, arm64, armhf, i386, s390x

additionally, refusing to make 'ondemand' configurable means anyone wanting to configure their system has to both install cpufrequtils (which is unsupported for UA customers, since it's universe) as well as disabling 'ondemand'.

Seeing the future, it's quite possible that debian (and/or us) simply drop cpufrequtils at some point.

> /etc/default files are not a particularly good interface overall

however, they are widely used for configuration in debian and ubuntu.

> use cases presented are all addressed by disabling the systemd unit

not without *also* installing the cpufrequtils package. Simply disabling ondemand will leave the governor at the kernel-compiled default.

> but I
> think this should be accomplished by making this unit a no-op in the presence
> of that file, not having ondemand reapply the same policy.

option 1) change cpu-setfreq to be a noop when /etc/default/cpufrequtils is detected, AND install cpufrequtils
option 2) change cpu-setfreq to honor /etc/default/cpufrequtils selection, with *or* without cpufrequtils installed

the end result is the same; the only difference is your design requires cpufrequtils to be installed. Is there a reason that design is better than this merge proposal?

and of course:

option 3) change cpu-setfreq to be a noop when /etc/default/cpufrequtils is detected, but without cpufrequtils installed -> this leads to the governor being completely unset, defaulting to the kernel compile default. Probably not exactly expected.

Revision history for this message
Steve Langasek (vorlon) wrote :

/etc/default/cpufrequtils is a conffile of the cpufrequtils package; I think it is reasonable to respect it if present but that this should be implemented by delegating to the cpufrequtils package in this case.

Is there an actual requirement from a user for setting the governor to a value that is neither the kernel default nor the ondemand behavior?

Revision history for this message
Robie Basak (racb) wrote :

> additionally, refusing to make 'ondemand' configurable means anyone wanting to configure their system has to both install cpufrequtils (which is unsupported for UA customers, since it's universe) as well as disabling 'ondemand'.

Another option would be to disable ondemand and add a systemd service unit to do what you want instead. For user-known hardware, it'd be pretty much a one-liner, right? Is there any reason this wouldn't be viable?

Revision history for this message
Trent Lloyd (lathiat) wrote :

I had a quick look at what other distributions are currently doing.

From what I can see it seems that Fedora and Arch are currently using the 'cpupower' tool (from linux-tools-common on Ubuntu, kernel-tools on Fedora) and then have a systemd service which relatively simply kicks off a call to 'sudo cpupower -c all frequency-set -g powersave' or similar. That systemd service isn't upstream in the kernel though.

RHEL seems to primarily use tuned to drive the change, which has it's own script to manually twiddle the /sys/devices/system/cpu/*/cpufreq/scaling_governor files.

Revision history for this message
Ioanna Alifieraki (joalif) wrote :

The kernel default governor is performance.
The 'ondemand' service will choose first interactive, then ondemand and finally
powersave.
(I use 'ondemand' to refer to the systemd service and differentiate it from
ondemand governor.)

Of course depending on the cpufreq driver in use there may be more governors
available such as conservative, userspace and schedutils.

The governor that will be selected depends on :
1) The processor (Intel, ARM etc.)
2) The BIOS settings (OS control, Dynamic etc.)
3) The cpufreq driver used (intel_pstate, pcc-cpufreq, acpi-cpufreq)
4) The available cpufreq governors and the behaviour of 'ondemand' service.

1 and 2 will define the cpufreq driver that will be used (3).
Based on the driver there will be some available governors and 'ondemand' service
will select one of them.

'Ondemand' behaviour or the kernel default suffice when we assume an intel
processor, with intel_pstate driver enabled.
In this case we have available only 2 governors : powersave and performance.
If 'ondemand' is enabled the powersave will be selected, if disabled the kernel
defaults to performance.
(Please note that the powersave and performance governors of intel_pstate are
very different from the acpi-cpufreq ones.)

If we don't run on an intel processor (e.g. ARM) or even if we run on intel
with intel_pstate disabled, then with 'ondemand' enabled the selected governor
will be ondemand and when disabled will be performance.
However, in that case you have more options (powersave, userspace, conservative,
scheduitls).
The current behaviour of 'ondemand' service does not allow you to use any other
governor.

> Is there an actual requirement from a user for setting the governor to a value
that is neither the kernel default nor the ondemand behavior?

I have a laptop with an ARM based CPU.
I want powersave governor because I am low on battery.
Neither enabling nor disabling 'ondemand' service will do the job.

To sum up, currently 'ondemand' is working fine for the average case (intel CPU+intel_pstate driver).
However, this is not the only case.
Modifying 'ondemand' service to make the right decision for every possible
combination of 1,2,3 is way too complicated and maybe impossible given that different
users have different demands for performance and power saving (this is after all the rational behind having all these governors).

This MP does NOT change the default behaviour of 'ondemand'.
It just provides more options for the users.
Plus it resolves the compatibility issues with cpufrequtils.
I can see benefits here and no harm.
And, yes, there are other workarounds (disabling 'ondemand', adding one more service
to do what the user wants etc.).
However I don't see why this is simpler than having 'ondemand' service configurable.

Unmerged commits

fc23499... by Ioanna Alifieraki

Ondemand - add option to configure governor from /etc/default/cpufrequtils

e9ff766... by Dimitri John Ledkov

Import patches-unapplied version 240-6ubuntu5 to ubuntu/disco-proposed

Imported using git-ubuntu import.

Changelog parent: bdacee5e974e81f7ccf243a4c702c25981f08c5b

New changelog entries:
  * systemd-stable: cherrypick many bugfixes from the v240-stable branch.
    Includes many documentation fixes, memory safety (use after free, read
    overruns, etc), networkd wireguard fixes, POSIX ACL fix which is preventing adm
    group from reading journals (LP: #1824342), journal dropping caches
    improvement, fixes regressions in udevadm / machinectl command line parsing.
    Files:
    - debian/patches/Add-missing-dash-to-all-option-in-the-timedatectl-man-pag.patch
    - debian/patches/Add-note-about-transactions-being-genereated-independentl.patch
    - debian/patches/Change-job-mode-of-manager-triggered-restarts-to-JOB_REPL.patch
    - debian/patches/Fix-omission-in-docs.patch
    - debian/patches/Log-the-job-being-merged.patch
    - debian/patches/NEWS-document-deprecation-of-PermissionsStartOnly-in-v240.patch
    - debian/patches/NEWS-retroactively-describe-.include-deprecation.patch
    - debian/patches/Update-systemd-system.conf.xml.patch
    - debian/patches/basic-prioq-add-prioq_peek_item.patch
    - debian/patches/core-Fix-EOPNOTSUPP-emergency-action-error-string.patch
    - debian/patches/core-Fix-return-argument-check-for-parse_emergency_action.patch
    - debian/patches/core-mount-do-not-add-Before-local-fs.target-or-remote-fs.patch
    - debian/patches/core-mount-move-static-function-earlier-in-file.patch
    - debian/patches/curl-util-fix-use-after-free.patch
    - debian/patches/ethtool-Make-sure-advertise-is-actually-set-when-autonego.patch
    - debian/patches/journal-avoid-buffer-overread-when-locale-name-is-too-lon.patch
    - debian/patches/journal-limit-the-number-of-entries-in-the-cache-based-on.patch
    - debian/patches/journald-periodically-drop-cache-for-all-dead-PIDs.patch
    - debian/patches/machinectl-fix-argument-index-in-error-log.patch
    - debian/patches/man-Fix-a-typo-in-systemd.exec.xml.patch
    - debian/patches/man-fix-reference.patch
    - debian/patches/man-fix-volume-num-of-journalctl.patch
    - debian/patches/man-update-DefaultDependency-in-systemd.mount-5.patch
    - debian/patches/netlink-set-maximum-size-of-WGDEVICE_A_IFNAME.patch
    - debian/patches/network-make-Link-and-NetDev-always-have-the-valid-poiter.patch
    - debian/patches/network-unset-Network-manager-when-loading-.network-file-.patch
    - debian/patches/network-wireguard-rename-and-split-set_wireguard_interfac.patch
    - debian/patches/networkd-wait-for-kernel-to-reply-ipv6-peer-address.patch
    - debian/patches/nspawn-ignore-SIGPIPE-for-nspawn-itself.patch
    - debian/patches/pager-improve-english-a-bit.patch
    - debian/patches/pid1-fix-cleanup-of-stale-implicit-deps-based-on-proc-sel.patch
    - debian/patches/procfs-util-expose-functionality-to-query-total-memory.patch
    - debian/patches/pull-fix-invalid-error-check.patch
    - debian/patches/shared-Revert-commit-49fe5c099-in-parts-for-function-pars.patch
    - debian/patches/shared-dissect-image-make-sure-that-we-don-t-truncate-dev.patch
    - debian/patches/test-execute-unset-HOME-before-testing.patch
    - debian/patches/udev-do-logging-before-setting-variables-to-NULL.patch
    - debian/patches/udev-val-may-be-NULL-use-strempty.patch
    - debian/patches/udevadm-info-a-should-enumerate-sysfs-attributes-not-envs.patch
    - debian/patches/udevd-use-worker_free-on-failure-in-worker_new.patch
    - debian/patches/units-make-sure-initrd-cleanup.service-terminates-before-.patch
    - debian/patches/wait-online-do-not-fail-if-we-receive-invalid-messages.patch
    https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=2b3db732ba7e5418d45ca42884e8d075189f2724
  * Only test that gdm3 comes up on amd64. Stalls on other arches.
    File: debian/tests/control
    https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=97cb13685dfb353045c449ec5d6d1df60f661079
  * tests/storage: make the test more resilient.
    Skip if the scsi_debug module is not available (like on custom kernels). Do not
    fail the tests if removing the module fail, at the end of the test run.
    File: debian/tests/storage
    https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=c08dcb1ffe372acd3a21496758a1984ff78dcdd4

bdacee5... by Dimitri John Ledkov

Import patches-unapplied version 240-6ubuntu4 to ubuntu/disco-proposed

Imported using git-ubuntu import.

Changelog parent: eea1f082a3812e659540f1758ecd19f95a25a00c

New changelog entries:
  * pam-systemd: use secure_getenv() rather than getenv()
    CVE-2019-3842
    File: debian/patches/pam-systemd-use-secure_getenv-rather-than-getenv.patch
    https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=f3291e9e8c3eafd0c8921cb26a0d5ee0fd563b3c
  * core: queue jobs on uninstall to generate PropertiesChanged signal.
    (LP: #1816812)
    File: debian/patches/core-when-we-uninstall-a-job-add-unit-to-dbus-queue.patch
    https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=241deca98fb9a0f1ba9a6ba781f738fb31a3bd80

eea1f08... by Balint Reczey

Import patches-unapplied version 240-6ubuntu3 to ubuntu/disco-proposed

Imported using git-ubuntu import.

Changelog parent: 9b1d7bb026cfa8ec55fb668bb494ac6321c88772

New changelog entries:
  * virt: detect WSL environment as a container (LP: #1816753)
  * debian/control: Update Vcs-{Browser|Git} to Ubuntu's packaging repository
  * debian/gbp.conf: Set tag format to ubuntu/*

9b1d7bb... by Ioanna Alifieraki <email address hidden>

Import patches-unapplied version 240-6ubuntu2 to ubuntu/disco-proposed

Imported using git-ubuntu import.

Changelog parent: 85344509ee5b92779693739b0c8b12180b8a3ff1

New changelog entries:
  * d/p/network-remove-routing-policy-rule-from-foreign-rule.patch
  * d/p/network-do-not-remove-rule-when-it-is-requested-by-e.patch
    - Fix RoutingPolicyRule does not apply correctly (LP: #1818282)

8534450... by Dimitri John Ledkov

Import patches-unapplied version 240-6ubuntu1 to ubuntu/disco-proposed

Imported using git-ubuntu import.

Changelog parent: c63029d7d61802bc0f6d3f5002b712df1532bab1

New changelog entries:
  * Release to ubuntu.

c63029d... by Martin Pitt

Import patches-unapplied version 240-6 to debian/sid

Imported using git-ubuntu import.

Changelog parent: 0bd28e4cef70407fe61fd7d8f332c8c65f438d7d

New changelog entries:
  * High urgency as this fixes a vulnerability.
  [ Felipe Sateler ]
  * Reenable pristine-tar in gbp.conf.
    The pristine-tar bug has been fixed, so we can use it again.
    This reverts commit 9fcfbbf6fea15eacfa3fad74240431c5f2c3300e.
  * d/watch: add version mangle to transform -rc to ~rc.
    Upstream has started releasing rcs, so let's account for that
  * Fix comment about why we disable hwclock.service.
    Systemd nowadays doesn't do it itself because the kernel does it on its
    own when necessary, and when not, it is not safe to save the hwclock (eg,
    there is no certainty the system clock
    is correct)
  * udev: Backport upstream preventing mass killings when not running under
    systemd (Closes: #918764)
  [ Dimitri John Ledkov ]
  * debian/tests/storage: improve cleanups.
    On fast ppc64el machines, cryptsetup start job may not complete by the
    time tearDown is executed. In that case stop, causes to simply cancel the
    start job without actually cleaning up the dmsetup node. This leads to
    failing subsequent test as it no longer starts with a clean device. Thus
    ensure the systemd-cryptsetup unit is started, before stopping it.
    Also rmmod scsi_debug module at the end, to allow re-running the test in a
    loop.
  * debian/tests/upstream: Mark TEST-13-NSPAWN-SMOKE as flakey.
  * debian/tests/control: add socat to upstream tests for pull #11591
  * Blacklist TEST-10-ISSUE-2467 #11706
  * debian/tests/storage: fix for LUKS2 and avoid interactive password
    prompts.
  [ Martin Pitt ]
  * udevadm: Fix segfault with subsystem-match containing '/'
    (Closes: #919206)
  * sd-bus: if we receive an invalid dbus message, ignore and proceed
  * sd-bus: enforce a size limit on D-Bus object paths.
    This avoids accessing/modifying memory outside of the allocated stack
    region by sending specially crafted D-Bus messages with very large object
    paths.
    Vulnerability discovered by Chris Coulson <email address hidden>,
    patch provided by Riccardo Schirone <email address hidden>.
    (CVE-2019-6454)

0bd28e4... by Martin Pitt

Import patches-unapplied version 240-5 to debian/sid

Imported using git-ubuntu import.

Changelog parent: 0945b6d4802a3bd9d4c21ca78a4880ff34e6a109

New changelog entries:
  [ Felipe Sateler ]
  * Revert interface renaming changes. (Closes: #919390)
  [ Martin Pitt ]
  * process-util: Fix memory leak (Closes: #920018)

0945b6d... by Michael Biebl

Import patches-unapplied version 240-4 to debian/sid

Imported using git-ubuntu import.

Changelog parent: 2feba195831b9d191e0e42321c2ff9f8de2b5748

New changelog entries:
  [ Benjamin Drung ]
  * Fix shellcheck issues in initramfs-tools scripts
  [ Michael Biebl ]
  * Import patches from v240-stable branch (up to f02b5472c6)
    - Fixes a problem in logind closing the controlling terminal when using
      startx. (Closes: #918927)
    - Fixes various journald vulnerabilities via attacker controlled alloca.
      (CVE-2018-16864, CVE-2018-16865, Closes: #918841, Closes: #918848)
  * sd-device-monitor: Fix ordering of setting buffer size.
    Fixes an issue with uevents not being processed properly during coldplug
    stage and some kernel modules not being loaded via "udevadm trigger".
    (Closes: #917607)
  * meson: Stop setting -fPIE globally.
    Setting -fPIE globally can lead to miscompilations on certain
    architectures. Instead use the b_pie=true build option, which was
    introduced in meson 0.49. Bump the Build-Depends accordingly.
    (Closes: #909396)

2feba19... by Michael Biebl

Import patches-unapplied version 240-3 to debian/sid

Imported using git-ubuntu import.

Changelog parent: fdd4947ab1ae5ee0f6760d8618de8dde3c5b3924

New changelog entries:
  * udev.init: Trigger add events for subsystems.
    Update the SysV init script and mimic the behaviour of the initramfs and
    systemd-udev-trigger.service which first trigger subsystems and then
    devices during the coldplug stage.
  * udevadm: Refuse to run trigger, control, settle and monitor commands in
    chroot (Closes: #917633)
  * network: Set link state configuring before setting addresses.
    Fixes a crash in systemd-networkd caused by an assertion failure.
    (Closes: #918658)
  * libudev-util: Make util_replace_whitespace() read only len characters.
    Fixes a regression where /dev/disk/by-id/ names had additional
    underscores.
  * man: Update color of journal logs in DEBUG level (Closes: #917948)
  * Remove old state directory of systemd-timesyncd on upgrades.
    Otherwise timesyncd will fail to update the clock file if it was created
    as /var/lib/private/systemd/timesync/clock.
    This was the case when the service was using DynamicUser=yes which it no
    longer does in v240. (Closes: #918190)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/extra/set-cpufreq b/debian/extra/set-cpufreq
index 4ffe126..59da0be 100755
--- a/debian/extra/set-cpufreq
+++ b/debian/extra/set-cpufreq
@@ -5,32 +5,40 @@ set -eu
5FIRSTCPU=`cut -f1 -d- /sys/devices/system/cpu/online`5FIRSTCPU=`cut -f1 -d- /sys/devices/system/cpu/online`
6AVAILABLE="/sys/devices/system/cpu/cpu$FIRSTCPU/cpufreq/scaling_available_governors"6AVAILABLE="/sys/devices/system/cpu/cpu$FIRSTCPU/cpufreq/scaling_available_governors"
7DOWN_FACTOR="/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor"7DOWN_FACTOR="/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor"
8CPUFREQUTILS="/etc/default/cpufrequtils"
9GOVERNOR=""
10GOVS="interactive ondemand powersave"
811
9[ -f $AVAILABLE ] || exit 012[ -f $AVAILABLE ] || exit 0
1013
11read governors < $AVAILABLE14if [ -f $CPUFREQUTILS ]; then
12case $governors in15 echo "/etc/default/cpufrequtils file is present, will follow its policy"
13 *interactive*)16 . $CPUFREQUTILS
14 GOVERNOR="interactive"17fi
15 break18
16 ;;19GOVS="$GOVERNOR $GOVS"
17 *ondemand*)20GOVERNOR=""
18 GOVERNOR="ondemand"21
19 case $(uname -m) in22read available_govs < $AVAILABLE
20 ppc64*)23for g in $GOVS
21 SAMPLING=10024do
25 for a in $available_govs
26 do
27 if [ "$g" = "$a" ] ; then
28 GOVERNOR=$g
29 break 2
30 fi
31 done
32done
33
34if [ "$GOVERNOR" = "ondemand" ] ; then
35 case $(uname -m) in
36 ppc64*)
37 SAMPLING=100
22 ;;38 ;;
23 esac39 esac
24 break40fi
25 ;;41
26 *powersave*)
27 GOVERNOR="powersave"
28 break
29 ;;
30 *)
31 exit 0
32 ;;
33esac
3442
35[ -n "${GOVERNOR:-}" ] || exit 043[ -n "${GOVERNOR:-}" ] || exit 0
3644

Subscribers

People subscribed via source and target branches