Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU usage after capture on RPi Zero running showmewebcam #27

Open
okawo80085 opened this issue Dec 12, 2021 · 1 comment
Open

High CPU usage after capture on RPi Zero running showmewebcam #27

okawo80085 opened this issue Dec 12, 2021 · 1 comment

Comments

@okawo80085
Copy link

okawo80085 commented Dec 12, 2021

Problem Description:
The /opt/uvc-webcam/uvc-gadget -l -p 21 -b process keeps running and using more then 20% CPU after the host system finished capturing from the v4l2 device. CPU usage from top when connecting to the debug shell on the RPi Zero:

Before host started capture (idle):

Mem: 33600K used, 375412K free, 1516K shrd, 1108K buff, 16028K cached
CPU:   0% usr   2% sys   0% nic  97% idle   0% io   0% irq   0% sirq
Load average: 0.07 0.04 0.00 2/43 334
  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
  326   278 root     R     1880   0%   3% /opt/uvc-webcam/uvc-gadget -l -p 21 -b
  334   274 root     R     2756   1%   0% top
    1     0 root     S     7564   2%   0% {systemd} /sbin/init
   64     1 root     S     7520   2%   0% /usr/lib/systemd/systemd-udevd
   60     1 root     S     7104   2%   0% /usr/lib/systemd/systemd-journald
   93     1 dbus     S     5008   1%   0% /usr/bin/dbus-daemon --system --addres
   94     1 root     S     2756   1%   0% -sh
  274     1 root     S     2756   1%   0% -sh
  278     1 root     S     2628   1%   0% {start-webcam.sh} /bin/sh /opt/uvc-web
    8     2 root     SW       0   0%   0% [ksoftirqd/0]
   14     2 root     SW       0   0%   0% [kcompactd0]
   44     2 root     IW<      0   0%   0% [kworker/0:1H-kb]
  332     2 root     IW       0   0%   0% [kworker/0:0-eve]
  333     2 root     IW       0   0%   0% [kworker/0:1-eve]
    2     0 root     SW       0   0%   0% [kthreadd]
    5     2 root     IW       0   0%   0% [kworker/u2:0-ev]
    6     2 root     IW<      0   0%   0% [mm_percpu_wq]
    7     2 root     SW       0   0%   0% [rcu_tasks_trace]
    9     2 root     SW       0   0%   0% [kdevtmpfs]
   10     2 root     IW<      0   0%   0% [netns]

When host is capturing stream (streaming):

Mem: 34476K used, 374536K free, 1516K shrd, 1108K buff, 16028K cached
CPU:   5% usr  67% sys   0% nic  26% idle   0% io   0% irq   0% sirq
Load average: 0.70 0.28 0.10 2/43 335
  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
  335     2 root     RW       0   0%  35% [kworker/0:0-eve]
  326   278 root     S     2832   1%  29% /opt/uvc-webcam/uvc-gadget -l -p 21 -b
   39     2 root     SW<      0   0%   4% [vchiq-slot/0]
  277     2 root     IW       0   0%   3% [kworker/u2:2-mm]
  334   274 root     R     2756   1%   2% top
    8     2 root     SW       0   0%   0% [ksoftirqd/0]
    1     0 root     S     7564   2%   0% {systemd} /sbin/init
   64     1 root     S     7520   2%   0% /usr/lib/systemd/systemd-udevd
   60     1 root     S     7104   2%   0% /usr/lib/systemd/systemd-journald
   93     1 dbus     S     5008   1%   0% /usr/bin/dbus-daemon --system --addres
   94     1 root     S     2756   1%   0% -sh
  274     1 root     S     2756   1%   0% -sh
  278     1 root     S     2628   1%   0% {start-webcam.sh} /bin/sh /opt/uvc-web
   14     2 root     SW       0   0%   0% [kcompactd0]
   44     2 root     IW<      0   0%   0% [kworker/0:1H-kb]
  333     2 root     IW       0   0%   0% [kworker/0:1-eve]
   40     2 root     SW<      0   0%   0% [vchiq-recy/0]
   42     2 root     IW       0   0%   0% [kworker/0:2-eve]
    2     0 root     SW       0   0%   0% [kthreadd]
    5     2 root     IW       0   0%   0% [kworker/u2:0-ev]

When host finished capturing (should be idle again):

Mem: 33756K used, 375256K free, 1516K shrd, 1108K buff, 16028K cached
CPU:   9% usr  21% sys   0% nic  68% idle   0% io   0% irq   0% sirq
Load average: 0.55 0.31 0.12 1/43 335
  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
  326   278 root     S     1880   0%  26% /opt/uvc-webcam/uvc-gadget -l -p 21 -b
  334   274 root     R     2756   1%   3% top
    8     2 root     SW       0   0%   0% [ksoftirqd/0]
    1     0 root     S     7564   2%   0% {systemd} /sbin/init
   64     1 root     S     7520   2%   0% /usr/lib/systemd/systemd-udevd
   60     1 root     S     7104   2%   0% /usr/lib/systemd/systemd-journald
   93     1 dbus     S     5008   1%   0% /usr/bin/dbus-daemon --system --addres
   94     1 root     S     2756   1%   0% -sh
  274     1 root     S     2756   1%   0% -sh
  278     1 root     S     2628   1%   0% {start-webcam.sh} /bin/sh /opt/uvc-web
  335     2 root     IW       0   0%   0% [kworker/0:0-eve]
   39     2 root     SW<      0   0%   0% [vchiq-slot/0]
  277     2 root     IW       0   0%   0% [kworker/u2:2-mm]
   42     2 root     IW       0   0%   0% [kworker/0:2-eve]
   14     2 root     SW       0   0%   0% [kcompactd0]
   44     2 root     IW<      0   0%   0% [kworker/0:1H-kb]
  333     2 root     IW       0   0%   0% [kworker/0:1-eve]
   40     2 root     SW<      0   0%   0% [vchiq-recy/0]
    2     0 root     SW       0   0%   0% [kthreadd]
    5     2 root     IW       0   0%   0% [kworker/u2:0-ev]

Expected behavior:
1-5% CPU usage by /opt/uvc-webcam/uvc-gadget -l -p 21 -b on idle after the host system finishes capturing from the v4l2 device.

Additional Notes:
The issue goes away if i restart the RPi, however that is not fitting my use case. In my use case the RPi is plugged in indefinitely into a VR system, wasting more power on idle is the last thing i want.

Host OS: Ubuntu 20.04.3 LTS
Board Running showmewebcam : Raspberry Pi Zero

uname -a from the board: Linux piwebcam 5.10.11 #1 Mon Nov 8 06:25:02 UTC 2021 armv6l GNU/Linux

Would be nice to see some sort of work around/solution to this! If its possible to enforce that state via shell commands that works for me too!

@okawo80085
Copy link
Author

Originally reported on showmewebcam issue tracker in issue#178

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant