stress-ng  0.13.05
About: stress-ng will stress test a computer system in various selectable ways. It was designed to exercise various physical subsystems of a computer as well as the various operating system kernel interfaces.
  Fossies Dox: stress-ng-0.13.05.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

stress-malloc.c File Reference
#include "stress-ng.h"
Include dependency graph for stress-malloc.c:

Go to the source code of this file.

Data Structures

struct  stress_malloc_args_t
 

Macros

#define MAX_MALLOC_PTHREADS   (32)
 

Functions

static int stress_set_malloc_bytes (const char *opt)
 
static int stress_set_malloc_max (const char *opt)
 
static int stress_set_malloc_threshold (const char *opt)
 
static int stress_set_malloc_pthreads (const char *opt)
 
static int stress_set_malloc_touch (const char *opt)
 
static size_t stress_alloc_size (const size_t size)
 
static void stress_malloc_page_touch (uint8_t *buffer, const size_t size, const size_t page_size)
 
static uint64_t stress_malloc_racy_count (const uint64_t *counters)
 
static bool stress_malloc_keep_stressing (const stress_args_t *args, uint64_t *counters)
 
static void * stress_malloc_loop (void *ptr)
 
static int stress_malloc_child (const stress_args_t *args, void *context)
 
static int stress_malloc (const stress_args_t *args)
 

Variables

static size_t malloc_max
 
static size_t malloc_bytes
 
static size_t malloc_pthreads
 
static bool malloc_touch
 
static const stress_help_t help []
 
static const stress_opt_set_func_t opt_set_funcs []
 
stressor_info_t stress_malloc_info
 

Macro Definition Documentation

◆ MAX_MALLOC_PTHREADS

#define MAX_MALLOC_PTHREADS   (32)

Definition at line 27 of file stress-malloc.c.

Function Documentation

◆ stress_alloc_size()

static size_t stress_alloc_size ( const size_t  size)
inlinestatic

Definition at line 120 of file stress-malloc.c.

References stress_mwc64().

Referenced by stress_malloc_loop().

◆ stress_malloc()

◆ stress_malloc_child()

◆ stress_malloc_keep_stressing()

static bool stress_malloc_keep_stressing ( const stress_args_t args,
uint64_t *  counters 
)
static

◆ stress_malloc_loop()

◆ stress_malloc_page_touch()

static void stress_malloc_page_touch ( uint8_t *  buffer,
const size_t  size,
const size_t  page_size 
)
static

◆ stress_malloc_racy_count()

static uint64_t stress_malloc_racy_count ( const uint64_t *  counters)
static

Definition at line 150 of file stress-malloc.c.

References malloc_pthreads.

Referenced by stress_malloc_child(), and stress_malloc_keep_stressing().

◆ stress_set_malloc_bytes()

static int stress_set_malloc_bytes ( const char *  opt)
static

◆ stress_set_malloc_max()

static int stress_set_malloc_max ( const char *  opt)
static

◆ stress_set_malloc_pthreads()

static int stress_set_malloc_pthreads ( const char *  opt)
static

◆ stress_set_malloc_threshold()

static int stress_set_malloc_threshold ( const char *  opt)
static

◆ stress_set_malloc_touch()

static int stress_set_malloc_touch ( const char *  opt)
static

Definition at line 107 of file stress-malloc.c.

References stress_set_setting(), and TYPE_ID_BOOL.

Variable Documentation

◆ help

const stress_help_t help[]
static
Initial value:
= {
{ NULL, "malloc N", "start N workers exercising malloc/realloc/free" },
{ NULL, "malloc-bytes N", "allocate up to N bytes per allocation" },
{ NULL, "malloc-max N", "keep up to N allocations at a time" },
{ NULL, "malloc-ops N", "stop after N malloc bogo operations" },
{ NULL, "malloc-thresh N", "threshold where malloc uses mmap instead of sbrk" },
{ NULL, "malloc-pthreads N", "number of pthreads to run concurrently" },
{ NULL, "malloc-touch", "touch pages force pages to be populated" },
{ NULL, NULL, NULL }
}

Definition at line 56 of file stress-malloc.c.

◆ malloc_bytes

size_t malloc_bytes
static

Definition at line 30 of file stress-malloc.c.

Referenced by stress_malloc(), and stress_malloc_loop().

◆ malloc_max

size_t malloc_max
static

Definition at line 29 of file stress-malloc.c.

Referenced by stress_malloc(), and stress_malloc_loop().

◆ malloc_pthreads

size_t malloc_pthreads
static

Definition at line 34 of file stress-malloc.c.

Referenced by stress_malloc(), stress_malloc_child(), and stress_malloc_racy_count().

◆ malloc_touch

bool malloc_touch
static

Definition at line 40 of file stress-malloc.c.

Referenced by stress_malloc(), and stress_malloc_page_touch().

◆ opt_set_funcs

const stress_opt_set_func_t opt_set_funcs[]
static
Initial value:
= {
{ 0, NULL }
}
static int stress_set_malloc_threshold(const char *opt)
Definition: stress-malloc.c:87
static int stress_set_malloc_pthreads(const char *opt)
Definition: stress-malloc.c:97
static int stress_set_malloc_touch(const char *opt)
static int stress_set_malloc_max(const char *opt)
Definition: stress-malloc.c:77
static int stress_set_malloc_bytes(const char *opt)
Definition: stress-malloc.c:67
@ OPT_malloc_threshold
Definition: stress-ng.h:3181
@ OPT_malloc_pthreads
Definition: stress-ng.h:3180
@ OPT_malloc_bytes
Definition: stress-ng.h:3178
@ OPT_malloc_touch
Definition: stress-ng.h:3182
@ OPT_malloc_max
Definition: stress-ng.h:3179

Definition at line 363 of file stress-malloc.c.

◆ stress_malloc_info

stressor_info_t stress_malloc_info
Initial value:
= {
.stressor = stress_malloc,
.class = (1UL << 2 ) | (1UL << 1 ) | (1UL << 6 ) | (1UL << 8 ) ,
.opt_set_funcs = opt_set_funcs,
.help = help
}
static const stress_opt_set_func_t opt_set_funcs[]
static int stress_malloc(const stress_args_t *args)
static const stress_help_t help[]
Definition: stress-malloc.c:56

Definition at line 372 of file stress-malloc.c.