umem  1.0.1
Classes | Macros | Typedefs
umem_impl.h File Reference
#include <umem.h>
#include <sys/sysmacros.h>
#include <sys/time.h>
#include <sys/vmem.h>
#include "sol_compat.h"

Go to the source code of this file.

Classes

struct  umem_bufctl
 
struct  umem_bufctl_audit
 
struct  umem_buftag
 
struct  umem_slab
 
struct  umem_magazine
 
struct  umem_magtype
 
struct  umem_cpu_cache
 
struct  umem_maglist
 
struct  umem_cache
 
struct  umem_cpu_log_header
 
struct  umem_log_header
 
struct  umem_cpu
 

Macros

#define UMC_QCACHE   0x00100000
 
#define UMC_INTERNAL   0x80000000
 
#define UMF_AUDIT   0x00000001 /* transaction auditing */
 
#define UMF_DEADBEEF   0x00000002 /* deadbeef checking */
 
#define UMF_REDZONE   0x00000004 /* redzone checking */
 
#define UMF_CONTENTS   0x00000008 /* freed-buffer content logging */
 
#define UMF_CHECKSIGNAL   0x00000010 /* abort when in signal context */
 
#define UMF_NOMAGAZINE   0x00000020 /* disable per-cpu magazines */
 
#define UMF_FIREWALL   0x00000040 /* put all bufs before unmapped pages */
 
#define UMF_LITE   0x00000100 /* lightweight debugging */
 
#define UMF_HASH   0x00000200 /* cache has hash table */
 
#define UMF_RANDOMIZE   0x00000400 /* randomize other umem_flags */
 
#define UMF_BUFTAG   (UMF_DEADBEEF | UMF_REDZONE)
 
#define UMF_TOUCH   (UMF_BUFTAG | UMF_LITE | UMF_CONTENTS)
 
#define UMF_RANDOM   (UMF_TOUCH | UMF_AUDIT | UMF_NOMAGAZINE)
 
#define UMF_DEBUG   (UMF_RANDOM | UMF_FIREWALL)
 
#define UMEM_STACK_DEPTH   umem_stack_depth
 
#define UMEM_FREE_PATTERN   0xdeadbeefdeadbeefULL
 
#define UMEM_UNINITIALIZED_PATTERN   0xbaddcafebaddcafeULL
 
#define UMEM_REDZONE_PATTERN   0xfeedfacefeedfaceULL
 
#define UMEM_REDZONE_BYTE   0xbb
 
#define UMEM_FATAL_FLAGS   (UMEM_NOFAIL)
 
#define UMEM_SLEEP_FLAGS   (0)
 
#define UMEM_SIZE_ENCODE(x)   (251 * (x) + 1)
 
#define UMEM_SIZE_DECODE(x)   ((x) / 251)
 
#define UMEM_SIZE_VALID(x)   ((x) % 251 == 1)
 
#define UMEM_BUFCTL_AUDIT_SIZE_DEPTH(frames)   ((size_t)(&((umem_bufctl_audit_t *)0)->bc_stack[frames]))
 
#define UMEM_BUFCTL_AUDIT_ALIGN   32
 
#define UMEM_BUFCTL_AUDIT_MAX_SIZE
 
#define UMEM_MAX_STACK_DEPTH
 
#define UMEM_LOCAL_BUFCTL_AUDIT(bcpp)
 
#define UMEM_BUFCTL_AUDIT_SIZE   UMEM_BUFCTL_AUDIT_SIZE_DEPTH(UMEM_STACK_DEPTH)
 
#define UMEM_BUFTAG(cp, buf)   ((umem_buftag_t *)((char *)(buf) + (cp)->cache_buftag))
 
#define UMEM_BUFCTL(cp, buf)   ((umem_bufctl_t *)((char *)(buf) + (cp)->cache_bufctl))
 
#define UMEM_BUF(cp, bcp)   ((void *)((char *)(bcp) - (cp)->cache_bufctl))
 
#define UMEM_SLAB(cp, buf)   ((umem_slab_t *)P2END((uintptr_t)(buf), (cp)->cache_slabsize) - 1)
 
#define UMEM_CPU_CACHE(cp, cpu)   (umem_cpu_cache_t *)((char *)cp + cpu->cpu_cache_offset)
 
#define UMEM_MAGAZINE_VALID(cp, mp)
 
#define UMEM_SLAB_MEMBER(sp, buf)
 
#define UMEM_BUFTAG_ALLOC   0xa110c8edUL
 
#define UMEM_BUFTAG_FREE   0xf4eef4eeUL
 
#define UMEM_HASH_INITIAL   64
 
#define UMEM_HASH(cp, buf)
 
#define UMEM_CPU_CACHE_SIZE   64 /* must be power of 2 */
 
#define UMEM_CPU_PAD
 
#define UMEM_CACHE_SIZE(ncpus)   ((size_t)(&((umem_cache_t *)0)->cache_cpu[ncpus]))
 
#define UMEM_CACHE_NAMELEN   31
 
#define UMEM_MAXBUF   16384
 
#define UMEM_ALIGN   8 /* min guaranteed alignment */
 
#define UMEM_ALIGN_SHIFT   3 /* log2(UMEM_ALIGN) */
 
#define UMEM_VOID_FRACTION   8 /* never waste more than 1/8 of slab */
 
#define UMEM_SECOND_ALIGN   UMEM_ALIGN
 
#define MALLOC_MAGIC   0x3a10c000 /* 8-byte tag */
 
#define MEMALIGN_MAGIC   0x3e3a1000
 
#define UMEM_MALLOC_ENCODE(type, sz)   (uint32_t)((type) - (sz))
 
#define UMEM_MALLOC_DECODE(stat, sz)   (uint32_t)((stat) + (sz))
 
#define UMEM_FREE_PATTERN_32   (uint32_t)(UMEM_FREE_PATTERN)
 
#define UMU_MAGAZINE_RESIZE   0x00000001
 
#define UMU_HASH_RESCALE   0x00000002
 
#define UMU_REAP   0x00000004
 
#define UMU_NOTIFY   0x08000000
 
#define UMU_ACTIVE   0x80000000
 
#define UMEM_READY_INIT_FAILED   -1
 
#define UMEM_READY_STARTUP   1
 
#define UMEM_READY_INITING   2
 
#define UMEM_READY   3
 

Typedefs

typedef struct umem_bufctl umem_bufctl_t
 
typedef struct umem_bufctl_audit umem_bufctl_audit_t
 
typedef struct umem_buftag umem_buftag_t
 
typedef struct umem_slab umem_slab_t
 
typedef struct umem_magazine umem_magazine_t
 
typedef struct umem_magtype umem_magtype_t
 
typedef struct umem_cpu_cache umem_cpu_cache_t
 
typedef struct umem_maglist umem_maglist_t
 
typedef struct umem_cpu_log_header umem_cpu_log_header_t
 
typedef struct umem_log_header umem_log_header_t
 
typedef struct umem_cpu umem_cpu_t
 

Macro Definition Documentation

#define MALLOC_MAGIC   0x3a10c000 /* 8-byte tag */

Referenced by malloc().

#define MEMALIGN_MAGIC   0x3e3a1000

Referenced by memalign().

#define UMC_INTERNAL   0x80000000

Referenced by umem_cache_create().

#define UMC_QCACHE   0x00100000

Referenced by umem_cache_create(), and vmem_create().

#define UMEM_ALIGN   8 /* min guaranteed alignment */
#define UMEM_ALIGN_SHIFT   3 /* log2(UMEM_ALIGN) */
#define UMEM_BUF (   cp,
  bcp 
)    ((void *)((char *)(bcp) - (cp)->cache_bufctl))
#define UMEM_BUFCTL (   cp,
  buf 
)    ((umem_bufctl_t *)((char *)(buf) + (cp)->cache_bufctl))
#define UMEM_BUFCTL_AUDIT_ALIGN   32
#define UMEM_BUFCTL_AUDIT_MAX_SIZE
Value:
(P2ALIGN((PAGESIZE - sizeof (umem_slab_t))/2 - \
#define UMEM_BUFCTL_AUDIT_ALIGN
Definition: umem_impl.h:140
#define P2ALIGN(x, align)
Definition: sol_compat.h:148
#define PAGESIZE
Definition: umem_base.h:42
Definition: umem_impl.h:174
Definition: umem_impl.h:206
#define UMEM_BUFCTL_AUDIT_SIZE   UMEM_BUFCTL_AUDIT_SIZE_DEPTH(UMEM_STACK_DEPTH)
#define UMEM_BUFCTL_AUDIT_SIZE_DEPTH (   frames)    ((size_t)(&((umem_bufctl_audit_t *)0)->bc_stack[frames]))
#define UMEM_BUFTAG (   cp,
  buf 
)    ((umem_buftag_t *)((char *)(buf) + (cp)->cache_buftag))
#define UMEM_BUFTAG_ALLOC   0xa110c8edUL
#define UMEM_BUFTAG_FREE   0xf4eef4eeUL
#define UMEM_CACHE_NAMELEN   31
#define UMEM_CACHE_SIZE (   ncpus)    ((size_t)(&((umem_cache_t *)0)->cache_cpu[ncpus]))
#define UMEM_CPU_CACHE (   cp,
  cpu 
)    (umem_cpu_cache_t *)((char *)cp + cpu->cpu_cache_offset)
#define UMEM_CPU_CACHE_SIZE   64 /* must be power of 2 */

Referenced by umem_cache_create(), and umem_init().

#define UMEM_CPU_PAD
Value:
2 * sizeof (uint_t) - 2 * sizeof (void *) - 4 * sizeof (int))
#define UMEM_CPU_CACHE_SIZE
Definition: umem_impl.h:241
pthread_mutex_t mutex_t
Definition: sol_compat.h:45
uint32_t uint_t
Definition: sol_compat.h:48
#define UMEM_FATAL_FLAGS   (UMEM_NOFAIL)
#define UMEM_FREE_PATTERN   0xdeadbeefdeadbeefULL

Referenced by _umem_free().

#define UMEM_FREE_PATTERN_32   (uint32_t)(UMEM_FREE_PATTERN)
#define UMEM_HASH (   cp,
  buf 
)
Value:
((cp)->cache_hash_table + \
(((uintptr_t)(buf) >> (cp)->cache_hash_shift) & (cp)->cache_hash_mask))
#define UMEM_HASH_INITIAL   64
#define UMEM_LOCAL_BUFCTL_AUDIT (   bcpp)
Value:
*(bcpp) = (umem_bufctl_audit_t *) \
Definition: umem_impl.h:150
#define UMEM_BUFCTL_AUDIT_SIZE
Definition: umem_impl.h:167
#define UMEM_MAGAZINE_VALID (   cp,
  mp 
)
Value:
(((umem_slab_t *)P2END((uintptr_t)(mp), PAGESIZE) - 1)->slab_cache == \
(cp)->cache_magtype->mt_cache)
#define P2END(x, align)
Definition: sol_compat.h:151
#define PAGESIZE
Definition: umem_base.h:42
Definition: umem_impl.h:206
#define UMEM_MALLOC_DECODE (   stat,
  sz 
)    (uint32_t)((stat) + (sz))
#define UMEM_MALLOC_ENCODE (   type,
  sz 
)    (uint32_t)((type) - (sz))

Referenced by malloc(), and memalign().

#define UMEM_MAX_STACK_DEPTH
Value:
UMEM_BUFCTL_AUDIT_SIZE_DEPTH(0)) / sizeof (uintptr_t))
#define UMEM_BUFCTL_AUDIT_MAX_SIZE
Definition: umem_impl.h:142
#define UMEM_BUFCTL_AUDIT_SIZE_DEPTH(frames)
Definition: umem_impl.h:128
#define UMEM_MAXBUF   16384
#define UMEM_READY   3
#define UMEM_READY_INIT_FAILED   -1

Referenced by umem_init().

#define UMEM_READY_INITING   2

Referenced by umem_init().

#define UMEM_READY_STARTUP   1

Referenced by umem_init(), and umem_startup().

#define UMEM_REDZONE_BYTE   0xbb
#define UMEM_REDZONE_PATTERN   0xfeedfacefeedfaceULL

Referenced by _umem_free().

#define UMEM_SECOND_ALIGN   UMEM_ALIGN

Referenced by malloc(), memalign(), and umem_cache_create().

#define UMEM_SIZE_DECODE (   x)    ((x) / 251)
#define UMEM_SIZE_ENCODE (   x)    (251 * (x) + 1)
#define UMEM_SIZE_VALID (   x)    ((x) % 251 == 1)

Referenced by _umem_free().

#define UMEM_SLAB (   cp,
  buf 
)    ((umem_slab_t *)P2END((uintptr_t)(buf), (cp)->cache_slabsize) - 1)
#define UMEM_SLAB_MEMBER (   sp,
  buf 
)
Value:
((size_t)(buf) - (size_t)(sp)->slab_base < \
(sp)->slab_cache->cache_slabsize)
#define UMEM_SLEEP_FLAGS   (0)
#define UMEM_STACK_DEPTH   umem_stack_depth
#define UMEM_UNINITIALIZED_PATTERN   0xbaddcafebaddcafeULL
#define UMEM_VOID_FRACTION   8 /* never waste more than 1/8 of slab */

Referenced by umem_cache_create().

#define UMF_AUDIT   0x00000001 /* transaction auditing */

Referenced by umem_cache_create(), and umem_init().

#define UMF_BUFTAG   (UMF_DEADBEEF | UMF_REDZONE)

Referenced by umem_cache_create().

#define UMF_CHECKSIGNAL   0x00000010 /* abort when in signal context */
#define UMF_CONTENTS   0x00000008 /* freed-buffer content logging */
#define UMF_DEADBEEF   0x00000002 /* deadbeef checking */

Referenced by umem_cache_create().

#define UMF_DEBUG   (UMF_RANDOM | UMF_FIREWALL)

Referenced by umem_cache_create().

#define UMF_FIREWALL   0x00000040 /* put all bufs before unmapped pages */

Referenced by umem_cache_create().

#define UMF_HASH   0x00000200 /* cache has hash table */

Referenced by umem_cache_create().

#define UMF_LITE   0x00000100 /* lightweight debugging */

Referenced by umem_cache_create().

#define UMF_NOMAGAZINE   0x00000020 /* disable per-cpu magazines */

Referenced by umem_cache_create().

#define UMF_RANDOM   (UMF_TOUCH | UMF_AUDIT | UMF_NOMAGAZINE)

Referenced by umem_cache_create().

#define UMF_RANDOMIZE   0x00000400 /* randomize other umem_flags */

Referenced by umem_cache_create().

#define UMF_REDZONE   0x00000004 /* redzone checking */

Referenced by umem_cache_create().

#define UMF_TOUCH   (UMF_BUFTAG | UMF_LITE | UMF_CONTENTS)

Referenced by umem_cache_create().

#define UMU_ACTIVE   0x80000000

Referenced by umem_process_updates().

#define UMU_HASH_RESCALE   0x00000002
#define UMU_MAGAZINE_RESIZE   0x00000001
#define UMU_NOTIFY   0x08000000

Referenced by umem_process_updates().

#define UMU_REAP   0x00000004

Referenced by umem_process_updates(), and umem_reap().

Typedef Documentation

typedef struct umem_bufctl umem_bufctl_t
typedef struct umem_buftag umem_buftag_t
typedef struct umem_cpu umem_cpu_t
typedef struct umem_maglist umem_maglist_t
typedef struct umem_magtype umem_magtype_t
typedef struct umem_slab umem_slab_t