[systemd-devel] watchdog feature highly ineffecient / using too much CPU

Michael Biebl mbiebl at gmail.com
Sat Sep 13 05:48:03 PDT 2014


2014-09-13 13:10 GMT+02:00 David Herrmann <dh.herrmann at gmail.com>:
> So, lets look at the bluetoothd code:
>
>         watchdog_usec = getenv("WATCHDOG_USEC");
>         seconds = atoi(watchdog_usec) / (1000 * 1000);
>
>         watchdog = g_timeout_add_seconds_full(G_PRIORITY_HIGH,
>                                         seconds / 2,
>                                         watchdog_callback,
>                                         NULL, NULL);
>
> If WATCHDOG_USEC is smaller than 2,000,000 (2s), then "seconds" is <=1
> and thus "seconds / 2" is 0. Thus, bluetoothd sends watchdog
> notifications without any timeout.
>
> Two solutions:
> 1) Don't set such watchdog values for bluetoothd.
> 2) Fix bluetoothd to use "usec" instead of seconds.

Thanks for the detailed analysis, David.
This indeed looks like a bug in bluetooth. Especially since you can
break bluetooth completely by setting e.g. WatchdogSec=0..

Will report this to the bluez upstream maintainer


More information about the systemd-devel mailing list