'\" t .\" Title: kmalloc .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: January 2017 .\" Manual: Memory Management in Linux .\" Source: Kernel Hackers Manual 4.8.15 .\" Language: English .\" .TH "KMALLOC" "9" "January 2017" "Kernel Hackers Manual 4\&.8\&." "Memory Management in Linux" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" kmalloc \- allocate memory .SH "SYNOPSIS" .HP \w'void\ *\ kmalloc('u .BI "void * kmalloc(size_t\ " "size" ", gfp_t\ " "flags" ");" .SH "ARGUMENTS" .PP \fIsize\fR .RS 4 how many bytes of memory are required\&. .RE .PP \fIflags\fR .RS 4 the type of memory to allocate\&. .RE .SH "DESCRIPTION" .PP kmalloc is the normal method of allocating memory for objects smaller than page size in the kernel\&. .PP The \fIflags\fR argument may be one of: .PP \fBGFP_USER\fR \- Allocate memory on behalf of user\&. May sleep\&. .PP \fBGFP_KERNEL\fR \- Allocate normal kernel ram\&. May sleep\&. .PP \fBGFP_ATOMIC\fR \- Allocation will not sleep\&. May use emergency pools\&. For example, use this inside interrupt handlers\&. .PP \fBGFP_HIGHUSER\fR \- Allocate pages from high memory\&. .PP \fBGFP_NOIO\fR \- Do not do any I/O at all while trying to get memory\&. .PP \fBGFP_NOFS\fR \- Do not make any fs calls while trying to get memory\&. .PP \fBGFP_NOWAIT\fR \- Allocation will not sleep\&. .PP \fB__GFP_THISNODE\fR \- Allocate node\-local memory only\&. .PP \fBGFP_DMA\fR \- Allocation suitable for DMA\&. Should only be used for \fBkmalloc\fR caches\&. Otherwise, use a slab created with SLAB_DMA\&. .PP Also it is possible to set different flags by OR\*(Aqing in one or more of the following additional \fIflags\fR: .PP \fB__GFP_COLD\fR \- Request cache\-cold pages instead of trying to return cache\-warm pages\&. .PP \fB__GFP_HIGH\fR \- This allocation has high priority and may use emergency pools\&. .PP \fB__GFP_NOFAIL\fR \- Indicate that this allocation is in no way allowed to fail (think twice before using)\&. .PP \fB__GFP_NORETRY\fR \- If memory is not immediately available, then give up at once\&. .PP \fB__GFP_NOWARN\fR \- If allocation fails, don\*(Aqt issue any warnings\&. .PP \fB__GFP_REPEAT\fR \- If allocation fails initially, try once more before failing\&. .PP There are other flags available as well, but these are not intended for general use, and so are not documented here\&. For a full list of potential flags, always refer to linux/gfp\&.h\&. .SH "COPYRIGHT" .br