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

◆ MALLOC_MAGIC

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

Referenced by malloc().

◆ MEMALIGN_MAGIC

#define MEMALIGN_MAGIC   0x3e3a1000

Referenced by memalign().

◆ UMC_INTERNAL

#define UMC_INTERNAL   0x80000000

Referenced by umem_cache_create().

◆ UMC_QCACHE

#define UMC_QCACHE   0x00100000

Referenced by umem_cache_create().

◆ UMEM_ALIGN

#define UMEM_ALIGN   8 /* min guaranteed alignment */

Referenced by _umem_alloc_align(), and memalign().

◆ UMEM_ALIGN_SHIFT

#define UMEM_ALIGN_SHIFT   3 /* log2(UMEM_ALIGN) */

◆ UMEM_BUF

#define UMEM_BUF (   cp,
  bcp 
)    ((void *)((char *)(bcp) - (cp)->cache_bufctl))

◆ UMEM_BUFCTL

#define UMEM_BUFCTL (   cp,
  buf 
)    ((umem_bufctl_t *)((char *)(buf) + (cp)->cache_bufctl))

◆ UMEM_BUFCTL_AUDIT_ALIGN

#define UMEM_BUFCTL_AUDIT_ALIGN   32

◆ UMEM_BUFCTL_AUDIT_MAX_SIZE

#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

◆ UMEM_BUFCTL_AUDIT_SIZE

#define UMEM_BUFCTL_AUDIT_SIZE   UMEM_BUFCTL_AUDIT_SIZE_DEPTH(UMEM_STACK_DEPTH)

◆ UMEM_BUFCTL_AUDIT_SIZE_DEPTH

#define UMEM_BUFCTL_AUDIT_SIZE_DEPTH (   frames)    ((size_t)(&((umem_bufctl_audit_t *)0)->bc_stack[frames]))

◆ UMEM_BUFTAG

#define UMEM_BUFTAG (   cp,
  buf 
)    ((umem_buftag_t *)((char *)(buf) + (cp)->cache_buftag))

◆ UMEM_BUFTAG_ALLOC

#define UMEM_BUFTAG_ALLOC   0xa110c8edUL

◆ UMEM_BUFTAG_FREE

#define UMEM_BUFTAG_FREE   0xf4eef4eeUL

◆ UMEM_CACHE_NAMELEN

#define UMEM_CACHE_NAMELEN   31

◆ UMEM_CACHE_SIZE

#define UMEM_CACHE_SIZE (   ncpus)    ((size_t)(&((umem_cache_t *)0)->cache_cpu[ncpus]))

Referenced by umem_cache_create().

◆ UMEM_CPU_CACHE

#define UMEM_CPU_CACHE (   cp,
  cpu 
)    (umem_cpu_cache_t *)((char *)cp + cpu->cpu_cache_offset)

◆ UMEM_CPU_CACHE_SIZE

#define UMEM_CPU_CACHE_SIZE   64 /* must be power of 2 */

Referenced by umem_cache_create(), and umem_init().

◆ UMEM_CPU_PAD

#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

◆ UMEM_FATAL_FLAGS

#define UMEM_FATAL_FLAGS   (UMEM_NOFAIL)

◆ UMEM_FREE_PATTERN

#define UMEM_FREE_PATTERN   0xdeadbeefdeadbeefULL

◆ UMEM_FREE_PATTERN_32

#define UMEM_FREE_PATTERN_32   (uint32_t)(UMEM_FREE_PATTERN)

◆ UMEM_HASH

#define UMEM_HASH (   cp,
  buf 
)
Value:
((cp)->cache_hash_table + \
(((uintptr_t)(buf) >> (cp)->cache_hash_shift) & (cp)->cache_hash_mask))

◆ UMEM_HASH_INITIAL

#define UMEM_HASH_INITIAL   64

Referenced by umem_cache_update().

◆ UMEM_LOCAL_BUFCTL_AUDIT

#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

◆ UMEM_MAGAZINE_VALID

#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

◆ UMEM_MALLOC_DECODE

#define UMEM_MALLOC_DECODE (   stat,
  sz 
)    (uint32_t)((stat) + (sz))

◆ UMEM_MALLOC_ENCODE

#define UMEM_MALLOC_ENCODE (   type,
  sz 
)    (uint32_t)((type) - (sz))

Referenced by malloc(), and memalign().

◆ UMEM_MAX_STACK_DEPTH

#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

◆ UMEM_MAXBUF

#define UMEM_MAXBUF   16384

◆ UMEM_READY

#define UMEM_READY   3

◆ UMEM_READY_INIT_FAILED

#define UMEM_READY_INIT_FAILED   -1

Referenced by umem_init().

◆ UMEM_READY_INITING

#define UMEM_READY_INITING   2

Referenced by umem_init().

◆ UMEM_READY_STARTUP

#define UMEM_READY_STARTUP   1

Referenced by umem_init(), and umem_startup().

◆ UMEM_REDZONE_BYTE

#define UMEM_REDZONE_BYTE   0xbb

◆ UMEM_REDZONE_PATTERN

#define UMEM_REDZONE_PATTERN   0xfeedfacefeedfaceULL

◆ UMEM_SECOND_ALIGN

#define UMEM_SECOND_ALIGN   UMEM_ALIGN

Referenced by malloc(), and memalign().

◆ UMEM_SIZE_DECODE

#define UMEM_SIZE_DECODE (   x)    ((x) / 251)

◆ UMEM_SIZE_ENCODE

#define UMEM_SIZE_ENCODE (   x)    (251 * (x) + 1)

◆ UMEM_SIZE_VALID

#define UMEM_SIZE_VALID (   x)    ((x) % 251 == 1)

◆ UMEM_SLAB

#define UMEM_SLAB (   cp,
  buf 
)    ((umem_slab_t *)P2END((uintptr_t)(buf), (cp)->cache_slabsize) - 1)

◆ UMEM_SLAB_MEMBER

#define UMEM_SLAB_MEMBER (   sp,
  buf 
)
Value:
((size_t)(buf) - (size_t)(sp)->slab_base < \
(sp)->slab_cache->cache_slabsize)

◆ UMEM_SLEEP_FLAGS

#define UMEM_SLEEP_FLAGS   (0)

◆ UMEM_STACK_DEPTH

#define UMEM_STACK_DEPTH   umem_stack_depth

◆ UMEM_UNINITIALIZED_PATTERN

#define UMEM_UNINITIALIZED_PATTERN   0xbaddcafebaddcafeULL

◆ UMEM_VOID_FRACTION

#define UMEM_VOID_FRACTION   8 /* never waste more than 1/8 of slab */

◆ UMF_AUDIT

#define UMF_AUDIT   0x00000001 /* transaction auditing */

Referenced by umem_init().

◆ UMF_BUFTAG

#define UMF_BUFTAG   (UMF_DEADBEEF | UMF_REDZONE)

◆ UMF_CHECKSIGNAL

#define UMF_CHECKSIGNAL   0x00000010 /* abort when in signal context */

◆ UMF_CONTENTS

#define UMF_CONTENTS   0x00000008 /* freed-buffer content logging */

◆ UMF_DEADBEEF

#define UMF_DEADBEEF   0x00000002 /* deadbeef checking */

◆ UMF_DEBUG

#define UMF_DEBUG   (UMF_RANDOM | UMF_FIREWALL)

◆ UMF_FIREWALL

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

◆ UMF_HASH

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

Referenced by umem_cache_update().

◆ UMF_LITE

#define UMF_LITE   0x00000100 /* lightweight debugging */

◆ UMF_NOMAGAZINE

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

◆ UMF_RANDOM

#define UMF_RANDOM   (UMF_TOUCH | UMF_AUDIT | UMF_NOMAGAZINE)

◆ UMF_RANDOMIZE

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

◆ UMF_REDZONE

#define UMF_REDZONE   0x00000004 /* redzone checking */

◆ UMF_TOUCH

#define UMF_TOUCH   (UMF_BUFTAG | UMF_LITE | UMF_CONTENTS)

◆ UMU_ACTIVE

#define UMU_ACTIVE   0x80000000

Referenced by umem_process_updates().

◆ UMU_HASH_RESCALE

#define UMU_HASH_RESCALE   0x00000002

◆ UMU_MAGAZINE_RESIZE

#define UMU_MAGAZINE_RESIZE   0x00000001

◆ UMU_NOTIFY

#define UMU_NOTIFY   0x08000000

◆ UMU_REAP

#define UMU_REAP   0x00000004

Typedef Documentation

◆ umem_bufctl_audit_t

◆ umem_bufctl_t

typedef struct umem_bufctl umem_bufctl_t

◆ umem_buftag_t

typedef struct umem_buftag umem_buftag_t

◆ umem_cpu_cache_t

◆ umem_cpu_log_header_t

◆ umem_cpu_t

typedef struct umem_cpu umem_cpu_t

◆ umem_log_header_t

◆ umem_magazine_t

◆ umem_maglist_t

typedef struct umem_maglist umem_maglist_t

◆ umem_magtype_t

typedef struct umem_magtype umem_magtype_t

◆ umem_slab_t

typedef struct umem_slab umem_slab_t