Motr  M0
ub.c File Reference
#include "lib/trace.h"
#include "fop/fom_long_lock.h"
#include "fop/fom_generic.h"
#include "reqh/reqh.h"
#include "reqh/reqh_service.h"
#include "rpc/rpc_opcodes.h"
#include "lib/memory.h"
#include "lib/ub.h"
#include "ut/ut.h"
Include dependency graph for ub.c:

Go to the source code of this file.

Data Structures

struct  ub_fom
 

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_UT
 
#define _UB_ROUND_DEFINE(name, test)
 

Enumerations

enum  { ST_NR_FOMS = 20000, ST_WRITER_PERIOD = 1000, ST_CYCLES_DEFAULT = 50, ST_CYCLES_BYTES = ST_CYCLES_DEFAULT * 20 }
 
enum  scenario {
  SC_MEM_B, SC_MEM_KB, SC_MEM_MB, SC_MUTEX,
  SC_MUTEX_PER_CPU, SC_LONG_LOCK, SC_BLOCK, SC_NR
}
 

Functions

static void cpu_utilize (const struct ub_fom *mach)
 
static void cpu_utilize_with_lock (struct ub_fom *mach, size_t lock_idx)
 
static int mem_tick (struct m0_fom *fom)
 
static int mutex_tick (struct m0_fom *fom)
 
static int mutex_per_cpu_tick (struct m0_fom *fom)
 
static int long_lock_tick (struct m0_fom *fom)
 
static int block_tick (struct m0_fom *fom)
 
static size_t mem_mask (enum scenario test)
 
static size_t cycles (enum scenario test)
 
static int dummy_service_start (struct m0_reqh_service *service)
 
static void dummy_service_stop (struct m0_reqh_service *service)
 
static void dummy_service_fini (struct m0_reqh_service *service)
 
static int dummy_service_allocate (struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
 
static void ub_fom_fini (struct m0_fom *fom)
 
static int ub_fom_tick (struct m0_fom *fom)
 
static size_t ub_fom_home_locality (const struct m0_fom *fom)
 
static void ub_fom_create (struct m0_fom **out, struct m0_reqh *reqh, size_t seqn, enum scenario test)
 
static void reqh_fom_add (struct m0_reqh *reqh, size_t seqn, enum scenario test)
 
static void reqh_test (struct m0_reqh *reqh, enum scenario test)
 
 _UB_ROUND_DEFINE (ub_fom_mem_b, SC_MEM_B)
 
 _UB_ROUND_DEFINE (ub_fom_mem_kb, SC_MEM_KB)
 
 _UB_ROUND_DEFINE (ub_fom_mem_mb, SC_MEM_MB)
 
 _UB_ROUND_DEFINE (ub_fom_mutex, SC_MUTEX)
 
 _UB_ROUND_DEFINE (ub_fom_mutex_per_cpu, SC_MUTEX_PER_CPU)
 
 _UB_ROUND_DEFINE (ub_fom_long_lock, SC_LONG_LOCK)
 
 _UB_ROUND_DEFINE (ub_fom_block, SC_BLOCK)
 
static int _init (const char *opts M0_UNUSED)
 
static void _fini (void)
 

Variables

static struct m0_reqh g_reqh
 
static struct m0_reqh_serviceg_svc
 
static char g_mem [8 *(1<< 20)]
 
static struct m0_mutexg_mutexes
 
static size_t g_mutexes_nr
 
static struct m0_long_lock g_long_lock
 
static int(* ticks [SC_NR])(struct m0_fom *fom)
 
static const struct m0_reqh_service_ops dummy_service_ops
 
static const struct m0_reqh_service_type_ops _stype_ops
 
struct m0_reqh_service_type ub_fom_stype
 
static const struct m0_fom_ops ub_fom_ops
 
static struct m0_fom_type ub_fom_type
 
static const struct m0_fom_type_ops ub_fom_type_ops
 
struct m0_ub_set m0_fom_ub
 

Macro Definition Documentation

◆ _UB_ROUND_DEFINE

#define _UB_ROUND_DEFINE (   name,
  test 
)
Value:
static void name(int iter) \
{ \
reqh_test(&g_reqh, test); \
} \
struct __ ## name ## _semicolon_catcher
const char * name
Definition: trace.c:110
static struct m0_reqh g_reqh
Definition: ub.c:34
Definition: list.c:42

Definition at line 393 of file ub.c.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_UT

Definition at line 22 of file ub.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Benchmark presets.

Enumerator
ST_NR_FOMS 

How many FOMs should a benchmark add to a request handler.

ST_WRITER_PERIOD 

Reciprocal for the frequency of writer locks.

ST_CYCLES_DEFAULT 

Default number of cpu_utilize() loop iterations.

ST_CYCLES_BYTES 

The number of cpu_utilize() iterations for SC_MEM_B scenario.

Definition at line 43 of file ub.c.

◆ scenario

enum scenario

Types of benchmarks.

Enumerator
SC_MEM_B 

Accessing bytes of memory.

SC_MEM_KB 

Accessing kilobytes of memory.

SC_MEM_MB 

Accessing megabytes of memory.

SC_MUTEX 

Taking and releasing a mutex.

SC_MUTEX_PER_CPU 

Taking and releasing mutexes — one mutex per locality.

SC_LONG_LOCK 

Taking and releasing a long lock.

SC_BLOCK 

Calling m0_fom_block_{enter,leave}().

SC_NR 

Definition at line 58 of file ub.c.

Function Documentation

◆ _fini()

static void _fini ( void  )
static

Definition at line 456 of file ub.c.

Here is the call graph for this function:

◆ _init()

static int _init ( const char *opts  M0_UNUSED)
static

Definition at line 414 of file ub.c.

Here is the call graph for this function:

◆ _UB_ROUND_DEFINE() [1/7]

_UB_ROUND_DEFINE ( ub_fom_mem_b  ,
SC_MEM_B   
)

◆ _UB_ROUND_DEFINE() [2/7]

_UB_ROUND_DEFINE ( ub_fom_mem_kb  ,
SC_MEM_KB   
)

◆ _UB_ROUND_DEFINE() [3/7]

_UB_ROUND_DEFINE ( ub_fom_mem_mb  ,
SC_MEM_MB   
)

◆ _UB_ROUND_DEFINE() [4/7]

_UB_ROUND_DEFINE ( ub_fom_mutex  ,
SC_MUTEX   
)

◆ _UB_ROUND_DEFINE() [5/7]

_UB_ROUND_DEFINE ( ub_fom_mutex_per_cpu  ,
SC_MUTEX_PER_CPU   
)

◆ _UB_ROUND_DEFINE() [6/7]

_UB_ROUND_DEFINE ( ub_fom_long_lock  ,
SC_LONG_LOCK   
)

◆ _UB_ROUND_DEFINE() [7/7]

_UB_ROUND_DEFINE ( ub_fom_block  ,
SC_BLOCK   
)

◆ block_tick()

static int block_tick ( struct m0_fom fom)
static

I/O overhead: m0_loc_thread creation.

Definition at line 189 of file ub.c.

Here is the call graph for this function:

◆ cpu_utilize()

static void cpu_utilize ( const struct ub_fom mach)
static

Performs raw memory operations.

Definition at line 215 of file ub.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cpu_utilize_with_lock()

static void cpu_utilize_with_lock ( struct ub_fom mach,
size_t  lock_idx 
)
static

Definition at line 104 of file ub.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cycles()

static size_t cycles ( enum scenario  test)
static

Definition at line 209 of file ub.c.

Here is the caller graph for this function:

◆ dummy_service_allocate()

static int dummy_service_allocate ( struct m0_reqh_service **  service,
const struct m0_reqh_service_type stype 
)
static

Definition at line 283 of file ub.c.

◆ dummy_service_fini()

static void dummy_service_fini ( struct m0_reqh_service service)
static

Definition at line 271 of file ub.c.

Here is the call graph for this function:

◆ dummy_service_start()

static int dummy_service_start ( struct m0_reqh_service service)
static

Definition at line 260 of file ub.c.

◆ dummy_service_stop()

static void dummy_service_stop ( struct m0_reqh_service service)
static

Definition at line 266 of file ub.c.

◆ long_lock_tick()

static int long_lock_tick ( struct m0_fom fom)
static

I/O overhead: acquisition of m0_long_lock shared between localities.

Definition at line 156 of file ub.c.

Here is the call graph for this function:

◆ mem_mask()

static size_t mem_mask ( enum scenario  test)
static

Definition at line 199 of file ub.c.

Here is the caller graph for this function:

◆ mem_tick()

static int mem_tick ( struct m0_fom fom)
static

No I/O overhead.

Definition at line 114 of file ub.c.

Here is the call graph for this function:

◆ mutex_per_cpu_tick()

static int mutex_per_cpu_tick ( struct m0_fom fom)
static

I/O overhead: several FOMs of one locality may contend for the same mutex.

Acquires the mutex associated with current locality and not shared with other localities. There is no concurrency with other FOMs of current locality, because a locality runs its ->fo_tick()s sequentially.

Definition at line 145 of file ub.c.

Here is the call graph for this function:

◆ mutex_tick()

static int mutex_tick ( struct m0_fom fom)
static

I/O overhead: acquisition of mutex shared between localities.

Definition at line 128 of file ub.c.

Here is the call graph for this function:

◆ reqh_fom_add()

static void reqh_fom_add ( struct m0_reqh reqh,
size_t  seqn,
enum scenario  test 
)
static

Definition at line 368 of file ub.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_test()

static void reqh_test ( struct m0_reqh reqh,
enum scenario  test 
)
static

Creates dummy FOMs and adds them to request handler's queue.

Definition at line 381 of file ub.c.

Here is the call graph for this function:

◆ ub_fom_create()

static void ub_fom_create ( struct m0_fom **  out,
struct m0_reqh reqh,
size_t  seqn,
enum scenario  test 
)
static

Definition at line 351 of file ub.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ub_fom_fini()

static void ub_fom_fini ( struct m0_fom fom)
static

Definition at line 314 of file ub.c.

Here is the call graph for this function:

◆ ub_fom_home_locality()

static size_t ub_fom_home_locality ( const struct m0_fom fom)
static

Definition at line 331 of file ub.c.

Here is the call graph for this function:

◆ ub_fom_tick()

static int ub_fom_tick ( struct m0_fom fom)
static

Definition at line 323 of file ub.c.

Variable Documentation

◆ _stype_ops

const struct m0_reqh_service_type_ops _stype_ops
static
Initial value:
= {
.rsto_service_allocate = dummy_service_allocate
}
static int dummy_service_allocate(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
Definition: ub.c:283

Definition at line 300 of file ub.c.

◆ dummy_service_ops

const struct m0_reqh_service_ops dummy_service_ops
static
Initial value:
= {
.rso_start = dummy_service_start,
.rso_stop = dummy_service_stop,
.rso_fini = dummy_service_fini
}
static void dummy_service_stop(struct m0_reqh_service *service)
Definition: ub.c:266
static int dummy_service_start(struct m0_reqh_service *service)
Definition: ub.c:260
static void dummy_service_fini(struct m0_reqh_service *service)
Definition: ub.c:271

Definition at line 277 of file ub.c.

◆ g_long_lock

struct m0_long_lock g_long_lock
static

Definition at line 40 of file ub.c.

◆ g_mem

char g_mem[8 *(1<< 20)]
static

Definition at line 37 of file ub.c.

◆ g_mutexes

struct m0_mutex* g_mutexes
static

Definition at line 38 of file ub.c.

◆ g_mutexes_nr

size_t g_mutexes_nr
static

Definition at line 39 of file ub.c.

◆ g_reqh

struct m0_reqh g_reqh
static

Definition at line 34 of file ub.c.

◆ g_svc

struct m0_reqh_service* g_svc
static

Definition at line 35 of file ub.c.

◆ m0_fom_ub

struct m0_ub_set m0_fom_ub

Definition at line 474 of file ub.c.

◆ ticks

int(* ticks[SC_NR])(struct m0_fom *fom)
static
Initial value:
= {
}
Definition: ub.c:66
static int block_tick(struct m0_fom *fom)
Definition: ub.c:189
Definition: ub.c:60
static int long_lock_tick(struct m0_fom *fom)
Definition: ub.c:156
static int mutex_per_cpu_tick(struct m0_fom *fom)
Definition: ub.c:145
Definition: ub.c:63
static int mutex_tick(struct m0_fom *fom)
Definition: ub.c:128
Definition: ub.c:69
Definition: ub.c:78
static int mem_tick(struct m0_fom *fom)
Definition: ub.c:114

Definition at line 246 of file ub.c.

◆ ub_fom_ops

const struct m0_fom_ops ub_fom_ops
static
Initial value:
= {
.fo_fini = ub_fom_fini,
.fo_tick = ub_fom_tick,
.fo_home_locality = ub_fom_home_locality
}
static int ub_fom_tick(struct m0_fom *fom)
Definition: ub.c:323
static size_t ub_fom_home_locality(const struct m0_fom *fom)
Definition: ub.c:331
static void ub_fom_fini(struct m0_fom *fom)
Definition: ub.c:314

Definition at line 339 of file ub.c.

◆ ub_fom_stype

struct m0_reqh_service_type ub_fom_stype
Initial value:
= {
.rst_name = "ub-fom-service",
.rst_ops = &_stype_ops,
.rst_level = M0_RS_LEVEL_NORMAL,
}
static const struct m0_reqh_service_type_ops _stype_ops
Definition: ub.c:300

Definition at line 304 of file ub.c.

◆ ub_fom_type

struct m0_fom_type ub_fom_type
static

Definition at line 345 of file ub.c.

◆ ub_fom_type_ops

const struct m0_fom_type_ops ub_fom_type_ops
static
Initial value:
= {
.fto_create = NULL
}
#define NULL
Definition: misc.h:38

Definition at line 347 of file ub.c.