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

Marcel Holtmann marcel at holtmann.org
Sat Sep 13 09:57:59 PDT 2014


Hi Michael,

>> 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..

setting WatchdogSec=0 should disable that feature (as described in the manpage). Which means that systemd should never give us the environment variable WATCHDOG_USEC in the first place. Are you saying that systemd does that. In that case that is a systemd bug.

Regards

Marcel



More information about the systemd-devel mailing list