Bug 100626 - upower relies on /proc/timer_stats, which was always optional and has been removed from recent kernels; busy loop and memory leak
Summary: upower relies on /proc/timer_stats, which was always optional and has been re...
Alias: None
Product: upower
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: high blocker
Assignee: Richard Hughes
QA Contact:
Depends on:
Reported: 2017-04-09 08:58 UTC by Christian Stadelmann
Modified: 2017-04-23 19:23 UTC (History)
0 users

See Also:
i915 platform:
i915 features:

A backtrace from upowerd started from systemd and running into a busy loop (gdb) (65.85 KB, text/plain)
2017-04-09 08:58 UTC, Christian Stadelmann

Description Christian Stadelmann 2017-04-09 08:58:12 UTC
Created attachment 130765 [details]
A backtrace from upowerd started from systemd and running into a busy loop (gdb)

There are a few downstream bugs on upower [1][2], showing that upower fails on kernels which do not have /proc/timer_stats present. This file was always optional (config flag CONFIG_TIMER_STATS) and recently has been removed from the kernel [3][4] at version 4.10, and some distros seem to have the change backported to 4.9 kernels.

Steps to reproduce:
1. open gnome-power-manager or start any other application that triggers calling the up_wakeups_poll_userspace_cb function.

What happens:
The warning from [5] will be printed all the time.

What should happen:
Please do not use this function any more.

Additional info:
When reproducing this bug, I often get a busy loop in upowerd, after I start gnome-power-manager for the second time. See the backtrace attached.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689298
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1427621
[3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dfb4357da6ddbdf57d583ba64361c9d792b0e0b1
[4] https://lkml.org/lkml/2017/2/7/846
[5] https://cgit.freedesktop.org/upower/tree/src/up-wakeups.c#n467
Comment 1 Christian Stadelmann 2017-04-09 09:19:35 UTC
I should add that the busy loop in upowerd happens also after gnome-power-statistics is closed, so upowerd is looping itself, and gnome-power-statistics is not to blame. A result of this loop is a massive memory leak.
Comment 2 Richard Hughes 2017-04-23 19:23:52 UTC
commit 798588a480eaae50368bed75fc78f8314523b2a3
Author: Richard Hughes <richard@hughsie.com>
Date:   Sun Apr 23 20:22:02 2017 +0100

    Do not spin in a loop when /proc/timer_stats cannot be written
    Only set up the polling once the write has succeeded.
    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=100626

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.