Opened 11 years ago

Closed 11 years ago

#2416 closed defect (fixed)

100% CPU usage with serial device (receiver)

Reported by: tigtex Owned by:
Priority: blocker Component: General
Severity: high Keywords: serial, cpu, usage
Cc: wurstwasserflocke@… Sensitive: no



5667 and newer

Issue Description

100% cpu usage when trying to use a serial device (for example, a rs232 sssp compatible receiver)

When the issue occurs

After updating from revision 5666 to 5667, the cpu usage hits the 100% if you try to use a serial device/reciever. This issue still happens with revision 6427 (latest revision at this time)

How the issue is reproducable

1) Use any revision after 5667

2) Use this oscam.conf file, no need for any other files
logfile = stdout
device = root@/dev/ttyS0

3) start oscam and check cpu usage (it should be with 100% usage)

Complete -d 255 log attached using the above oscam.conf

Attachments (6)

cpu_usage.txt (2.0 KB ) - added by tigtex 11 years ago.
ticket log
process_input-poll.patch (702 bytes ) - added by oopepe 11 years ago.
oscam.log (2.7 KB ) - added by tigtex 11 years ago.
serial errors
oscam-5666.log (41.7 KB ) - added by tigtex 11 years ago.
working oscam version
oscam_6608_patched.log (40.8 KB ) - added by tigtex 11 years ago.
latest svn + 100% cpu patch
PatchForSerialClient_r6613.patch (498 bytes ) - added by Sulge 11 years ago.

Download all attachments as: .zip

Change History (19)

by tigtex, 11 years ago

Attachment: cpu_usage.txt added

ticket log

comment:1 by tigtex, 11 years ago

I've tested this on different computers, with serial (native) and usb to serial adapters. I don't even need to power on the serial device in order to cause the 100% cpu usage. I can provide more help if needed, minimal C skills, advanced linux user.

comment:2 by tigtex, 11 years ago

Priority: criticalblocker

2 weeks later: Build 6480, same problem.
Since oscam doesn't work at all with any rs232 receiver, I'm going to increase this ticket priority.

comment:3 by oopepe, 11 years ago

Hi, the problem seems to be in process_input in oscam.c. The function is using poll() without a timeout. This is causing your cpu load.
I attached a patch which uses the timeout value from process_input for the poll() function.

Why is there a timeout of 0 for poll() at all?

Last edited 11 years ago by oopepe (previous) (diff)

by oopepe, 11 years ago

Attachment: process_input-poll.patch added

comment:4 by oopepe, 11 years ago

Cc: wurstwasserflocke@… added

by tigtex, 11 years ago

Attachment: oscam.log added

serial errors

comment:5 by tigtex, 11 years ago

Thanks for the patch oopepe, that solves the 100% cpu usage but serial is unusable.
oscam.log attached.
serial keeps re-initializing and receives incomplete requests (build 5666 works just fine).

comment:6 by oopepe, 11 years ago

Ok, please post a full debug log of 5666 and a full debug log of a current version with my patch applied. When you do the logs wait until some (un)successful commands have been written to the serial device and then close oscam so the log doesnt get too big.

comment:7 by Doom, 11 years ago

Thank you oopepe ! This patch works more 100% CPU usage using serial module (SSSP mode)

No more 100% CPU usage but after some requests, Oscam hangs :(

Last edited 11 years ago by Doom (previous) (diff)

by tigtex, 11 years ago

Attachment: oscam-5666.log added

working oscam version

by tigtex, 11 years ago

Attachment: oscam_6608_patched.log added

latest svn + 100% cpu patch

comment:8 by tigtex, 11 years ago

Sorry about the delay. I've posted 2 logs from the working oscam version and the latest svn.
Also, on the latest version, the cpu usage was at 100% everytime it recieved/sent any information using the serial device.
I hope it helps somehow.
This time I won't be away, I'll check this bug report every day.

comment:9 by Sulge, 11 years ago

From oscam.log we see that the function init_oscam_ser is called many times:

2012/03/05 16:48:15 B##$F040 c serial: initialized (auto@/dev/ttyUSB0)
2012/03/05 16:48:30 A17$$F0 c serial: initialized (auto@/dev/ttyUSB0)

a new threads are created and so on so on

Probably this is the cause of the problem. The function init_oscam_ser should be called only once at oscam start.

This weekend I do not have time to analyze why this is called many times.

Maybe in the next ....

comment:10 by Sulge, 11 years ago

Please retest adding following patch

comment:11 by tigtex, 11 years ago

I noticed that the patch is now upstream. So I decided to build the current trunk without patchs. As expected, the 100% cpu usage bug is there because the 1st patch wasn't uploaded yet.
After patching the current trunk with this everything works. No more serial restarts and no more 100% cpu usage!
So, please check if the process_input-poll.patch can be added and I'll close this bug after that :)
Thank you

comment:12 by theparasol, 11 years ago

Missed that one ;)

Try again with 6617!

comment:13 by tigtex, 11 years ago

Resolution: fixed
Status: newclosed

Ok, everything is working :) Marking as fixed

Note: See TracTickets for help on using tickets.