Linux High CPU usage on Xubuntu 19.10 while Idle
#16
That's entirely bad solution.

run: sudo udevadm monitor

on a terminal next to kodi

on the terminal and see if you get events all the time. The only reason:

Code:
void CPeripheralBusUSB::Process(void)
{
  bool bUpdated(false);
  ScanForDevices();
  while (!m_bStop)
  {
    bUpdated = WaitForUpdate();
    if (bUpdated && !m_bStop)
      ScanForDevices();
  }
}

Can eat CPU is that WaitForUpdate does not block. So find out, what happens in this method.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#17
I did say that was a last resort didn't I?

Here is the output of that command when kodi is idle https://paste.kodi.tv/anolirodok

It does seem to be making a lot of calls. Mind you Kodi was only open for a few minutes.
Reply
#18
Thanks. That's the problem in fact:

Quote:KERNEL[4028.932671] change   /devices/virtual/thermal/thermal_zone1 (thermal)
KERNEL[4028.932776] change   /devices/virtual/thermal/thermal_zone1 (thermal)
KERNEL[4028.932807] change   /devices/virtual/thermal/thermal_zone1 (thermal)
KERNEL[4028.932831] change   /devices/virtual/thermal/thermal_zone1 (thermal)
KERNEL[4028.933575] change   /devices/virtual/thermal/thermal_zone2 (thermal)

Those events constantly wakeup kodi's udev trigger.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#19
I checked on my Thinkpad and added some CPU load. I don't see all those change events. Please post your dmesg as well. Something is odd in your kernel / configuration.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#20
Try this patch:

Code:
From fa3edee5350e68886473188891838ee849c873cf Mon Sep 17 00:00:00 2001
From: fritsch <[email protected]>
Date: Sat, 11 Jan 2020 18:03:24 +0100
Subject: [PATCH] CPeripheralBusUSB: Workaround virtual thermalzone devices
 constantly waking us up

---
 .../platform/linux/peripherals/PeripheralBusUSBLibUdev.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/xbmc/platform/linux/peripherals/PeripheralBusUSBLibUdev.cpp b/xbmc/platform/linux/peripherals/PeripheralBusUSBLibUdev.cpp
index 07c45a3e96..35bb64aa2c 100644
--- a/xbmc/platform/linux/peripherals/PeripheralBusUSBLibUdev.cpp
+++ b/xbmc/platform/linux/peripherals/PeripheralBusUSBLibUdev.cpp
@@ -8,6 +8,7 @@
 
 #include "PeripheralBusUSBLibUdev.h"
 #include "peripherals/Peripherals.h"
+#include <unistd.h>
 extern "C" {
 #include <libudev.h>
 }
@@ -194,7 +195,13 @@ void CPeripheralBusUSB::Process(void)
   {
     bUpdated = WaitForUpdate();
     if (bUpdated && !m_bStop)
+    {
       ScanForDevices();
+      // make sure that pseudo devices don't constantly
+      // wake us up
+      if (!m_bStop)
+        usleep(500 * 1000);
+    }
   }
 }
 
-- 
2.20.1
 
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#21
CPeripheralBusUSB has a major design flaw regarding multi threading:
Quote:All functions listed here are thread-agnostic and only a single specific thread may operate on a given object during its entire lifetime. It's safe to allocate multiple independent objects and use each from a specific thread in parallel. However, it's not safe to allocate such an object in one thread, and operate or free it from any other, even if locking is used to ensure these threads don't operate on it at the very same time.

source: https://www.freedesktop.org/software/sys...budev.html

Kodi code violates this rule. It allocates the udev context in one thread and uses it in a different one. As a result many funny things may occur.
Reply
#22
For the device Scanning this is easily solved (also I don't think that's the reason for the high cpu Load).

The bigger bugger is the "PerformDeviceScan" that is even called from Addon-World.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#23
I've never compile patches before, Could you point me to some resources/tutorials. I don't want to find the wrong one.

Here is the output you asked for. https://pastebin.com/Y6uCxYZB
Reply
#24
Yes: https://github.com/xbmc/xbmc/blob/master....Ubuntu.md - give it some time, it's quite hard for starters.

If you can build and run this normal version applying above is just a: git am path-to-above-patch.patch
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#25
That patch works. Unfortunately both Plex and Trakt add-ons brake on the nightly build, which is what I think the master branch gives me. I'll try using the Leia branch next.
Reply
#26
Leia branch won't build. First, build configuration can't find python, which I fixed, but then ffmpeg gets interrupted when building. Will have to try again tomorrow.
Any way I can just compile that file and put into the correct folder for my current kodi install?
Reply
#27
No. For Leia: https://github.com/xbmc/xbmc/blob/Leia/d....Ubuntu.md

Make sure to not skip anything from this document, it would have installed Python if you would have followed it.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#28
This "patch" does not fix the root cause, hence useless. My system even crashes in PeripheralBusUSBLibUdev when hotplugging or removing an USB Mic. No useful info from debugger. Internal state of libudev seems to be corrupted.
Reply
#29
watch gallery
Reply
#30
(2020-01-12, 09:18)FernetMenta Wrote: This "patch" does not fix the root cause, hence useless. My system even crashes in PeripheralBusUSBLibUdev when hotplugging or removing an USB Mic. No useful info from debugger. Internal state of libudev seems to be corrupted.

Please keep things separate. User's setup has a bogus thermal virtual sensor that even spams udev adm monitor and causes the poll to wake up directly, therefore causing high kodi load.

Your issue is separate to exactly this, while you are perfectly right about the misusage in another thread.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply

Logout Mark Read Team Forum Stats Members Help
High CPU usage on Xubuntu 19.10 while Idle0