2011-01-28 14:28:47     Random loading problem with ffmpeg

Document created by Aaronwu Employee on Aug 26, 2013
Version 1Show Document
  • View in full screen mode

2011-01-28 14:28:47     Random loading problem with ffmpeg

Cedric Marin (FRANCE)

Message: 97734   

 

Hi everybody,

 

 

 

We work with the uClinux2010R1-RC5 distribution on a CM-BF548 from Bluetechnix plugged on a customized board. When we start ffmpeg after loading the kernel, all is OK (ffmpeg captures video from V4L driver, compress it into the specific requested format an stores the result into a SD Card with ext2 filesystem).

 

However, after performing a forced filesystem checking of SD Card using 'e2fsck -p /dev/mmcblck0p1' command, we notice that ffmpeg failed to allocate memory for libavcodec. We do not understand the problem : the free memory is of 40MB, no other user process runs in concuence and so no fragmentaton is possible...

 

In the forum, we also found information related to lack of cache L1 and investigated in this direction. But if problem was associated to a cache problem, ffmpeg would never work !

 

Finally, when we wait for one minute (after checking SD Card's fs) and retry to launch ffmpeg. It work again !

 

We though that memory was automatically freed when a process stops and we do not understand why a fragmentation problem occurs after the fs checking... is anybody can help us ?

 

Thanks in advance.

 

Cedric

QuoteReplyEditDelete

 

 

2011-01-28 15:05:52     Re: Random loading problem with ffmpeg

Mike Frysinger (UNITED STATES)

Message: 97735   

 

post the actual error you're seeing

 

QuoteReplyEditDelete

 

 

2011-01-31 11:23:29     Re: Random loading problem with ffmpeg

Cedric Marin (FRANCE)

Message: 97810   

 

Hi Mike,

 

Thanks for your answer and sorry for the delay...

 

Please find the core dump in the following :

 

ffmpeg -f video4linux -r 2 -s 720x576 -i /dev/video0 /tmp/test.flv

ffmpeg: page allocation failure. order:11, mode:0xd0

Hardware Trace:

   0 Target : <0x00225798> { _dump_stack + 0x0 }

     Source : <0x00132fae> { ___alloc_pages_nodemask + 0x386 } CALL pcrel

   1 Target : <0x00132fae> { ___alloc_pages_nodemask + 0x386 }

     Source : <0x00225894> { _printk + 0x14 } RTS

   2 Target : <0x00225890> { _printk + 0x10 }

     Source : <0x0010df1e> { _vprintk + 0x162 } RTS

   3 Target : <0x0010df12> { _vprintk + 0x156 }

     Source : <0xffa00c3e> { __common_int_entry + 0xca } RTI

   4 Target : <0xffa00bdc> { __common_int_entry + 0x68 }

     Source : <0xffa00a2c> { _return_from_int + 0x58 } RTS

   5 Target : <0xffa00a2c> { _return_from_int + 0x58 }

     Source : <0xffa00a02> { _return_from_int + 0x2e } IF !CC JUMP pcrel

   6 Target : <0xffa009d4> { _return_from_int + 0x0 }

     Source : <0xffa00bd8> { __common_int_entry + 0x64 } JUMP.L

   7 Target : <0xffa00bd6> { __common_int_entry + 0x62 }

     Source : <0xffa00380> { _asm_do_IRQ + 0x60 } RTS

   8 Target : <0xffa00378> { _asm_do_IRQ + 0x58 }

     Source : <0x001114d6> { __local_bh_enable + 0x3a } RTS

   9 Target : <0x0011149c> { __local_bh_enable + 0x0 }

     Source : <0x00111af4> { ___do_softirq + 0xa4 } JUMP.L

  10 Target : <0x00111aec> { ___do_softirq + 0x9c }

     Source : <0x00111ae0> { ___do_softirq + 0x90 } IF CC JUMP pcrel

  11 Target : <0x00111ad2> { ___do_softirq + 0x82 }

     Source : <0x0012cf70> { _rcu_bh_qs + 0x14 } RTS

  12 Target : <0x0012cf5c> { _rcu_bh_qs + 0x0 }

     Source : <0x00111ace> { ___do_softirq + 0x7e } JUMP.L

  13 Target : <0x00111ac6> { ___do_softirq + 0x76 }

     Source : <0x0012d7e0> { _rcu_process_callbacks + 0x30 } RTS

  14 Target : <0x0012d7dc> { _rcu_process_callbacks + 0x2c }

     Source : <0x0012d67e> { _rcu_do_batch + 0x12a } RTS

  15 Target : <0x0012d676> { _rcu_do_batch + 0x122 }

     Source : <0x0012d566> { _rcu_do_batch + 0x12 } IF CC JUMP pcrel

Stack info:

SP: [0x02b47dac] <0x02b47dac> /* kernel dynamic memory */

FP: (0x02b47eec)

Memory from 0x02b47da0 to 02b48000

02b47da0: 000000d0  02b47dac  00000000 [002a179c] 00132fb2  02049080  00000000  000200d0

02b47dc0: 02049260  0000000b  000000d0  00000001  00000042  002a0d70  00000000  02b46008

02b47de0: 00000010  00000050  00000040  02b46000  02b46000  01000000  000200d0  002a17a0

02b47e00: 00000800  00000000  02049080  00000000  00000040  00000010  00000000  002a0d70

02b47e20: 00000000  00000000  00000000  002a0d70  02797fb0  0013b018  0045b000  027c2cfc

02b47e40: 027c2cfc  0000000b  00000073  00000000  0045a424  000003f7  00000000  027974b0

02b47e60: 00000000  027c2be8  00000022  02797fb0  0013b37e  00000000  027c2cfc  00000000

02b47e80: 00000003  00000073  00000000  0045a424  037dfa48  0013fbc2  0045a424  00000004

02b47ea0: 00000022  00000000  02b47eb0  000003f7  00000004  037dfa48  0013b6fc  00000000

02b47ec0: 0045a424  03d5abe0  02b46000  00000000  00000022  00000003  00001000  00000000

02b47ee0: 00000000  00000003  00000022 (00000000)<ffa0088e> 0013b6b8  000000c0  00000000

02b47f00: ffffe000  00000000  ffffffff  02abdfef  02049080  00000001  00000022  ffffffff

02b47f20: 00000000  027ca82e  00008000  00000000  00000000  02b48000  027ca82e  027ca82e

02b47f40: 027ca45c  ffa00e24  02000020  027cadc5  036dd8c1  027cadc2  036dd8be  00000000

02b47f60: 00000000  00000000  00000000  00000000  00000000  00000000  7ffff000  000000c0

02b47f80: 00000137  00000000  00000000  00000000  00000000  0000005b  00001802  00000001

02b47fa0: 000000b4  00000001  00000002  00000fff  000092f4  037df944  037dfa48  02b04054

02b47fc0: 02b454f8  03d5abe0  02b45504  02b04000  000000c0  fec00000  00000000  00000000

02b47fe0: ffffffff  00000022  00000003  0045a424  00000000  00000000  000000c0  00000006

Return addresses in stack:

   frame  1 : <0xffa0088e> { _system_call + 0x6a }

Mem-Info:

DMA per-cpu:

CPU    0: hi:    0, btch:   1 usd:   0

active_anon:0 inactive_anon:0 isolated_anon:0

active_file:0 inactive_file:3 isolated_file:0

unevictable:3785 dirty:1 writeback:0 unstable:0

free:8886 slab_reclaimable:125 slab_unreclaimable:325

mapped:0 shmem:0 pagetables:0 bounce:0

DMA free:35544kB min:1000kB low:1248kB high:1500kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:12kB unevictable:15140kB isolated(anon):0kB isolated(file):0kB present:62992kB mlocked:0kB dirty:4kB writeback:0kB mapped:0kB shmem:0kB slab_reclaimable:500kB slab_unreclaimable:1300kB kernel_stack:160kB pagetables:0kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no

lowmem_reserve[]: 0 0 0

DMA: 22*4kB 12*8kB 16*16kB 13*32kB 12*64kB 9*128kB 10*256kB 9*512kB 5*1024kB 6*2048kB 2*4096kB 0*8192kB 0*16384kB 0*32768kB = 35544kB

3788 total pagecache pages

15872 pages RAM

818 pages reserved

3668 pages shared

2480 pages non-shared

Allocation of length 4564004 from process 174 (ffmpeg) failed

DMA per-cpu:

CPU    0: hi:    0, btch:   1 usd:   0

active_anon:0 inactive_anon:0 isolated_anon:0

active_file:0 inactive_file:3 isolated_file:0

unevictable:3785 dirty:1 writeback:0 unstable:0

free:8886 slab_reclaimable:125 slab_unreclaimable:325

mapped:0 shmem:0 pagetables:0 bounce:0

DMA free:35544kB min:1000kB low:1248kB high:1500kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:12kB unevictable:15140kB isolated(anon):0kB isolated(file):0kB present:62992kB mlocked:0kB dirty:4kB writeback:0kB mapped:0kB shmem:0kB slab_reclaimable:500kB slab_unreclaimable:1300kB kernel_stack:160kB pagetables:0kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no

lowmem_reserve[]: 0 0 0

DMA: 22*4kB 12*8kB 16*16kB 13*32kB 12*64kB 9*128kB 10*256kB 9*512kB 5*1024kB 6*2048kB 2*4096kB 0*8192kB 0*16384kB 0*32768kB = 35544kB

3788 total pagecache pages

ffmpeg:582: can't map '/usr/lib/libavcodec.so.52'

ffmpeg: page allocation failure. order:11, mode:0xd0

Hardware Trace:

   0 Target : <0x00225798> { _dump_stack + 0x0 }

     Source : <0x00132fae> { ___alloc_pages_nodemask + 0x386 } CALL pcrel

   1 Target : <0x00132fae> { ___alloc_pages_nodemask + 0x386 }

     Source : <0x00225894> { _printk + 0x14 } RTS

   2 Target : <0x00225890> { _printk + 0x10 }

     Source : <0x0010df1e> { _vprintk + 0x162 } RTS

   3 Target : <0x0010df12> { _vprintk + 0x156 }

     Source : <0xffa00c3e> { __common_int_entry + 0xca } RTI

   4 Target : <0xffa00bdc> { __common_int_entry + 0x68 }

     Source : <0xffa00a2c> { _return_from_int + 0x58 } RTS

   5 Target : <0xffa00a2c> { _return_from_int + 0x58 }

     Source : <0xffa00a02> { _return_from_int + 0x2e } IF !CC JUMP pcrel

   6 Target : <0xffa009d4> { _return_from_int + 0x0 }

     Source : <0xffa00bd8> { __common_int_entry + 0x64 } JUMP.L

   7 Target : <0xffa00bd6> { __common_int_entry + 0x62 }

     Source : <0xffa00380> { _asm_do_IRQ + 0x60 } RTS

   8 Target : <0xffa00378> { _asm_do_IRQ + 0x58 }

     Source : <0x001114d6> { __local_bh_enable + 0x3a } RTS

   9 Target : <0x0011149c> { __local_bh_enable + 0x0 }

     Source : <0x00111af4> { ___do_softirq + 0xa4 } JUMP.L

  10 Target : <0x00111aec> { ___do_softirq + 0x9c }

     Source : <0x00111ae0> { ___do_softirq + 0x90 } IF CC JUMP pcrel

  11 Target : <0x00111ad2> { ___do_softirq + 0x82 }

     Source : <0x0012cf70> { _rcu_bh_qs + 0x14 } RTS

  12 Target : <0x0012cf5c> { _rcu_bh_qs + 0x0 }

     Source : <0x00111ace> { ___do_softirq + 0x7e } JUMP.L

  13 Target : <0x00111ac6> { ___do_softirq + 0x76 }

     Source : <0x0012d7e0> { _rcu_process_callbacks + 0x30 } RTS

  14 Target : <0x0012d7dc> { _rcu_process_callbacks + 0x2c }

     Source : <0x0012d67e> { _rcu_do_batch + 0x12a } RTS

  15 Target : <0x0012d676> { _rcu_do_batch + 0x122 }

     Source : <0x0012d566> { _rcu_do_batch + 0x12 } IF CC JUMP pcrel

Stack info:

SP: [0x02b47dac] <0x02b47dac> /* kernel dynamic memory */

FP: (0x02b47eec)

Memory from 0x02b47da0 to 02b48000

02b47da0: 000000d0  02b47dac  00000000 [002a179c] 00132fb2  02049080  00000000  000200d0

02b47dc0: 02049260  0000000b  000000d0  00000001  00000042  002a0d70  00000000  02b46008

02b47de0: 00000010  00000050  00000040  02b46000  02b46000  01000000  000200d0  002a17a0

02b47e00: 00000800  00000000  02049080  00000000  00000040  00000010  00000000  002a0d70

02b47e20: 00000000  00000000  00000000  002a0d70  02797fb0  0013b018  0045b000  027c2cfc

02b47e40: 027c2cfc  0000000b  00000073  00000000  0045a424  000003f7  00000000  027974b0

02b47e60: 00000000  027c2be8  00000022  02797fb0  0013b37e  00000000  027c2cfc  00000000

02b47e80: 00000003  00000073  00000000  0045a424  037df1fc  0013fbc2  0045a424  00000004

02b47ea0: 00000022  00000000  02b47eb0  000003f7  00000004  037df1fc  0013b6fc  00000000

02b47ec0: 0045a424  03d5abe0  02b46000  00000000  00000022  00000003  00001000  00000000

02b47ee0: 1f0c81d5  00000003  00000022 (00000000)<ffa0088e> 0013b6b8  000000c0  00000000

02b47f00: ffffe000  00000000  ffffffff  ffffe000  00000000  0000fffe  00000022  ffffffff

02b47f20: 00000000  027ca82e  00008000  00000000  00000000  02b48000  027ca82e  027ca82e

02b47f40: 027ca45c  ffa00e24  02000020  027cadc5  036dd8c1  027cadc2  036dd8be  00000000

02b47f60: 00000000  00000004  00000000  00000004  00000000  00000000  7ffff000  000000c0

02b47f80: 00000137  00000000  00000000  00000000  00000000  0000005b  00001802  00000001

02b47fa0: 000000b4  00000001  00000002  00000fff  000092f4  037df0f8  037df1fc  02b04054

02b47fc0: 02b45538  03d5abe0  02b45544  02b04000  000000c0  fec00000  00000000  00000000

02b47fe0: ffffffff  00000022  00000003  0045a424  00000000  00000000  000000c0  00000006

Return addresses in stack:

   frame  1 : <0xffa0088e> { _system_call + 0x6a }

Mem-Info:

DMA per-cpu:

CPU    0: hi:    0, btch:   1 usd:   0

active_anon:0 inactive_anon:0 isolated_anon:0

active_file:0 inactive_file:5 isolated_file:0

unevictable:3785 dirty:1 writeback:0 unstable:0

free:8883 slab_reclaimable:125 slab_unreclaimable:326

mapped:0 shmem:0 pagetables:0 bounce:0

DMA free:35532kB min:1000kB low:1248kB high:1500kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:20kB unevictable:15140kB isolated(anon):0kB isolated(file):0kB present:62992kB mlocked:0kB dirty:4kB writeback:0kB mapped:0kB shmem:0kB slab_reclaimable:500kB slab_unreclaimable:1304kB kernel_stack:160kB pagetables:0kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no

lowmem_reserve[]: 0 0 0

DMA: 19*4kB 12*8kB 16*16kB 13*32kB 12*64kB 9*128kB 10*256kB 9*512kB 5*1024kB 6*2048kB 2*4096kB 0*8192kB 0*16384kB 0*32768kB = 35532kB

3790 total pagecache pages

15872 pages RAM

818 pages reserved

3668 pages shared

2483 pages non-shared

Allocation of length 4564004 from process 174 (ffmpeg) failed

DMA per-cpu:

CPU    0: hi:    0, btch:   1 usd:   0

active_anon:0 inactive_anon:0 isolated_anon:0

active_file:0 inactive_file:5 isolated_file:0

unevictable:3785 dirty:1 writeback:0 unstable:0

free:8883 slab_reclaimable:125 slab_unreclaimable:326

mapped:0 shmem:0 pagetables:0 bounce:0

DMA free:35532kB min:1000kB low:1248kB high:1500kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:20kB unevictable:15140kB isolated(anon):0kB isolated(file):0kB present:62992kB mlocked:0kB dirty:4kB writeback:0kB mapped:0kB shmem:0kB slab_reclaimable:500kB slab_unreclaimable:1304kB kernel_stack:160kB pagetables:0kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no

lowmem_reserve[]: 0 0 0

DMA: 19*4kB 12*8kB 16*16kB 13*32kB 12*64kB 9*128kB 10*256kB 9*512kB 5*1024kB 6*2048kB 2*4096kB 0*8192kB 0*16384kB 0*32768kB = 35532kB

3790 total pagecache pages

ffmpeg:582: can't map '/usr/lib/libavcodec.so.52'

ffmpeg: can't load library 'libavcodec.so.52'

 

 

It represents a fragmenation error but we do not understand why : no user process is running, except syslogd and inetd as shown below (with ps command) :

 

PID USER VSZ STAT COMMAND

1 root 544 S /init

2 root 0 SW [kthreadd]

3 root 0 SW [ksoftirqd/0]

4 root 0 SW [events/0]

5 root 0 SW [khelper]

8 root 0 SW [async/mgr]

36 root 0 SW [sync_supers]

38 root 0 SW [bdi-default]

40 root 0 SW [kblockd/0]

56 root 0 SW [kswapd0]

57 root 0 SW [aio/0]

69 root 0 SW [mtdblockd]

108 root 0 SW [kmmcd]

121 root 0 SW [mmcqd]

133 root 705 S -/bin/sh

134 root 465 S /sbin/inetd

135 root 677 S /sbin/syslogd -n

136 root 673 S /sbin/klogd -n

176 root 677 R ps

 

Thanks in advance.

 

Cedric

QuoteReplyEditDelete

 

 

2011-01-31 11:26:32     Re: Random loading problem with ffmpeg

Mike Frysinger (UNITED STATES)

Message: 97811   

 

that is not related to L1.  it simply means your memory is fragmented.

 

you can probably do `echo 3 > /proc/sys/vm/drop_caches` after the fsck to workaround it.

QuoteReplyEditDelete

 

 

2011-01-31 13:48:24     Re: Random loading problem with ffmpeg

Cedric Marin (FRANCE)

Message: 97813   

 

Mike,

 

I just try to free pagecache, dentries and inodes with the previous command but it did not work... ffmpeg still crashes when we start it after checking the SD Card's filesystem (with e2fsck)...

 

Moreover, e2fsck is finished when we run ffmpeg and the memory pages reserved during the checking process are no longer used. So I do not understand why the kernel cannot allocate memory pages to the user application and generates a fragmentation core dump...

 

I tried to find documentation about this topic for few days (i.e., memory managment on system with no virtual memory - noMMU) but I found no pertinent information. Have you got some useful and interesting references ?

 

Thanks in advance.

 

Cedric

QuoteReplyEditDelete

 

 

2011-01-31 18:29:17     Re: Random loading problem with ffmpeg

Mike Frysinger (UNITED STATES)

Message: 97816   

 

fragmentation isnt something that can fix itself.  install more memory, or avoid large contiguous allocations, or avoid releasing those large allocations once you've booted.

 

an 8MiB chunk of memory on a 32MiB system is highly unlikely once you've booted and started running applications.

Attachments

    Outcomes