Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
slub.c File Reference
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/module.h>
#include <linux/bit_spinlock.h>
#include <linux/interrupt.h>
#include <linux/bitops.h>
#include <linux/slab.h>
#include "slab.h"
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/kmemcheck.h>
#include <linux/cpu.h>
#include <linux/cpuset.h>
#include <linux/mempolicy.h>
#include <linux/ctype.h>
#include <linux/debugobjects.h>
#include <linux/kallsyms.h>
#include <linux/memory.h>
#include <linux/math64.h>
#include <linux/fault-inject.h>
#include <linux/stacktrace.h>
#include <linux/prefetch.h>
#include <trace/events/kmem.h>
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  track
 

Macros

#define SLAB_DEBUG_FLAGS
 
#define MIN_PARTIAL   5
 
#define MAX_PARTIAL   10
 
#define DEBUG_DEFAULT_FLAGS
 
#define DEBUG_METADATA_FLAGS   (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
 
#define SLUB_NEVER_MERGE
 
#define SLUB_MERGE_SAME
 
#define OO_SHIFT   16
 
#define OO_MASK   ((1 << OO_SHIFT) - 1)
 
#define MAX_OBJS_PER_PAGE   32767 /* since page.objects is u15 */
 
#define __OBJECT_POISON   0x80000000UL /* Poison object */
 
#define __CMPXCHG_DOUBLE   0x40000000UL /* Use cmpxchg_double */
 
#define TRACK_ADDRS_COUNT   16
 
#define for_each_object(__p, __s, __addr, __objects)
 
#define slub_debug   0
 
#define disable_higher_order_debug   0
 
#define need_reserve_slab_rcu   (sizeof(((struct page *)NULL)->lru) < sizeof(struct rcu_head))
 
#define TID_STEP   1
 

Enumerations

enum  track_item { TRACK_ALLOC, TRACK_FREE }
 

Functions

voidkmem_cache_alloc (struct kmem_cache *s, gfp_t gfpflags)
 
 EXPORT_SYMBOL (kmem_cache_alloc)
 
void kmem_cache_free (struct kmem_cache *s, void *x)
 
 EXPORT_SYMBOL (kmem_cache_free)
 
unsigned int kmem_cache_size (struct kmem_cache *s)
 
 EXPORT_SYMBOL (kmem_cache_size)
 
int __kmem_cache_shutdown (struct kmem_cache *s)
 
 EXPORT_SYMBOL (kmalloc_caches)
 
 __setup ("slub_min_order=", setup_slub_min_order)
 
 __setup ("slub_nomerge", setup_slub_nomerge)
 
void__kmalloc (size_t size, gfp_t flags)
 
 EXPORT_SYMBOL (__kmalloc)
 
size_t ksize (const void *object)
 
 EXPORT_SYMBOL (ksize)
 
void kfree (const void *x)
 
 EXPORT_SYMBOL (kfree)
 
int kmem_cache_shrink (struct kmem_cache *s)
 
 EXPORT_SYMBOL (kmem_cache_shrink)
 
void __init kmem_cache_init (void)
 
void __init kmem_cache_init_late (void)
 
struct kmem_cache__kmem_cache_alias (const char *name, size_t size, size_t align, unsigned long flags, void(*ctor)(void *))
 
int __kmem_cache_create (struct kmem_cache *s, unsigned long flags)
 
void__kmalloc_track_caller (size_t size, gfp_t gfpflags, unsigned long caller)
 

Variables

struct kmem_cachekmalloc_caches [SLUB_PAGE_SHIFT]
 

Macro Definition Documentation

#define __CMPXCHG_DOUBLE   0x40000000UL /* Use cmpxchg_double */

Definition at line 180 of file slub.c.

#define __OBJECT_POISON   0x80000000UL /* Poison object */

Definition at line 179 of file slub.c.

#define DEBUG_DEFAULT_FLAGS
Value:

Definition at line 154 of file slub.c.

#define DEBUG_METADATA_FLAGS   (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)

Definition at line 162 of file slub.c.

#define disable_higher_order_debug   0

Definition at line 1238 of file slub.c.

#define for_each_object (   __p,
  __s,
  __addr,
  __objects 
)
Value:
for (__p = (__addr); __p < (__addr) + (__objects) * (__s)->size;\
__p += (__s)->size)

Definition at line 279 of file slub.c.

#define MAX_OBJS_PER_PAGE   32767 /* since page.objects is u15 */

Definition at line 176 of file slub.c.

#define MAX_PARTIAL   10

Definition at line 152 of file slub.c.

#define MIN_PARTIAL   5

Definition at line 145 of file slub.c.

#define need_reserve_slab_rcu   (sizeof(((struct page *)NULL)->lru) < sizeof(struct rcu_head))

Definition at line 1415 of file slub.c.

#define OO_MASK   ((1 << OO_SHIFT) - 1)

Definition at line 175 of file slub.c.

#define OO_SHIFT   16

Definition at line 174 of file slub.c.

#define SLAB_DEBUG_FLAGS
Value:

Definition at line 115 of file slub.c.

#define slub_debug   0

Definition at line 1236 of file slub.c.

#define SLUB_MERGE_SAME
Value:

Definition at line 171 of file slub.c.

#define SLUB_NEVER_MERGE
Value:

Definition at line 167 of file slub.c.

#define TID_STEP   1

Definition at line 1673 of file slub.c.

#define TRACK_ADDRS_COUNT   16

Definition at line 191 of file slub.c.

Enumeration Type Documentation

enum track_item
Enumerator:
TRACK_ALLOC 
TRACK_FREE 

Definition at line 202 of file slub.c.

Function Documentation

void* __kmalloc ( size_t  size,
gfp_t  flags 
)

Definition at line 3348 of file slub.c.

void* __kmalloc_track_caller ( size_t  size,
gfp_t  gfpflags,
unsigned long  caller 
)

Definition at line 4014 of file slub.c.

struct kmem_cache* __kmem_cache_alias ( const char name,
size_t  size,
size_t  align,
unsigned long  flags,
void(*)(void *)  ctor 
)
read

Definition at line 3935 of file slub.c.

int __kmem_cache_create ( struct kmem_cache s,
unsigned long  flags 
)

Definition at line 3959 of file slub.c.

int __kmem_cache_shutdown ( struct kmem_cache s)

Definition at line 3207 of file slub.c.

__setup ( )
__setup ( "slub_nomerge"  ,
setup_slub_nomerge   
)
EXPORT_SYMBOL ( kmem_cache_alloc  )
EXPORT_SYMBOL ( kmem_cache_free  )
EXPORT_SYMBOL ( kmem_cache_size  )
EXPORT_SYMBOL ( kmalloc_caches  )
EXPORT_SYMBOL ( __kmalloc  )
EXPORT_SYMBOL ( ksize  )
EXPORT_SYMBOL ( kfree  )
EXPORT_SYMBOL ( kmem_cache_shrink  )
void kfree ( const void x)

kfree - free previously allocated memory : pointer returned by kmalloc.

If is NULL, no operation is performed.

Don't free memory not originally allocated by kmalloc() or you will run into trouble.

Definition at line 3467 of file slub.c.

void* kmem_cache_alloc ( struct kmem_cache s,
gfp_t  gfpflags 
)

kmem_cache_alloc - Allocate an object : The cache to allocate from. : See kmalloc().

Allocate an object from this cache. The flags are only relevant if the cache has no available objects.

Definition at line 2393 of file slub.c.

void kmem_cache_free ( struct kmem_cache s,
void x 
)

kmem_cache_free - Deallocate an object : The cache the allocation was from. : The previously allocated object.

Free an object which was previously allocated from this cache.

Definition at line 2620 of file slub.c.

void __init kmem_cache_init ( void  )

Definition at line 3705 of file slub.c.

void __init kmem_cache_init_late ( void  )

Definition at line 3870 of file slub.c.

int kmem_cache_shrink ( struct kmem_cache s)

kmem_cache_shrink - Shrink a cache. : The cache to shrink.

Releases as many slabs as possible for a cache. To help debugging, a zero exit status indicates all slabs were released.

Definition at line 3498 of file slub.c.

unsigned int kmem_cache_size ( struct kmem_cache s)

Definition at line 3133 of file slub.c.

size_t ksize ( const void object)

ksize - get the actual amount of memory allocated for a given object : Pointer to the object

kmalloc may internally round up allocations and return more memory than requested. ksize() can be used to determine the actual amount of memory allocated. The caller may use this additional memory, even though a smaller amount of memory was initially specified with the kmalloc call. The caller must guarantee that objp points to a valid object previously allocated with either kmalloc() or kmem_cache_alloc(). The object must not be freed during the duration of the call.

Definition at line 3413 of file slub.c.

Variable Documentation

struct kmem_cache* kmalloc_caches[SLUB_PAGE_SHIFT]

Definition at line 3221 of file slub.c.