=>  Releases

Current version
Git/Latestdiff: 1.5.5

Latest Snapshots
Produced after each commit or rebase to new upstream version

RSBAC source code, can be unstable sometimes

=>  Events

No events planned


This shows you the differences between two versions of the page.

Link to this comparison view

documentation:memory_allocation [2006/05/02 15:40] (current)
Line 1: Line 1:
 +===== Basics =====
 +For different tasks it is necessary to allocate a chunk of memory. Especially in the Linux kernel, stack space is pretty tight, so you quite often cannot simply declare some large variable and hope it works out.
 +The usual way to allocate kernel memory is using kmalloc/​kfree for rather small amounts (allocated continuously as real memory) and vmalloc/​vfree (virtual memory) for large sizes. Unfortunately,​ you have to find out yourself, which method is better. kmalloc will fail, if you try to allocate more than 128M - anyway, continous memory of several pages might be difficult to get.
 +===== RSBAC memory allocation =====
 +RSBAC provides some own memory management functions. These functions also get exported for modules, if REG support has been enabled.
 +In kernel versions from 2.4.0, separate RSBAC memory slabs are used for kmalloc style memory to provide better control of memory usage through /​proc/​slabinfo.
 +  * All functions are defined here:
 +<code c>#​include <​rsbac/​rkmem.h></​code>​
 +  * rsbac_kmalloc works like kmalloc with second parameter GFP_KERNEL.
 +<code c>void * rsbac_kmalloc (size_t size);</​code>​
 +  * rsbac_kfree is used like kfree - please make sure you do not call it with wrong pointers
 +<code c>void rsbac_kfree (const void *objp);</​code>​
 +  * rsbac_vkmalloc allocates via rsbac_kmalloc for small sizes (up to RSBAC_MAX_KMALLOC) and via vmalloc for larger sizes. Whether vmalloc has been used is put into *vmalloc_used_p as boolean value TRUE or FALSE
 +<code c>void * rsbac_vkmalloc
 + ​(size_t size, boolean * vmalloc_used_p);</​code>​
 +  * rsbac_vkfree is used to free such memory. To know the memory type, it needs the boolean value vmalloc_used from rsbac_vkmalloc
 +<code c>void rsbac_vkfree (void *objp, boolean vmalloc_used);</​code>​
documentation/memory_allocation.txt · Last modified: 2006/05/02 15:40 (external edit)

documentation/memory_allocation.txt · Last modified: 2006/05/02 15:40 (external edit)
This website is kindly hosted by m-privacy