AnsweredAssumed Answered

How can I minimize memory fragmentation on startup?

Question asked by skstrobel on Jan 25, 2013
Latest reply on Jan 30, 2013 by sonic

I have a BF537 project that loads the kernel and rootfs into an initramfs on startup.  I just ported it from 2009R1.1 to 2011r1-rc3 and am now having trouble with failed memory allocations.  While booting it fails on an order 12 (16MB) allocation, even though there is 41MB of memory free with three 8MB blocks available.  So it seems that either the memory is getting more fragmented during startup than it did with 2009R1.1, or maybe it didn't try to allocate such a big chunk all at one time.

 

Is there any way to determine what is causing the large allocation?  Is there anything I can do to minimize the fragmentation so that a 16MB block of memory would be available?

 

I have looked through the online docs and have tried to minimize the memory used by the distribution files and the file size of my application.  My uImage.gz.initramfs file is about 10MB, slightly smaller than it was under 2009R1.1.  My application file is about 11MB uncompressed (it uses Qt so it is rather large).  If it omit it from the initramfs, the compressed uImage drops to about 6MB and it boots fine.  So the problem may be related to that file (which isn't getting executed yet at the point of the problem - Linux is still booting), or maybe storing it in the initramfs just uses enough memory that something else fails.

 

Thanks for any suggestions.  The serial output during boot follows...

 

Steve

 

 

bfin> run devboot-ipr5000-ss

Random delay: 216 ms...

BOOTP broadcast 1

DHCP client bound to address 192.168.25.26

Using bfin_mac device

TFTP from server 192.168.25.87; our IP address is 192.168.25.26

Filename 'uImage-ipr5000-ss'.

Load address: 0x2000000

Loading: #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################

done

Bytes transferred = 10069702 (99a6c6 hex)

## Booting kernel from Legacy Image at 02000000 ...

   Image Name:   bf537-0.3-3.0.8-ADI-2011R1-svn72

   Image Type:   Blackfin Linux Kernel Image (gzip compressed)

   Data Size:    10069638 Bytes = 9.6 MiB

   Load Address: 00001000

   Entry Point:  00205be8

   Verifying Checksum ... OK

   Uncompressing Kernel Image ... OK

Starting Kernel at = 00205be8

Linux version 3.0.8-ADI-2011R1-svn7271 (stevestrobel@dev-server) (gcc version 4.

3.5 (ADI-2011R1-RC4) ) #29 PREEMPT Fri Jan 25 14:38:24 MST 2013

register early platform devices

Board Memory: 64MB

Kernel Managed Memory: 64MB

Memory map:

  fixedcode = 0x00000400-0x00000490

  text      = 0x00001000-0x001704e8

  rodata    = 0x001704e8-0x001da4ac

  bss       = 0x001db000-0x001eb508

  data      = 0x001eb508-0x00202000

    stack   = 0x00200000-0x00202000

  init      = 0x00202000-0x01259000

  available = 0x01259000-0x03f00000

  DMA Zone  = 0x03f00000-0x04000000

Hardware Trace active and enabled

Boot Mode: 3

Reset caused by Software reset

Blackfin support (C) 2004-2010 Analog Devices, Inc.

Compiled for ADSP-BF537 Rev 0.3

Blackfin Linux support by http://blackfin.uclinux.org/

Processor Speed: 600 MHz core clock and 120 MHz System Clock

NOMPU: setting up cplb tables

Instruction Cache Enabled for CPU0

  External memory: cacheable in instruction cache

Data Cache Enabled for CPU0

  External memory: cacheable (write-back) in data cache

Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 16002

Kernel command line: root=/dev/mtdblock0 rw clkin_hz=25000000 earlyprintk=serial

,uart0,115200 console=ttyBF0,115200

PID hash table entries: 256 (order: -2, 1024 bytes)

Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)

Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)

Memory available: 45116k/65536k RAM, (16732k init code, 1469k kernel code, 583k

data, 1024k dma, 612k reserved)

NR_IRQS:146

Configuring Blackfin Priority Driven Interrupts

console [ttyBF0] enabled

Calibrating delay loop... 1191.93 BogoMIPS (lpj=2383872)

pid_max: default: 32768 minimum: 301

Mount-cache hash table entries: 512

Blackfin Scratchpad data SRAM: 4 KB

Blackfin L1 Data A SRAM: 16 KB (15 KB free)

Blackfin L1 Data B SRAM: 16 KB (16 KB free)

Blackfin L1 Instruction SRAM: 48 KB (34 KB free)

NET: Registered protocol family 16

Blackfin DMA Controller

stamp_init(): registering device resources

bio: create slab <bio-0> at 0

SCSI subsystem initialized

bfin-spi bfin-spi.0: Blackfin on-chip SPI Controller Driver, Version 1.0, regs@f

fc00500, dma channel@7

usbcore: registered new interface driver usbfs

usbcore: registered new interface driver hub

usbcore: registered new device driver usb

Advanced Linux Sound Architecture Driver Version 1.0.24.

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 2048 (order: 2, 16384 bytes)

TCP bind hash table entries: 2048 (order: 1, 8192 bytes)

TCP: Hash tables configured (established 2048 bind 2048)

TCP reno registered

UDP hash table entries: 256 (order: 0, 4096 bytes)

UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)

NET: Registered protocol family 1

swapper: page allocation failure: order:12, mode:0x200d2

Hardware Trace:

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

     Source : <0x000414a6> { _warn_alloc_failed + 0x7a } JUMP.L

   1 Target : <0x000414a6> { _warn_alloc_failed + 0x7a }

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

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

     Source : <0x00010622> { _vprintk + 0x2da } RTS

   3 Target : <0x00010608> { _vprintk + 0x2c0 }

     Source : <0x0000ac3e> { _sub_preempt_count + 0x26 } RTS

   4 Target : <0x0000ac2c> { _sub_preempt_count + 0x14 }

     Source : <0x0000ac5a> { _sub_preempt_count + 0x42 } IF !CC JUMP pcrel (BP)

   5 Target : <0x0000ac40> { _sub_preempt_count + 0x28 }

     Source : <0x0000ac2a> { _sub_preempt_count + 0x12 } IF CC JUMP pcrel

   6 Target : <0x0000ac18> { _sub_preempt_count + 0x0 }

     Source : <0x00010604> { _vprintk + 0x2bc } CALL pcrel

   7 Target : <0x00010602> { _vprintk + 0x2ba }

     Source : <0xffa00d76> { __common_int_entry + 0xe2 } RTI

   8 Target : <0xffa00d14> { __common_int_entry + 0x80 }

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

   9 Target : <0xffa00b4c> { _return_from_int + 0x58 }

     Source : <0xffa00ab6> { _resume_kernel_from_int + 0x12 } IF !CC JUMP pcrel

  10 Target : <0xffa00aa4> { _resume_kernel_from_int + 0x0 }

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

  11 Target : <0xffa00af4> { _return_from_int + 0x0 }

     Source : <0xffa00d10> { __common_int_entry + 0x7c } JUMP.L

  12 Target : <0xffa00d0a> { __common_int_entry + 0x76 }

     Source : <0xffa003ba> { _asm_do_IRQ + 0x6a } RTS

  13 Target : <0xffa003b2> { _asm_do_IRQ + 0x62 }

     Source : <0x0000ac3e> { _sub_preempt_count + 0x26 } RTS

  14 Target : <0x0000ac2c> { _sub_preempt_count + 0x14 }

     Source : <0x0000ac5a> { _sub_preempt_count + 0x42 } IF !CC JUMP pcrel (BP)

  15 Target : <0x0000ac40> { _sub_preempt_count + 0x28 }

     Source : <0x0000ac2a> { _sub_preempt_count + 0x12 } IF CC JUMP pcrel

Stack info:

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

FP: (0x0200bf80)

Memory from 0x0200bcc0 to 0200c000

0200bcc0: 00000000  0200bccc  00000001 [00041458] 000414aa  001fdc8c  000200d2

00000000

0200bce0: 020081a4  0000000c  000200d2  000418f2  00000000  000200d2  00000001

00000001

0200bd00: 000200d2  00000000  0000000c  001fdc8c  00000001  00000040  001fd278

00000000

0200bd20: 0200a008  0200a000  0200a008  0200a000  00000040  0200a000  0106d004

000200d2

0200bd40: 00001000  00000001  00000001  00000040  00000010  00000000  00000040

001fd278

0200bd60: 00000000  00000000  001fd278  001fd278  0200bda8  00087560  0206e118

0206e118

0200bd80: 0207e5f4  0000000c  00adbf90  00000000  00002068  0004d2b8  0000000c

02005f00

0200bda0: 00000000  00000000  00212d18  000876f2  0206e118  0200be28  0207e5f4

00000000

0200bdc0: 00000000  00adbf90  00002068  003a46ee  000617c0  00013d24 <000616b6>

0200be28

0200bde0: 0206e118  00000000  00000008  000081ed  00adbf90  00000000  0206e118

00000000

0200be00: 0004e662  0207e5f4  00212d3c  00212d00  00000000  00000001  0207e580

00212d28

0200be20: 00212d3c  00212d00  00002068  00212d18  00062f82  0004e130  00adbf90

00000000

0200be40: 45984f00  0f7f4902  45984f00  0f7f4902  45984f00  0f7f4902  0207e580

0004e726

0200be60: 00212d54  00000000  00212d18  45984f00  0f7f4902  00000060  0207e580

0004e74e

0200be80: 0018c61c <00eafbe4> 00000000  00212d28  00212d3c  00212d00  0018c61c

00000001

0200bea0: 002040ee  00000000  00000000  0000000b  30303030  42303030  5102fb00 <

00203c26>

0200bec0:<003a4680> 00212d18 <00203c26><003a4680> 00212d28  001db008  0018c61c

00000000

0200bee0: 0007fdee  0007f8c0  001a8fa4  0200bef8  001e9098  001f9918  00000103

0007ff06

0200bf00: 020663e0  00211218  001db008  0200bf80  00204434  00217ee4  01254268

001db008

0200bf20: 00000000  00000000  00000000  00000000  001db008  0000018c  020070c0

00183f38

0200bf40: 00000000  002112a8  00111b16  001fd0a0  00211218  00183f38  00111b16

001fd0a0

0200bf60: 00000000  00000000  00000000  00111bd6  00217ee0  001fd0a0  00000000

00000001

0200bf80:(00000000)<0000110a> 00217ee4  00204418  001db008  00000000  00000000

00000000

0200bfa0: 00000000  00000000  001f0000  0003af24  001ef33c  00217e1c  0020215e

00217ee4

0200bfc0: 00217e1c  00218060  00000000  00000000  00000000  00000000  00000000

00000000

0200bfe0: 00000000

00000000  00000000  00000000  00000000  ffffffff  00000006

Return addresses in stack:

    address : <0x000616b6> { _notify_change + 0xa2 }

    address : <0x00eafbe4> /* kernel dynamic memory */

    address : <0x00203c26> { _unpack_to_rootfs + 0x116 }

    address : <0x003a4680> /* kernel dynamic memory */

    address : <0x00203c26> { _unpack_to_rootfs + 0x116 }

    address : <0x003a4680> /* kernel dynamic memory */

   frame  1 : <0x0000110a> { _do_one_initcall + 0x10a }

    address : <0x00001556> { _kernel_thread_helper + 0x6 }

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:0 isolated_file:0

unevictable:416 dirty:0 writeback:0 unstable:0

free:10753 slab_reclaimable:0 slab_unreclaimable:0

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

DMA free:43012kB min:0kB low:0kB high:0kB active_anon:0kB inactive_anon:0kB acti

ve_file:0kB inactive_file:0kB unevictable:1664kB isolated(anon):0kB isolated(fil

e):0kB present:64008kB mlocked:0kB dirty:0kB writeback:0kB mapped:0kB shmem:0kB

slab_reclaimable:0kB slab_unreclaimable:0kB kernel_stack:104kB pagetables:0kB un

stable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:416 all_unreclaimable? no

lowmem_reserve[]: 0 0 0

DMA: 3*4kB 1*8kB 1*16kB 1*32kB 1*64kB 1*128kB 1*256kB 1*512kB 3*1024kB 1*2048kB

3*4096kB 3*8192kB 0*16384kB 0*32768kB = 43012kB

416 total pagecache pages

16128 pages RAM

4849 pages reserved

0 pages shared

513 pages non-shared

io scheduler noop registered

io scheduler cfq registered (default)

bfin-uart: Blackfin serial driver

bfin-uart.0: ttyBF0 at MMIO 0xffc00400 (irq = 18) is a BFIN-UART

bfin-uart.1: ttyBF1 at MMIO 0xffc02000 (irq = 20) is a BFIN-UART

bfin_sport: registered sport0

bfin_sport: registered sport1

IPR5000 mic_ptt driver

IPR5000 boot_mode_switch_4 driver

IPR5000 volume_knob driver

IPR5000 channel_knob driver

IPR5000 channel_knob_pressed driver

IPR5000 backlight_control driver

IPR5000 power_control driver

IPR5000 speaker_enable driver

IPR5000 dvsi_ready driver

IPR5000 buttons driver

brd: module loaded

PPP generic driver version 2.4.2

bfin_mii_bus: probed

bfin_mac: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1, mdc_

clk=2500000Hz(mdc_div=23)@sclk=120MHz)

bfin_mac bfin_mac.0: eth0: Blackfin on-chip Ethernet MAC driver, Version 1.1

driver isp1362-hcd, 2005-04-04

isp1362-hcd isp1362-hcd.0: ISP1362 Host Controller

isp1362-hcd isp1362-hcd.0: new USB bus registered, assigned bus number 1

isp1362_hc_reset:

isp1362-hcd isp1362-hcd.0: irq 65, io mem 0x20060000

isp1362_hc_start:

isp1362-hcd isp1362-hcd.0: ISP1362 Memory usage:

isp1362-hcd isp1362-hcd.0:   ISTL:    2 *  256:      512 @ $0000:$0100

isp1362-hcd isp1362-hcd.0:   INTL:   16 * ( 64+8):  1152 @ $0200

isp1362-hcd isp1362-hcd.0:   ATL :   32 * ( 64+8):  2304 @ $0680

isp1362-hcd isp1362-hcd.0:   USED/FREE:   3968       128

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

ISP1362 Host Controller, irq 65

Initializing USB Mass Storage driver...

usbcore: registered new interface driver usb-storage

USB Mass Storage support registered.

bfin-wdt: initialized: timeout=20 sec (nowayout=0)

 

Probing AD1938...

dma_alloc_init: dma_page @ 0x0198f000 - 256 pages at 0x03f00000

snd_ad1938_configure

AD1938: requesting GPIO line PF7.

 

AD1938 Initialization complete. (ret=0)

ALSA device list:

  #0: ADI ad1938 at PF4 SPORT0 rx/tx dma 3/4 err irq 45

TCP cubic registered

NET: Registered protocol family 17

Freeing unused kernel memory: 16732k freed

mkdir: can't create directory '/log': File exists

usb 1-2: new full speed USB device number 2 using isp1362-hcd

hub 1-2:1.0: USB hub found

hub 1-2:1.0: 4 ports detected

                           _____________________________________

        a8888b.           / Welcome to the uClinux distribution \

       d888888b.         /       _     _                         \

       8P"YP"Y88        /       | |   |_|            __  __ (TM)  |

       8|o||o|88  _____/        | |    _ ____  _   _ \ \/ /       |

       8'    .88       \        | |   | |  _ \| | | | \  /        |

       8`._.' Y8.       \       | |__ | | | | | |_| | /  \        |

      d/      `8b.       \      \____||_|_| |_|\____|/_/\_\       |

     dP   .    Y8b.       \   For embedded processors including   |

    d8:'  "  `::88b        \    the Analog Devices Blackfin      /

   d8"         'Y88b        \___________________________________/

  :8P    '      :888

   8a.   :     _a88P         For further information, check out:

._/"Yaa_:   .| 88P|            - http://blackfin.uclinux.org/

\    YP"    `| 8P  `.          - http://docs.blackfin.uclinux.org/

/     \.___.d|    .'           - http://www.uclinux.org/

`--..__)8888P`._.'  jgs/a:f    - http://www.analog.com/blackfin

 

 

Have a lot of fun...

mount: mounting /dev/mtdblock4 on /mnt/permanent failed: No such device

This is /mnt/permanent/scripts/init-passwd

Checking for password file

Setting up default password

Password file exists - using it

usb 1-2.3: new full speed USB device number 3 using isp1362-hcd

 

BusyBox v1.18.4 (2013-01-24 11:30:04 MST) hush - the humble shell

Enter 'help' for a list of built-in commands.

 

root:~>

Outcomes