Kodi Community Forum

Full Version: XBPyThread context switches
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all

I am new to XBMC so : congratulations to all people having contributed
to this HTPC system!


I built bleeding edge gentoo intel XBMC with nvidia graphics and see
xbmc.bin running 100% CPU on one core, even when nothing happens. I
have read a little bit and I have adapted algorithmdirtyregions
nofliptimeout in advancedsettings. It does not change behaviour.


vmstat shows -MANY- interrupts and context switches per second:

# vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
...
1 0 0 248120 265336 2933444 0 0 0 0 71403 142516 25 1 74 0

...



pidstat points to XBPyThread

# pidstat -wt | egrep '(__XBPyThread|cswch)'
03:57:49 UID TGID TID cswch/s nvcswch/s Command
03:57:49 1000 - 4437 7073.50 0.03 |__XBPyThread
03:57:49 1000 - 4440 0.73 9.33 |__XBPyThread
03:57:49 1000 - 4441 3898.50 0.01 |__XBPyThread


powertop also spots xbmc.bin with similar amount of wakeups

Summary: 7982.1 wakeups/second, 0.0 GPU ops/seconds, 0.0 VFS ops/sec and 55.2% CPU use

Usage Events/s Category Description
548.7 ms/s 7862.5 Process /usr/lib64/xbmc/xbmc.bin


FWIW: /proc/interrupts reports "rescheduling"

# watch -tdn1 cat /proc/interrupts
RES: 15097764 10079972 12758152 4994793 Rescheduling interrupts


Is this a known issue?


Thanks!
debug log
Hi wsnipex

Thanks for encouraging me to debug.

Here is the link to the log:

http://xbmclogs.com/show.php?id=85647

Thanks
fwiw

I verified https://help.ubuntu.com/community/Resche...Interrupts as to exclude

- ACPI and APIC problems
- misconfigured hardware

Thanks
another fwiw

I built HEAD git xbmc

It also shows the thousands of Rescheduling interrupts per second

Thanks
I think you are looking for the red herring with the context switches, Xbmc is a media player, so audio/video and addons could cause this. E.g. your log shows plenty of json events.

start with GIT master and a clean ~/.xbmc
use confluence, set dirty regions to 3, vsync ON
then check cpu usage when xbmc is idle on the home screen.
Hi wsnipex

Thanks for kind follow up and for instructions.

I tried (both 12.2 and git master) with requested settings. But
there are always ~10000 context switches per second. I also tried
without graphics hw accelleration. The graphics hw is nVidia.

The system has a i3 Intel CPU with dual core and
hyperthreading. Linux shows 4 CPUs.

AFAIK the rescheduling interrupts are meant to help spread threads
evenly over CPUs. Recall I also tried with ACPI turned off in
kernel. Always same: one CPU runs ~100%.

Note from pidstat that 2 XBPyThread threads show to be context
switching. It looks as if they are kind to one another as to give
room to CPU.

But there seem to be some issues:

- there is nothing to do so why keep on interrupting for rescheduling
- only one CPU is used instead of multiple

The system runs fine but one core runs 100% (and gets warmer than the
other one).

Have a nice day
I'll try to play a bit with kernel cpu and scheduler configurations, like, for example, disabling SMT (Hyperthreading) scheduler support

Keep you informed
After completely disabling SMP(multi CPU), SMT(hyperthread) and
MC(multi core) from kernel config, regardless of PREEMPT NONE or
VOLUNTARY, remaining single CPU stays 100% high, but, of course, no
more reschedule interrupt driven context switches.

strace of xbmc.bin revealed many attempts to open Addons15.db-wal and
Addons15.db-journal, so I found
http://forum.xbmc.org/showthread.php?tid=137960 fixed in
http://trac.xbmc.org/ticket/14122

I applied changeset github 9cf9efa47b1ea6e14cb4bc80636c51bd5aa6823c
to 12.2, but still 100% CPU (I did not yet go find out further why),
even on single CPU. It makes sense because master git version has
changeset integrated and shows same behaviour as 12.2.
As already said, the reason for 100% CPU must be something else.
Please provide a debug log with the setup I outlined in my previous post.
Hi wsnipex,

Actually, I had not cleaned ~/.xbmc yet as part of testing...

Doing so brings down CPU usage to 5% ! Thanks !

I will now reconfigure XBMC step by step and see what gives after each step.

have a nice day
then the culprit is one of the addons
Thanks wsnipex,

I reinstalled addons and reconfigured xbmc, CPU usage stays low.
I guess some 'beginners' mistake must have caused the issue.

One thing, I am trying to get PVR working with VDR and a DVB-T stick. But the (beta) addons seem to hang XBMC.
Perhaps some experiments left the setup in an unstable state.

I appreciate all help!
if you run xbmc git, you also need pvr addons from git. The API changed a few days ago.
Hi wsnipex

As before: thanks for all your help.

For now, I am going to stick to xbmc 12.2 stable trying to figuring out what it can do.

have a nice day