Skip to main content.
Navigation:
DENX
>
Training2
>
LddKernelMemory
Translations:
Edit
|
Attach
|
Raw
|
Ref-By
|
Printable
|
More
Training2
Sections of this site:
DENX Home
|
DULG
|
ELDK-5
|
Know
|
Training
|
U-Boot
|
U-Bootdoc
Topics
Training2 Home
Changes
Index
Search
Go
List of pages in Training2
Search
%SECTION0{name=LddKernelMemory}% Allocating Memory * simplest form =kmalloc(size, flags)= * flags see =linux/gfp.h= * may sleep =GFP_KERNEL=, or not =GFP_ATOMIC= * fast, continuous, doesn't clear (security? -> =kzalloc=) * free with =kfree(ptr)= * more memory needed? allocate pages: * =get_zeroed_page(flags)= * =__get_free_page(flags) /* non zeroed */= * =__get_free_pages(flags, order)= * allocate 2^order pages * calculate oder from size: =get_order(size)= * freeing * =free_page(ptr)= * =free_pages(ptr, order)= * advantages: slightly faster and avoids fragementation * =vmalloc= / =vfree= * above functions allocate physically consecutive memory * =vmalloc= allocated memory is only *virtually* consecutive * cons: * slower because page tables need to be setup * not usable from outside of CPU (DMA) * pro: * large allocation less likely to fail due to fragementation * -> ok for e.g. large software only buffer * Optimizations (premature opt ...) * Situation: driver allocates many objects of the same size over and over again * lookaside cache (see slab cache in !DocBook "Memory Management in Linux") * nice: cache usage information in /proc/slabinfo * Sitation: memory allocation is not allowed to fail * mempool can be used for reserving memory in emergencies * Usually bad: memory is idle. Better deal with allocation failures
5.7.4.4. Other locking techniques
1. Denx Training Topics
5.7.6. How to delay execution
Prev
Home
Next