Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
util.c File Reference
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/export.h>
#include <linux/err.h>
#include <linux/sched.h>
#include <linux/security.h>
#include <asm/uaccess.h>
#include "internal.h"
#include <trace/events/kmem.h>

Go to the source code of this file.

Macros

#define CREATE_TRACE_POINTS
 

Functions

charkstrdup (const char *s, gfp_t gfp)
 
 EXPORT_SYMBOL (kstrdup)
 
charkstrndup (const char *s, size_t max, gfp_t gfp)
 
 EXPORT_SYMBOL (kstrndup)
 
voidkmemdup (const void *src, size_t len, gfp_t gfp)
 
 EXPORT_SYMBOL (kmemdup)
 
voidmemdup_user (const void __user *src, size_t len)
 
 EXPORT_SYMBOL (memdup_user)
 
void__krealloc (const void *p, size_t new_size, gfp_t flags)
 
 EXPORT_SYMBOL (__krealloc)
 
voidkrealloc (const void *p, size_t new_size, gfp_t flags)
 
 EXPORT_SYMBOL (krealloc)
 
void kzfree (const void *p)
 
 EXPORT_SYMBOL (kzfree)
 
charstrndup_user (const char __user *s, long n)
 
 EXPORT_SYMBOL (strndup_user)
 
void __vma_link_list (struct mm_struct *mm, struct vm_area_struct *vma, struct vm_area_struct *prev, struct rb_node *rb_parent)
 
pid_t vm_is_stack (struct task_struct *task, struct vm_area_struct *vma, int in_group)
 
int __attribute__ ((weak))
 
 EXPORT_SYMBOL_GPL (__get_user_pages_fast)
 
 EXPORT_SYMBOL_GPL (get_user_pages_fast)
 
unsigned long vm_mmap_pgoff (struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flag, unsigned long pgoff)
 
unsigned long vm_mmap (struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flag, unsigned long offset)
 
 EXPORT_SYMBOL (vm_mmap)
 
 EXPORT_TRACEPOINT_SYMBOL (kmalloc)
 
 EXPORT_TRACEPOINT_SYMBOL (kmem_cache_alloc)
 
 EXPORT_TRACEPOINT_SYMBOL (kmalloc_node)
 
 EXPORT_TRACEPOINT_SYMBOL (kmem_cache_alloc_node)
 
 EXPORT_TRACEPOINT_SYMBOL (kfree)
 
 EXPORT_TRACEPOINT_SYMBOL (kmem_cache_free)
 

Macro Definition Documentation

#define CREATE_TRACE_POINTS

Definition at line 12 of file util.c.

Function Documentation

int __attribute__ ( (weak)  )
read

get_user_pages_fast() - pin user pages in memory : starting user address : number of pages from start to pin : whether pages will be written to : array that receives pointers to the pages pinned. Should be at least nr_pages long.

Returns number of pages pinned. This may be fewer than the number requested. If nr_pages is 0 or negative, returns 0. If no pages were pinned, returns -errno.

get_user_pages_fast provides equivalent functionality to get_user_pages, operating on current and current->mm, with force=0 and vma=NULL. However unlike get_user_pages, it must be called without mmap_sem held.

get_user_pages_fast may take mmap_sem and page table locks, so no assumptions can be made about lack of locking. get_user_pages_fast is to be implemented in a way that is advantageous (vs get_user_pages()) when the user memory area is already faulted in and present in ptes. However if the pages have to be faulted in, it may turn out to be slightly slower so callers need to carefully consider what to use. On many architectures, get_user_pages_fast simply falls back to get_user_pages.

Definition at line 306 of file util.c.

void* __krealloc ( const void p,
size_t  new_size,
gfp_t  flags 
)

__krealloc - like krealloc() but don't free . : object to reallocate memory for. : how many bytes of memory are required. : the type of memory to allocate.

This function is like krealloc() except it never frees the originally allocated buffer. Use this if you don't want to free the buffer immediately like, for example, with RCU.

Definition at line 137 of file util.c.

void __vma_link_list ( struct mm_struct mm,
struct vm_area_struct vma,
struct vm_area_struct prev,
struct rb_node rb_parent 
)

Definition at line 228 of file util.c.

EXPORT_SYMBOL ( kstrdup  )
EXPORT_SYMBOL ( kstrndup  )
EXPORT_SYMBOL ( kmemdup  )
EXPORT_SYMBOL ( memdup_user  )
EXPORT_SYMBOL ( __krealloc  )
EXPORT_SYMBOL ( krealloc  )
EXPORT_SYMBOL ( kzfree  )
EXPORT_SYMBOL ( strndup_user  )
EXPORT_SYMBOL ( vm_mmap  )
EXPORT_SYMBOL_GPL ( __get_user_pages_fast  )
EXPORT_SYMBOL_GPL ( get_user_pages_fast  )
EXPORT_TRACEPOINT_SYMBOL ( kmalloc  )
EXPORT_TRACEPOINT_SYMBOL ( kmem_cache_alloc  )
EXPORT_TRACEPOINT_SYMBOL ( kmalloc_node  )
EXPORT_TRACEPOINT_SYMBOL ( kmem_cache_alloc_node  )
EXPORT_TRACEPOINT_SYMBOL ( kfree  )
EXPORT_TRACEPOINT_SYMBOL ( kmem_cache_free  )
void* kmemdup ( const void src,
size_t  len,
gfp_t  gfp 
)

kmemdup - duplicate region of memory

: memory region to duplicate : memory region length : GFP mask to use

Definition at line 67 of file util.c.

void* krealloc ( const void p,
size_t  new_size,
gfp_t  flags 
)

krealloc - reallocate memory. The contents will remain unchanged. : object to reallocate memory for. : how many bytes of memory are required. : the type of memory to allocate.

The contents of the object pointed to are preserved up to the lesser of the new and old sizes. If is NULL, krealloc() behaves exactly like kmalloc(). If is 0 and is not a NULL pointer, the object pointed to is freed.

Definition at line 158 of file util.c.

char* kstrdup ( const char s,
gfp_t  gfp 
)

kstrdup - allocate space for and copy an existing string : the string to duplicate : the GFP mask used in the kmalloc() call when allocating memory

Definition at line 20 of file util.c.

char* kstrndup ( const char s,
size_t  max,
gfp_t  gfp 
)

kstrndup - allocate space for and copy an existing string : the string to duplicate : read at most chars from : the GFP mask used in the kmalloc() call when allocating memory

Definition at line 42 of file util.c.

void kzfree ( const void p)

kzfree - like kfree but zero memory : object to free memory of

The memory of the object points to is zeroed before freed. If is NULL, kzfree() does nothing.

Note: this function zeroes the whole allocated buffer which can be a good deal bigger than the requested buffer size passed to kmalloc(). So be careful when using this function in performance sensitive code.

Definition at line 186 of file util.c.

void* memdup_user ( const void __user src,
size_t  len 
)

memdup_user - duplicate memory region from user space

: source address in user space : number of bytes to copy

Returns an ERR_PTR() on failure.

Definition at line 86 of file util.c.

char* strndup_user ( const char __user s,
long  n 
)

Definition at line 204 of file util.c.

pid_t vm_is_stack ( struct task_struct task,
struct vm_area_struct vma,
int  in_group 
)

Definition at line 263 of file util.c.

unsigned long vm_mmap ( struct file file,
unsigned long  addr,
unsigned long  len,
unsigned long  prot,
unsigned long  flag,
unsigned long  offset 
)

Definition at line 368 of file util.c.

unsigned long vm_mmap_pgoff ( struct file file,
unsigned long  addr,
unsigned long  len,
unsigned long  prot,
unsigned long  flag,
unsigned long  pgoff 
)

Definition at line 352 of file util.c.