Bug 10459 - budget_av: High CPU load due to CI slot polling
Summary: budget_av: High CPU load due to CI slot polling
Status: CLOSED CODE_FIX
Alias: None
Product: v4l-dvb
Classification: Unclassified
Component: ttpci (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: ttpci
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-16 11:56 UTC by Robert Schedel
Modified: 2008-05-23 13:16 UTC (History)
0 users

See Also:
Kernel Version: 2.6.24.4
Subsystem:
Regression: ---
Bisected commit-id:


Attachments

Description Robert Schedel 2008-04-16 11:56:01 UTC
Failing kernel version: 2.6.24.4
Distribution: Gentoo (reproducable with gentoo kernel as well as vanilla kernel 2.6.24.4!)
Hardware Environment: Athlon 64X2 3800+, Satelco Easywatch DVB-C (1894:002c), no CI/CAM
Software Environment: Linux kernel 2.6.24.4 SMP x86_64, budget_av module
Problem Description:
After the budget_av driver module is loaded (even without any DVB  application), the CPU load average in 'top' rises to ~1, but in top no active tasks are found. After unloading the driver, the load decreases again to ~0.

Steps to reproduce:
- Precondition: budget_av card (e.g. Satelco EasyWatch DVB-C) without CI inserted in PCI slot
- modprobe budget_av
- Watch CPU load in top

Please note: The high CPU load is not only a statistical issue due to the kernel accounting. It would put at least some unnecessary stress on PCI and CPU and e.g. also has the effect that cron tasks with idle guard condition would not start, so on midterm this should be fixed.

Additional information:
1) lspci output:
00:09.0 Multimedia controller: Philips Semiconductors SAA7146 (rev 01)
        Subsystem: KNC One Unknown device 002c
        Flags: bus master, medium devsel, latency 64, IRQ 16
        Memory at fb500000 (32-bit, non-prefetchable) [size=512]
        Kernel driver in use: budget_av
        Kernel modules: budget-av

2) uptime output when issue occurs (load can differ between ~0,7-1):
 10:57:32 up  1:14,  1 user,  load average: 0.75, 0.45, 0.19

3) kernel information:
Linux 2.6.24.4 #1 SMP Fri Apr 11 10:07:01 CEST 2008 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ AuthenticAMD GNU/Linux

4) Syslog output when loading budget_av module:
saa7146: register extension 'budget_av'.
ACPI: PCI Interrupt 0000:00:09.0[A] -> GSI 16 (level, low) -> IRQ 16
saa7146: found saa7146 @ mem ffffc2000001e000 (revision 1, irq 16) (0x1894,0x002c).
saa7146 (0): dma buffer size 192512
DVB: registering new adapter (Satelco EasyWatch DVB-C MK3)
adapter failed MAC signature check
encoded MAC from EEPROM was ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff
KNC1-0: MAC addr = 00:09:[...]
DVB: registering frontend 0 (Philips TDA10023 DVB-C)...
budget-av: ci interface initialised.

5) Full lsmod output after budget_av has been loaded:
Module                  Size  Used by
tda10023                6532  1
budget_av              20736  0
saa7146_vv             49856  1 budget_av
videobuf_dma_sg        12676  1 saa7146_vv
videobuf_core          17348  2 saa7146_vv,videobuf_dma_sg
firmware_class          8768  1 budget_av
budget_core            10436  1 budget_av
dvb_core               83436  2 budget_av,budget_core
saa7146                16904  3 budget_av,saa7146_vv,budget_core
ttpci_eeprom            2496  1 budget_core
ip6table_filter         2752  1
xt_state                2560  2
powernow_k8            13600  1

Please report when additional information is required.
Comment 1 Robert Schedel 2008-04-16 11:57:08 UTC
Preanalysis:
Displaying the blocked tasks during high load with Alt-SysRq-W shows that the kdvb-ca kernel thread seems to be accounted as blocked when it polls for the CI slot status:
---------------------------------------------------
SysRq : Show Blocked State
task                        PC stack   pid father
kdvb-ca-0:0   D 0000000100d78984     0  2046      2
ffff81007ee73c70 0000000000000046 0000000000000000 0000000000000008
0000000000000800 0000000000000000 0000000000000286 ffff81007bebe080
ffff81007f8d47e0 ffff81007ee73c80 ffff81007ed91a00 0000000100d78984
Call Trace:
[<ffffffff80241da6>] __mod_timer+0xb6/0xd0
[<ffffffff804e52ff>] schedule_timeout+0x5f/0xd0
[<ffffffff80241890>] process_timeout+0x0/0x10
[<ffffffff80241dd6>] msleep+0x16/0x30
[<ffffffff880a0189>] :saa7146:saa7146_wait_for_debi_done+0x159/0x260
[<ffffffff880bba3a>] :budget_core:ttpci_budget_debiread+0x6a/0x140
[<ffffffff880d1cfb>] :budget_av:ciintf_poll_slot_status+0xbb/0x1c0
[<ffffffff880aa800>] :dvb_core:dvb_ca_en50221_thread+0x0/0xa10
[<ffffffff880a9339>] :dvb_core:dvb_ca_en50221_check_camstatus+0x59/0x100
[<ffffffff880aa8ba>] :dvb_core:dvb_ca_en50221_thread+0xba/0xa10
[<ffffffff8022f221>] update_curr+0x61/0xb0
[<ffffffff8022f221>] update_curr+0x61/0xb0
[<ffffffff802341e6>] dequeue_task_fair+0x46/0x80
[<ffffffff8022f79d>] __dequeue_entity+0x3d/0x50
[<ffffffff804e4a7e>] thread_return+0x3d/0x52f
[<ffffffff80288da4>] filp_close+0x54/0x90
[<ffffffff880aa800>] :dvb_core:dvb_ca_en50221_thread+0x0/0xa10
[<ffffffff8024d48b>] kthread+0x4b/0x80
[<ffffffff8020ca48>] child_rip+0xa/0x12
[<ffffffff8024d440>] kthread+0x0/0x80
[<ffffffff8020ca3e>] child_rip+0x0/0x12
---------------------------------------------------

Enabling debug traces shows that polling for the PSR in function  'saa7146_wait_for_debi_done_sleep' constantly times out after 250x1ms sleeps:

 > saa7146: saa7146_wait_for_debi_done_sleep(): saa7146 (0): 
saa7146_wait_for_debi_done_sleep timed out while waiting for transfer completion

Increasing the 250ms did not avoid the timeout. And as I understood from previous v4l-dvb list mails, this timeout is normal when no CI/CAM is connected to the DEBI. However, for me the high frequency polling does not make sense if someone does not plan to plug in a CI/CAM.

When commenting out two lines in 'dvb_ca_en50221_thread_update_delay' to increase the polling timer for slotstate NONE from 100ms (!) to 60s, the CPU load went down to 0. So this is some kind of workaround for me.
Comment 2 Robert Schedel 2008-04-16 12:08:53 UTC
Ticket has been created for tracking.

Previous mail threads with some technical discussion:
- http://www.linuxtv.org/pipermail/linux-dvb/2008-April/025248.html (current status as described above for kernel 2.6.24, some technical discussion, no final solution yet)
- http://www.mail-archive.com/linux-dvb@linuxtv.org/msg22094.html (similar report against older kernel, driver code has changed since)
- http://www.mail-archive.com/linux-dvb@linuxtv.org/msg25556.html (similar report against older kernel, driver code has changed since)
Comment 3 Robert Schedel 2008-05-23 13:09:56 UTC
Bugfix has been included in official kernel 2.6.26-rc3:
> V4L/DVB (7830): dvb_ca_en50221: Fix High CPU load in 'top' due to budget_av
> slot polling

Therefore, for me this bug is resolved now.
Comment 4 Robert Schedel 2008-05-23 13:14:44 UTC
Bugfix was already verified successfully by me, see the following mail thread for details:
http://www.linuxtv.org/pipermail/linux-dvb/2008-April/025248.html
Comment 5 Robert Schedel 2008-05-23 13:16:14 UTC
Included in 2.6.26-rc3 -> CLOSED.

Note You need to log in before you can comment on or make changes to this bug.