Motr  M0
Discrete Event Simulator

Data Structures

struct  chs_conf
 
struct  chs_dev
 
struct  client_thread_param
 
struct  client_write_ext
 
struct  client
 
struct  client_conf
 
struct  cnt
 
struct  io_req
 
struct  elevator
 
struct  m0t1fs_thread
 
struct  m0t1fs_client
 
struct  m0t1fs_conf
 
struct  net_conf
 
struct  net_srv
 
struct  net_rpc
 
struct  sim_callout
 
struct  sim
 
struct  sim_thread
 
struct  sim_chan
 
struct  storage_conf
 
struct  storage_dev
 

Macros

#define __MOTR_DESIM_SIM_H__
 

Typedefs

typedef unsigned long long cnt_t
 
typedef unsigned long long sim_time_t
 
typedef int sim_call_t(struct sim_callout *)
 
typedef void sim_func_t(struct sim *, struct sim_thread *, void *)
 
typedef unsigned long long sector_t
 
typedef void(* storage_end_io_t) (struct storage_dev *dev)
 
typedef void(* storage_submit_t) (struct storage_dev *dev, enum storage_req_type type, sector_t sector, unsigned long count)
 

Enumerations

enum  chs_dev_state { CDS_XFER, CDS_IDLE }
 
enum  sim_log_level { SLL_WARN, SLL_INFO, SLL_TRACE, SLL_DEBUG }
 
enum  storage_req_type { SRT_READ, SRT_WRITE }
 
enum  { LBA_D = 10, ROUNDS = 10, TRACK_D = 8, TRACK_S = 2500 }
 

Functions

long long int llabs (long long int j)
 
static void chs_submit (struct storage_dev *dev, enum storage_req_type type, sector_t sector, unsigned long count)
 
M0_INTERNAL void chs_conf_init (struct chs_conf *conf)
 
M0_INTERNAL void chs_conf_fini (struct chs_conf *conf)
 
M0_INTERNAL void chs_dev_init (struct chs_dev *dev, struct sim *sim, struct chs_conf *conf)
 
M0_INTERNAL void chs_dev_fini (struct chs_dev *dev)
 
static unsigned chs_tracks (struct chs_conf *conf, unsigned cyl)
 
static sector_t chs_cylinder_sectors (struct chs_conf *conf, unsigned cyl)
 
static unsigned chs_sector_cylinder (struct chs_conf *conf, sector_t sector)
 
static void chs_sector_to_chs (struct chs_conf *conf, sector_t sector, unsigned *head, unsigned *cylinder, sector_t *sect_in_track)
 
static sim_time_t chs_sect_time (struct chs_conf *conf, unsigned track_sects, unsigned sectors)
 
static sim_time_t chs_req (struct chs_dev *dev, enum storage_req_type type, sector_t sector, long count)
 
static int chs_req_done (struct sim_callout *call)
 
 M0_TL_DESCR_DEFINE (cl, "client write extents", static, struct client_write_ext, cwe_linkage, cwe_magic, M0_DESIM_CLIENT_WRITE_EXT_MAGIC, M0_DESIM_CLIENT_WRITE_EXT_HEAD_MAGIC)
 
 M0_TL_DEFINE (cl, static, struct client_write_ext)
 
static void client_pageout (struct sim *s, struct sim_thread *t, void *arg)
 
static void client_write_loop (struct sim *s, struct sim_thread *t, void *arg)
 
static int client_threads_start (struct sim_callout *call)
 
M0_INTERNAL void client_init (struct sim *s, struct client_conf *conf)
 
M0_INTERNAL void client_fini (struct client_conf *conf)
 
 M0_TL_DESCR_DEFINE (cnts, "counters", static, struct cnt, c_linkage, c_magic, M0_DESIM_CNT_MAGIC, M0_DESIM_CNTS_HEAD_MAGIC)
 
 M0_TL_DEFINE (cnts, static, struct cnt)
 
M0_INTERNAL void cnt_init (struct cnt *cnt, struct cnt *parent, const char *format,...)
 
M0_INTERNAL void cnt_dump (struct cnt *cnt)
 
M0_INTERNAL void cnt_dump_all (void)
 
M0_INTERNAL void cnt_fini (struct cnt *cnt)
 
M0_INTERNAL void cnt_mod (struct cnt *cnt, cnt_t val)
 
M0_INTERNAL void cnt_global_init (void)
 
M0_INTERNAL void cnt_global_fini (void)
 
 M0_TL_DESCR_DEFINE (req, "io requests", static, struct io_req, ir_linkage, ir_magic, M0_DESIM_IO_REQ_MAGIC, M0_DESIM_IO_REQ_HEAD_MAGIC)
 
 M0_TL_DEFINE (req, static, struct io_req)
 
static void elevator_submit (struct elevator *el, enum storage_req_type type, sector_t sector, unsigned long count)
 
static void elevator_go (struct elevator *el)
 
M0_INTERNAL void el_end_io (struct storage_dev *dev)
 
M0_INTERNAL void elevator_init (struct elevator *el, struct storage_dev *dev)
 
M0_INTERNAL void elevator_fini (struct elevator *el)
 
M0_INTERNAL void elevator_io (struct elevator *el, enum storage_req_type type, sector_t sector, unsigned long count)
 
static void thread_loop (struct sim *s, struct sim_thread *t, void *arg)
 
static int threads_start (struct sim_callout *call)
 
static void layout_build (struct m0t1fs_conf *conf)
 
static void m0t1fs_layout_fini (struct m0t1fs_conf *conf)
 
M0_INTERNAL void m0t1fs_init (struct sim *s, struct m0t1fs_conf *conf)
 
M0_INTERNAL void m0t1fs_fini (struct m0t1fs_conf *conf)
 
 M0_TL_DESCR_DEFINE (rpc, "rpcs", static, struct net_rpc, nr_inqueue, nr_magic, M0_DESIM_NET_RPC_MAGIC, M0_DESIM_NET_RPC_HEAD_MAGIC)
 
 M0_TL_DEFINE (rpc, static, struct net_rpc)
 
static void net_srv_loop (struct sim *s, struct sim_thread *t, void *arg)
 
static int net_srv_threads_start (struct sim_callout *call)
 
M0_INTERNAL void net_srv_init (struct sim *s, struct net_srv *srv)
 
M0_INTERNAL void net_srv_fini (struct net_srv *srv)
 
M0_INTERNAL void net_init (struct net_conf *net)
 
M0_INTERNAL void net_fini (struct net_conf *net)
 
M0_INTERNAL void net_rpc_init (struct net_rpc *rpc, struct net_conf *conf, struct net_srv *srv, struct m0_stob_id *stob_id, unsigned long long offset, unsigned long nob)
 
M0_INTERNAL void net_rpc_fini (struct net_rpc *rpc)
 
static void net_enter (struct sim_thread *t, struct net_conf *n, unsigned long nob)
 
static void net_leave (struct sim_thread *t, struct net_conf *n, unsigned long nob)
 
static void net_tx (struct sim_thread *t, struct net_conf *n, unsigned long nob, sim_time_t min, sim_time_t max)
 
M0_INTERNAL void net_rpc_send (struct sim_thread *t, struct net_rpc *rpc)
 
M0_INTERNAL void net_rpc_bulk (struct sim_thread *t, struct net_rpc *rpc)
 
M0_INTERNAL void net_rpc_process (struct sim_thread *t, struct net_conf *net, struct net_srv *srv, struct m0_stob_id *stob_id, unsigned long long offset, unsigned long count)
 
 M0_TL_DESCR_DEFINE (ca, "call-outs", static, struct sim_callout, sc_linkage, sc_magic, M0_DESIM_SIM_CALLOUT_MAGIC, M0_DESIM_SIM_CALLOUT_HEAD_MAGIC)
 
 M0_TL_DEFINE (ca, static, struct sim_callout)
 
 M0_TL_DESCR_DEFINE (sim_thr, "threads", static, struct sim_thread, st_block, st_magic, M0_DESIM_SIM_THREAD_MAGIC, M0_DESIM_SIM_THREAD_HEAD_MAGIC)
 
 M0_TL_DEFINE (sim_thr, static, struct sim_thread)
 
int vasprintf (char **strp, const char *fmt, va_list ap)
 
M0_INTERNAL void * sim_alloc (size_t size)
 
M0_INTERNAL void sim_free (void *ptr)
 
M0_INTERNAL void sim_init (struct sim *state)
 
M0_INTERNAL void sim_fini (struct sim *state)
 
M0_INTERNAL void sim_run (struct sim *state)
 
static void sim_call_place (struct sim *sim, struct sim_callout *call)
 
static void sim_timer_init (struct sim *state, struct sim_callout *call, sim_time_t delta, sim_call_t *cfunc, void *datum)
 
M0_INTERNAL void sim_timer_add (struct sim *state, sim_time_t delta, sim_call_t *cfunc, void *datum)
 
M0_INTERNAL void sim_timer_rearm (struct sim_callout *call, sim_time_t delta, sim_call_t *cfunc, void *datum)
 
static void sim_thread_fix (struct sim_thread *thread)
 
static void sim_thread_resume (struct sim_thread *thread)
 
static void sim_thread_suspend (struct sim_thread *thread)
 
static void * sim_decode (int p0, int p1)
 
static int sim_encode0 (void *p)
 
static int sim_encode1 (void *p)
 
static void sim_trampoline (int func0, int func1, int state0, int state1, int thread0, int thread1, int datum0, int datum1)
 
M0_INTERNAL void sim_thread_init (struct sim *state, struct sim_thread *thread, unsigned stacksize, sim_func_t func, void *arg)
 
M0_INTERNAL void sim_thread_fini (struct sim_thread *thread)
 
M0_INTERNAL void sim_thread_exit (struct sim_thread *thread)
 
static int sim_wakeup (struct sim_callout *call)
 
static void sim_wakeup_post (struct sim *sim, struct sim_thread *thread, sim_time_t nap)
 
M0_INTERNAL void sim_sleep (struct sim_thread *thread, sim_time_t nap)
 
M0_INTERNAL void sim_chan_init (struct sim_chan *chan, char *format,...)
 
M0_INTERNAL void sim_chan_fini (struct sim_chan *chan)
 
M0_INTERNAL void sim_chan_wait (struct sim_chan *chan, struct sim_thread *thread)
 
static void sim_chan_wake_head (struct sim_chan *chan)
 
M0_INTERNAL void sim_chan_signal (struct sim_chan *chan)
 
M0_INTERNAL void sim_chan_broadcast (struct sim_chan *chan)
 
M0_INTERNAL struct sim_threadsim_thread_current (void)
 
M0_INTERNAL unsigned long long sim_rnd (unsigned long long a, unsigned long long b)
 
M0_INTERNAL void sim_name_set (char **name, const char *format,...)
 
M0_INTERNAL void sim_name_vaset (char **name, const char *format, va_list valist)
 
M0_INTERNAL void sim_log (struct sim *s, enum sim_log_level level, const char *format,...)
 
M0_INTERNAL int sim_global_init (void)
 
M0_INTERNAL void sim_global_fini (void)
 
static double seekto (struct sim *s, int64_t sector, int sectors)
 
static void seek_test_thread (struct sim *s, struct sim_thread *t, void *arg)
 
static int seek_test_start (struct sim_callout *co)
 
int main (int argc, char **argv)
 
static void workload_init (struct sim *s, int argc, char **argv)
 
static void workload_fini (void)
 

Variables

static struct m0_tl cnts
 
static struct sim_threadsim_current = NULL
 
static ucontext_t sim_idle_ctx
 
enum sim_log_level sim_log_level = SLL_INFO
 
enum sim_log_level sim_log_level
 
static struct chs_conf ST31000640SS
 
static struct chs_dev disc
 
static struct elevator el
 
static struct sim_thread seek_thr
 
static struct net_conf net
 
static struct net_srv srv0
 
static struct m0t1fs_conf m0t1fs
 
static struct chs_conf ST31000640SS
 
static struct net_conf net
 
static struct net_srv srv
 
static struct client_conf client
 
static struct chs_conf ST31000640SS
 
struct chs_dev disc
 

Detailed Description

Concepts

sim is a very simple discrete event simulator, geared toward simulation of distributed systems.

In sim a model consists of state machines, representing entities in a system being simulated. Software (a client cache, a kernel disc elevator, a thread etc.) as well as hardware (a volatile memory, a hard disc, a network, etc.) entities can be simulated.

A state machine maintains some internal state, receives input events, and sends output messages to state machines. The core task of simulator is to arrange events in the chronological order, given that state transitions and event deliveries take some time, specified by the model. While for some system message exchanging state machines are a natural device of simulation, the most common control flow mechanism—a function call is awkward to express this way. sim provides a built-in support for synchronous state machine interaction.

Data types and interfaces

The most fundamental components of sim are logical time (struct sim) and a future event (struct sim_callout), defined in sim.h.

struct sim represents an instance of simulation, it contains a current logical time (sim::ss_bolt) and a queue of future events (sim::ss_future). sim_run() function executes main simulation loop: it removes an event from head of the future events list and calls its callback function repeatedly until the future queue is empty. Callback functions populate the queue by creating new future events (by calling sim_timer_add()), that are added to the queue in chronological order.

struct sim_callout represents a parametrized event scheduled for some future time ("callout" is a traditional UNIX name for this).

Sequential threads are simulated with two more data types:

struct sim_thread represents a simulated thread. struct sim_chan represents a channel (in UNIX kernel sense) that threads can synchronize on. sim_thread is relatively lightweight. Current implementation is based on ucontext_t calls (getcontext(3), swapcontext(3), etc.). Overhead depends on platform. Mac OS X requires a minimum stack of 32K (16K on Linux).

Threading introduces two distinct modes of execution: in-thread and call-back (the latter is also called a "scheduler mode"). Call-back is a code executed on the stack of main simulation loop. All timer code runs in call-backs. Mode of execution can be distinguished by result of sim_thread_current() function which is non-null only in a thread. New threads can be created only from call-backs.

A "counter" is a simple statistical and measurement interface. A counter (struct cnt) is named on creation. A "measurement" can be added to a counter by a call to cnt_mod(). When simulation finishes, values of all alive counters are dumped onto standard output. A counter reports average and standard deviation (a square root of difference between average of squared measurements and squared average). A counter optionally has a parent counter to which it replicates all its measurements. This can be used to accumulate data across a number of short-lived objects (like RPCs). Histogram capabilities should be added.

Todo:
add m0_ prefixes to sim symbols.

Macro Definition Documentation

◆ __MOTR_DESIM_SIM_H__

#define __MOTR_DESIM_SIM_H__

Definition at line 93 of file sim.h.

Typedef Documentation

◆ cnt_t

typedef unsigned long long cnt_t

Definition at line 34 of file cnt.h.

◆ sector_t

typedef unsigned long long sector_t

Definition at line 34 of file storage.h.

◆ sim_call_t

typedef int sim_call_t(struct sim_callout *)

Definition at line 114 of file sim.h.

◆ sim_func_t

typedef void sim_func_t(struct sim *, struct sim_thread *, void *)

Definition at line 115 of file sim.h.

◆ sim_time_t

typedef unsigned long long sim_time_t

Definition at line 111 of file sim.h.

◆ storage_end_io_t

typedef void(* storage_end_io_t) (struct storage_dev *dev)

Definition at line 47 of file storage.h.

◆ storage_submit_t

typedef void(* storage_submit_t) (struct storage_dev *dev, enum storage_req_type type, sector_t sector, unsigned long count)

Definition at line 48 of file storage.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LBA_D 
ROUNDS 
TRACK_D 
TRACK_S 

Definition at line 115 of file chs_test.c.

◆ chs_dev_state

Enumerator
CDS_XFER 
CDS_IDLE 

Definition at line 71 of file chs.h.

◆ sim_log_level

Enumerator
SLL_WARN 
SLL_INFO 
SLL_TRACE 
SLL_DEBUG 

Definition at line 284 of file sim.h.

◆ storage_req_type

Enumerator
SRT_READ 
SRT_WRITE 

Definition at line 42 of file storage.h.

Function Documentation

◆ chs_conf_fini()

M0_INTERNAL void chs_conf_fini ( struct chs_conf conf)

Definition at line 123 of file chs.c.

Here is the caller graph for this function:

◆ chs_conf_init()

M0_INTERNAL void chs_conf_init ( struct chs_conf conf)

Definition at line 43 of file chs.c.

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

◆ chs_cylinder_sectors()

static sector_t chs_cylinder_sectors ( struct chs_conf conf,
unsigned  cyl 
)
static

Definition at line 168 of file chs.c.

Here is the caller graph for this function:

◆ chs_dev_fini()

M0_INTERNAL void chs_dev_fini ( struct chs_dev dev)

Definition at line 147 of file chs.c.

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

◆ chs_dev_init()

M0_INTERNAL void chs_dev_init ( struct chs_dev dev,
struct sim sim,
struct chs_conf conf 
)

Definition at line 129 of file chs.c.

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

◆ chs_req()

static sim_time_t chs_req ( struct chs_dev dev,
enum storage_req_type  type,
sector_t  sector,
long  count 
)
static

Definition at line 240 of file chs.c.

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

◆ chs_req_done()

static int chs_req_done ( struct sim_callout call)
static

Definition at line 362 of file chs.c.

Here is the caller graph for this function:

◆ chs_sect_time()

static sim_time_t chs_sect_time ( struct chs_conf conf,
unsigned  track_sects,
unsigned  sectors 
)
static

Definition at line 230 of file chs.c.

Here is the caller graph for this function:

◆ chs_sector_cylinder()

static unsigned chs_sector_cylinder ( struct chs_conf conf,
sector_t  sector 
)
static

Definition at line 177 of file chs.c.

Here is the caller graph for this function:

◆ chs_sector_to_chs()

static void chs_sector_to_chs ( struct chs_conf conf,
sector_t  sector,
unsigned *  head,
unsigned *  cylinder,
sector_t sect_in_track 
)
static

Definition at line 204 of file chs.c.

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

◆ chs_submit()

static void chs_submit ( struct storage_dev dev,
enum storage_req_type  type,
sector_t  sector,
unsigned long  count 
)
static

Definition at line 374 of file chs.c.

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

◆ chs_tracks()

static unsigned chs_tracks ( struct chs_conf conf,
unsigned  cyl 
)
static

Definition at line 159 of file chs.c.

Here is the caller graph for this function:

◆ client_fini()

M0_INTERNAL void client_fini ( struct client_conf conf)

Definition at line 177 of file client.c.

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

◆ client_init()

M0_INTERNAL void client_init ( struct sim s,
struct client_conf conf 
)

Definition at line 148 of file client.c.

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

◆ client_pageout()

static void client_pageout ( struct sim s,
struct sim_thread t,
void *  arg 
)
static

Definition at line 53 of file client.c.

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

◆ client_threads_start()

static int client_threads_start ( struct sim_callout call)
static

Definition at line 124 of file client.c.

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

◆ client_write_loop()

static void client_write_loop ( struct sim s,
struct sim_thread t,
void *  arg 
)
static

Definition at line 90 of file client.c.

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

◆ cnt_dump()

M0_INTERNAL void cnt_dump ( struct cnt cnt)

Definition at line 59 of file cnt.c.

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

◆ cnt_dump_all()

M0_INTERNAL void cnt_dump_all ( void  )

Definition at line 74 of file cnt.c.

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

◆ cnt_fini()

M0_INTERNAL void M0_INTERNAL void cnt_fini ( struct cnt cnt)

Definition at line 83 of file cnt.c.

Here is the caller graph for this function:

◆ cnt_global_fini()

M0_INTERNAL void cnt_global_fini ( void  )

Definition at line 110 of file cnt.c.

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

◆ cnt_global_init()

M0_INTERNAL void cnt_global_init ( void  )

Definition at line 105 of file cnt.c.

Here is the caller graph for this function:

◆ cnt_init()

M0_INTERNAL void cnt_init ( struct cnt cnt,
struct cnt parent,
const char *  format,
  ... 
)

Definition at line 44 of file cnt.c.

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

◆ cnt_mod()

M0_INTERNAL void cnt_mod ( struct cnt cnt,
cnt_t  val 
)

Definition at line 92 of file cnt.c.

Here is the caller graph for this function:

◆ el_end_io()

M0_INTERNAL void el_end_io ( struct storage_dev dev)

Definition at line 66 of file elevator.c.

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

◆ elevator_fini()

M0_INTERNAL void elevator_fini ( struct elevator el)

Definition at line 87 of file elevator.c.

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

◆ elevator_go()

static void elevator_go ( struct elevator el)
static

Definition at line 60 of file elevator.c.

Here is the caller graph for this function:

◆ elevator_init()

M0_INTERNAL void elevator_init ( struct elevator el,
struct storage_dev dev 
)

Definition at line 77 of file elevator.c.

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

◆ elevator_io()

M0_INTERNAL void elevator_io ( struct elevator el,
enum storage_req_type  type,
sector_t  sector,
unsigned long  count 
)

Definition at line 93 of file elevator.c.

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

◆ elevator_submit()

static void elevator_submit ( struct elevator el,
enum storage_req_type  type,
sector_t  sector,
unsigned long  count 
)
static

Definition at line 49 of file elevator.c.

Here is the caller graph for this function:

◆ layout_build()

static void layout_build ( struct m0t1fs_conf conf)
static

Definition at line 128 of file m0t1fs.c.

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

◆ llabs()

long long int llabs ( long long int  j)

◆ M0_TL_DEFINE() [1/6]

M0_TL_DEFINE ( rpc  ,
static  ,
struct net_rpc   
)

◆ M0_TL_DEFINE() [2/6]

M0_TL_DEFINE ( cnts  ,
static  ,
struct cnt   
)

◆ M0_TL_DEFINE() [3/6]

M0_TL_DEFINE ( ca  ,
static  ,
struct sim_callout   
)

◆ M0_TL_DEFINE() [4/6]

M0_TL_DEFINE ( req  ,
static  ,
struct io_req   
)

◆ M0_TL_DEFINE() [5/6]

M0_TL_DEFINE ( sim_thr  ,
static  ,
struct sim_thread   
)

◆ M0_TL_DEFINE() [6/6]

M0_TL_DEFINE ( cl  ,
static  ,
struct client_write_ext   
)

◆ M0_TL_DESCR_DEFINE() [1/6]

M0_TL_DESCR_DEFINE ( rpc  ,
"rpcs"  ,
static  ,
struct net_rpc  ,
nr_inqueue  ,
nr_magic  ,
M0_DESIM_NET_RPC_MAGIC  ,
M0_DESIM_NET_RPC_HEAD_MAGIC   
)

◆ M0_TL_DESCR_DEFINE() [2/6]

M0_TL_DESCR_DEFINE ( cnts  ,
"counters"  ,
static  ,
struct cnt  ,
c_linkage  ,
c_magic  ,
M0_DESIM_CNT_MAGIC  ,
M0_DESIM_CNTS_HEAD_MAGIC   
)

◆ M0_TL_DESCR_DEFINE() [3/6]

M0_TL_DESCR_DEFINE ( ca  ,
"call-outs"  ,
static  ,
struct sim_callout  ,
sc_linkage  ,
sc_magic  ,
M0_DESIM_SIM_CALLOUT_MAGIC  ,
M0_DESIM_SIM_CALLOUT_HEAD_MAGIC   
)

◆ M0_TL_DESCR_DEFINE() [4/6]

M0_TL_DESCR_DEFINE ( req  ,
"io requests"  ,
static  ,
struct io_req  ,
ir_linkage  ,
ir_magic  ,
M0_DESIM_IO_REQ_MAGIC  ,
M0_DESIM_IO_REQ_HEAD_MAGIC   
)

◆ M0_TL_DESCR_DEFINE() [5/6]

M0_TL_DESCR_DEFINE ( sim_thr  ,
"threads"  ,
static  ,
struct sim_thread  ,
st_block  ,
st_magic  ,
M0_DESIM_SIM_THREAD_MAGIC  ,
M0_DESIM_SIM_THREAD_HEAD_MAGIC   
)

◆ M0_TL_DESCR_DEFINE() [6/6]

M0_TL_DESCR_DEFINE ( cl  ,
"client write extents"  ,
static  ,
struct client_write_ext  ,
cwe_linkage  ,
cwe_magic  ,
M0_DESIM_CLIENT_WRITE_EXT_MAGIC  ,
M0_DESIM_CLIENT_WRITE_EXT_HEAD_MAGIC   
)

◆ m0t1fs_fini()

M0_INTERNAL void m0t1fs_fini ( struct m0t1fs_conf conf)

Definition at line 237 of file m0t1fs.c.

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

◆ m0t1fs_init()

M0_INTERNAL void m0t1fs_init ( struct sim s,
struct m0t1fs_conf conf 
)

Definition at line 173 of file m0t1fs.c.

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

◆ m0t1fs_layout_fini()

static void m0t1fs_layout_fini ( struct m0t1fs_conf conf)
static

Definition at line 161 of file m0t1fs.c.

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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 213 of file chs_test.c.

Here is the call graph for this function:

◆ net_enter()

static void net_enter ( struct sim_thread t,
struct net_conf n,
unsigned long  nob 
)
static

Definition at line 168 of file net.c.

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

◆ net_fini()

M0_INTERNAL void net_fini ( struct net_conf net)

Definition at line 136 of file net.c.

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

◆ net_init()

M0_INTERNAL void net_init ( struct net_conf net)

Definition at line 129 of file net.c.

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

◆ net_leave()

static void net_leave ( struct sim_thread t,
struct net_conf n,
unsigned long  nob 
)
static

Definition at line 178 of file net.c.

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

◆ net_rpc_bulk()

M0_INTERNAL void net_rpc_bulk ( struct sim_thread t,
struct net_rpc rpc 
)

Definition at line 208 of file net.c.

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

◆ net_rpc_fini()

M0_INTERNAL void net_rpc_fini ( struct net_rpc rpc)

Definition at line 159 of file net.c.

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

◆ net_rpc_init()

M0_INTERNAL void net_rpc_init ( struct net_rpc rpc,
struct net_conf conf,
struct net_srv srv,
struct m0_stob_id stob_id,
unsigned long long  offset,
unsigned long  nob 
)

Definition at line 143 of file net.c.

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

◆ net_rpc_process()

M0_INTERNAL void net_rpc_process ( struct sim_thread t,
struct net_conf net,
struct net_srv srv,
struct m0_stob_id stob_id,
unsigned long long  offset,
unsigned long  count 
)

Definition at line 222 of file net.c.

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

◆ net_rpc_send()

M0_INTERNAL void net_rpc_send ( struct sim_thread t,
struct net_rpc rpc 
)

Definition at line 196 of file net.c.

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

◆ net_srv_fini()

M0_INTERNAL void net_srv_fini ( struct net_srv srv)

Definition at line 110 of file net.c.

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

◆ net_srv_init()

M0_INTERNAL void net_srv_init ( struct sim s,
struct net_srv srv 
)

Definition at line 101 of file net.c.

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

◆ net_srv_loop()

static void net_srv_loop ( struct sim s,
struct sim_thread t,
void *  arg 
)
static

Definition at line 41 of file net.c.

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

◆ net_srv_threads_start()

static int net_srv_threads_start ( struct sim_callout call)
static

Definition at line 89 of file net.c.

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

◆ net_tx()

static void net_tx ( struct sim_thread t,
struct net_conf n,
unsigned long  nob,
sim_time_t  min,
sim_time_t  max 
)
static

Definition at line 188 of file net.c.

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

◆ seek_test_start()

static int seek_test_start ( struct sim_callout co)
static

Definition at line 207 of file chs_test.c.

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

◆ seek_test_thread()

static void seek_test_thread ( struct sim s,
struct sim_thread t,
void *  arg 
)
static

Definition at line 122 of file chs_test.c.

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

◆ seekto()

static double seekto ( struct sim s,
int64_t  sector,
int  sectors 
)
static

Definition at line 106 of file chs_test.c.

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

◆ sim_alloc()

M0_INTERNAL void * sim_alloc ( size_t  size)

Wrapper around malloc(3), aborting the simulation when allocation fails.

Definition at line 85 of file sim.c.

Here is the caller graph for this function:

◆ sim_call_place()

static void sim_call_place ( struct sim sim,
struct sim_callout call 
)
static

Insert a callout in sorted events list.

Definition at line 150 of file sim.c.

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

◆ sim_chan_broadcast()

M0_INTERNAL void sim_chan_broadcast ( struct sim_chan chan)

Wake-up all threads waiting on a channel.

Definition at line 456 of file sim.c.

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

◆ sim_chan_fini()

M0_INTERNAL void M0_INTERNAL void sim_chan_fini ( struct sim_chan chan)

Finalize the channel, releasing its resources.

Definition at line 400 of file sim.c.

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

◆ sim_chan_init()

M0_INTERNAL void sim_chan_init ( struct sim_chan chan,
char *  format,
  ... 
)

Initialize synchronization channel. If format is not-NULL it (after sprintf-ing remaining arguments into it) will be used as a name of statistical counter embedded into the channel. This name is used in the final statistics dump after simulation completes.

Definition at line 385 of file sim.c.

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

◆ sim_chan_signal()

M0_INTERNAL void sim_chan_signal ( struct sim_chan chan)

Wake-up a thread at head of the channel list of waiting threads.

Definition at line 447 of file sim.c.

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

◆ sim_chan_wait()

M0_INTERNAL void sim_chan_wait ( struct sim_chan chan,
struct sim_thread thread 
)

Wait on a channel. This call suspends calling sim_thread until it is woken-up by a sim_chan_{signal,broadcast}() call. The calling thread is added to the tail of the list, so that sim_chan_signal() wakes threads up in FIFO order.

Definition at line 411 of file sim.c.

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

◆ sim_chan_wake_head()

static void sim_chan_wake_head ( struct sim_chan chan)
static

A helper function, waking up a thread at head of the sim_chan::ch_threads list.

Definition at line 435 of file sim.c.

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

◆ sim_decode()

static void* sim_decode ( int  p0,
int  p1 
)
static

Definition at line 260 of file sim.c.

Here is the caller graph for this function:

◆ sim_encode0()

static int sim_encode0 ( void *  p)
static

Definition at line 265 of file sim.c.

Here is the caller graph for this function:

◆ sim_encode1()

static int sim_encode1 ( void *  p)
static

Definition at line 270 of file sim.c.

Here is the caller graph for this function:

◆ sim_fini()

M0_INTERNAL void sim_fini ( struct sim state)

Finalize simulator state.

Definition at line 116 of file sim.c.

Here is the caller graph for this function:

◆ sim_free()

M0_INTERNAL void sim_free ( void *  ptr)

Wrapper around free(3), dual to sim_alloc().

Definition at line 98 of file sim.c.

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

◆ sim_global_fini()

M0_INTERNAL void sim_global_fini ( void  )

Definition at line 549 of file sim.c.

◆ sim_global_init()

M0_INTERNAL void M0_INTERNAL int sim_global_init ( void  )

Definition at line 543 of file sim.c.

◆ sim_init()

M0_INTERNAL void sim_init ( struct sim state)

Initialize simulator state (struct sim).

Definition at line 106 of file sim.c.

Here is the caller graph for this function:

◆ sim_log()

M0_INTERNAL void sim_log ( struct sim s,
enum sim_log_level  level,
const char *  format,
  ... 
)

Write a log message to the console.

Definition at line 527 of file sim.c.

Here is the caller graph for this function:

◆ sim_name_set()

M0_INTERNAL void sim_name_set ( char **  name,
const char *  format,
  ... 
)

Format optional arguments according to the format and store resulting allocated string at a given place, freeing its previous contents if any.

Definition at line 500 of file sim.c.

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

◆ sim_name_vaset()

M0_INTERNAL void M0_INTERNAL void sim_name_vaset ( char **  name,
const char *  format,
va_list  valist 
)

Format arguments in valist according to the format and store resulting allocated string at a given place, freeing its previous contents if any.

Definition at line 513 of file sim.c.

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

◆ sim_rnd()

M0_INTERNAL unsigned long long sim_rnd ( unsigned long long  a,
unsigned long long  b 
)

get a pseudo-random number in the interval [a, b]

Definition at line 471 of file sim.c.

Here is the caller graph for this function:

◆ sim_run()

M0_INTERNAL void sim_run ( struct sim state)

Execute the simulation.

This function runs main simulation loop, taking callouts from simulator logical time queue and executing them. Callouts add other callouts to the queue (ordered by the logical time). The loop exits when the queue becomes empty.

Definition at line 129 of file sim.c.

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

◆ sim_sleep()

M0_INTERNAL void sim_sleep ( struct sim_thread thread,
sim_time_t  nap 
)

Delay thread execution for a given amount of logical time.

Definition at line 372 of file sim.c.

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

◆ sim_thread_current()

M0_INTERNAL struct sim_thread * sim_thread_current ( void  )

Currently executing thread or NULL if in the scheduler mode.

Definition at line 465 of file sim.c.

Here is the caller graph for this function:

◆ sim_thread_exit()

M0_INTERNAL void sim_thread_exit ( struct sim_thread thread)

Exit thread execution. Simulation threads must call this before returning from their top-level function.

Definition at line 346 of file sim.c.

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

◆ sim_thread_fini()

M0_INTERNAL void sim_thread_fini ( struct sim_thread thread)

Finalize thread, releasing its resources (stack).

Definition at line 333 of file sim.c.

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

◆ sim_thread_fix()

static void sim_thread_fix ( struct sim_thread thread)
static

Mac OS X getmcontext() (Libc-498/i386/gen/) resets uc_stack.ss_size incorrectly.

Definition at line 212 of file sim.c.

Here is the caller graph for this function:

◆ sim_thread_init()

M0_INTERNAL void sim_thread_init ( struct sim state,
struct sim_thread thread,
unsigned  stacksize,
sim_func_t  func,
void *  arg 
)

Initialize and start a new simulation thread that will be running a function func with an argument arg.

The newly initialized thread is immediately switched to. This function can be called only in the scheduler mode.

Definition at line 293 of file sim.c.

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

◆ sim_thread_resume()

static void sim_thread_resume ( struct sim_thread thread)
static

Resume a thread by jumping onto its context.

Definition at line 220 of file sim.c.

Here is the caller graph for this function:

◆ sim_thread_suspend()

static void sim_thread_suspend ( struct sim_thread thread)
static

Stash current state of the read (registers) into sim_thread::st_ctx and jump onto main simulation loop context (sim_idle_ctx).

Definition at line 235 of file sim.c.

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

◆ sim_timer_add()

M0_INTERNAL void sim_timer_add ( struct sim state,
sim_time_t  delta,
sim_call_t cfunc,
void *  datum 
)

Allocate and initialize call-out. Allocated call-out will be executed after delta units of simulation logical time by calling cfunc call-back. datum in installed into sim_callout::sc_datum field of a newly allocated call-out.

Definition at line 189 of file sim.c.

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

◆ sim_timer_init()

static void sim_timer_init ( struct sim state,
struct sim_callout call,
sim_time_t  delta,
sim_call_t cfunc,
void *  datum 
)
static

Initialize callout

Definition at line 172 of file sim.c.

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

◆ sim_timer_rearm()

M0_INTERNAL void sim_timer_rearm ( struct sim_callout call,
sim_time_t  delta,
sim_call_t cfunc,
void *  datum 
)

Re-arm already allocated call-out to be executed (possibly again) after delta units of logical time. The call-out must be not in the logical time queue.

Definition at line 202 of file sim.c.

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

◆ sim_trampoline()

static void sim_trampoline ( int  func0,
int  func1,
int  state0,
int  state1,
int  thread0,
int  thread1,
int  datum0,
int  datum1 
)
static

Definition at line 275 of file sim.c.

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

◆ sim_wakeup()

static int sim_wakeup ( struct sim_callout call)
static

Wake-up a thread.

Definition at line 354 of file sim.c.

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

◆ sim_wakeup_post()

static void sim_wakeup_post ( struct sim sim,
struct sim_thread thread,
sim_time_t  nap 
)
static

Schedule a thread wake-up after a given amount of logical time.

Definition at line 363 of file sim.c.

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

◆ thread_loop()

static void thread_loop ( struct sim s,
struct sim_thread t,
void *  arg 
)
static

Definition at line 35 of file m0t1fs.c.

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

◆ threads_start()

static int threads_start ( struct sim_callout call)
static

Definition at line 109 of file m0t1fs.c.

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

◆ vasprintf()

int vasprintf ( char **  strp,
const char *  fmt,
va_list  ap 
)
Here is the caller graph for this function:

◆ workload_fini()

static void workload_fini ( void  )
static

Definition at line 121 of file m0t1fs_test.c.

Here is the call graph for this function:

◆ workload_init()

static void workload_init ( struct sim s,
int  argc,
char **  argv 
)
static

Definition at line 99 of file m0t1fs_test.c.

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

Variable Documentation

◆ client

struct client_conf client
static
Initial value:
= {
.cc_nr_clients = 0,
.cc_nr_threads = 0,
.cc_total = 100*1024*1024,
.cc_count = 1024*1024,
.cc_opt_count = 1024*1024,
.cc_inflight_max = 8,
.cc_delay_min = 0,
.cc_delay_max = 1000000,
.cc_cache_max = ~0UL,
.cc_dirty_max = 32*1024*1024,
.cc_net = &net,
.cc_srv = &srv
}
static struct net_conf net
Definition: net_test.c:39
static struct net_srv srv
Definition: net_test.c:52

Definition at line 59 of file net_test.c.

◆ cnts

struct m0_tl cnts
static

Definition at line 42 of file cnt.c.

◆ disc [1/2]

struct chs_dev disc
static

Definition at line 101 of file chs_test.c.

◆ disc [2/2]

struct chs_dev disc

Definition at line 96 of file net_test.c.

◆ el

struct elevator el
static

Definition at line 102 of file chs_test.c.

◆ m0t1fs

struct m0t1fs_conf m0t1fs
static
Initial value:
= {
.ct_nr_clients = 0,
.ct_nr_threads = 0,
.ct_nr_servers = 0,
.ct_nr_devices = 0,
.ct_N = 8,
.ct_K = 2,
.ct_S = 2,
.ct_unitsize = 4*1024*1024,
.ct_client_step = 0,
.ct_thread_step = 0,
.ct_inflight_max = 8,
.ct_total = 1024*1024*1024,
.ct_delay_min = 0,
.ct_delay_max = 1000000,
.ct_net = &net,
.ct_srv0 = &srv0
}
static struct net_srv srv0
Definition: m0t1fs_test.c:51
static struct net_conf net
Definition: m0t1fs_test.c:38

Definition at line 58 of file m0t1fs_test.c.

◆ net [1/2]

struct net_conf net
static
Initial value:
= {
.nc_frag_size = 4*1024,
.nc_rpc_size = 1024,
.nc_rpc_delay_min = 1000,
.nc_rpc_delay_max = 5000,
.nc_frag_delay_min = 100,
.nc_frag_delay_max = 1000,
.nc_rate_min = 750000000,
.nc_rate_max = 1000000000,
.nc_nob_max = ~0UL,
.nc_msg_max = ~0UL
}

Definition at line 39 of file net_test.c.

◆ net [2/2]

struct net_conf net
static
Initial value:
= {
.nc_frag_size = 4*1024,
.nc_rpc_size = 1024,
.nc_rpc_delay_min = 1000,
.nc_rpc_delay_max = 5000,
.nc_frag_delay_min = 100,
.nc_frag_delay_max = 1000,
.nc_rate_min = 750000000,
.nc_rate_max = 1000000000,
.nc_nob_max = ~0UL,
.nc_msg_max = ~0UL,
}

Definition at line 38 of file m0t1fs_test.c.

◆ seek_thr

struct sim_thread seek_thr
static

Definition at line 104 of file chs_test.c.

◆ sim_current

struct sim_thread* sim_current = NULL
static

Currently executing thread in the thread mode of execution (see struct sim_thread).

Definition at line 71 of file sim.c.

◆ sim_idle_ctx

ucontext_t sim_idle_ctx
static

Scheduler context.

Here the context of a main simulation loop is stored before switching in the thread mode (see struct sim_thread). This context is restored to switch to the scheduler mode.

Definition at line 80 of file sim.c.

◆ sim_log_level [1/2]

Definition at line 522 of file sim.c.

◆ sim_log_level [2/2]

Definition at line 522 of file sim.c.

◆ srv

struct net_srv srv
static
Initial value:
= {
.ns_nr_threads = 64,
.ns_nr_devices = 1,
.ns_pre_bulk_min = 0,
.ns_pre_bulk_max = 1000
}

Definition at line 52 of file net_test.c.

◆ srv0

struct net_srv srv0
static
Initial value:
= {
.ns_nr_threads = 64,
.ns_pre_bulk_min = 0,
.ns_pre_bulk_max = 1000,
.ns_file_size = 1024*1024
}

Definition at line 51 of file m0t1fs_test.c.

◆ ST31000640SS [1/3]

struct chs_conf ST31000640SS
static
Initial value:
= {
.cc_storage = {
.sc_sector_size = 512,
},
.cc_heads = 4*2,
.cc_cylinders = 153352,
.cc_track_skew = 160,
.cc_cylinder_skew = 76,
.cc_sectors_min = 1220,
.cc_sectors_max = 1800,
.cc_cyl_in_zone = 48080,
.cc_seek_avg = 8500000,
.cc_seek_track_to_track = 800000,
.cc_seek_full_stroke = 16000000,
.cc_write_settle = 500000,
.cc_head_switch = 500000,
.cc_command_latency = 0,
.cc_rps = 7200/60
}

Definition at line 79 of file chs_test.c.

◆ ST31000640SS [2/3]

struct chs_conf ST31000640SS
static
Initial value:
= {
.cc_storage = {
.sc_sector_size = 512,
},
.cc_heads = 4*2,
.cc_cylinders = 153352,
.cc_track_skew = 160,
.cc_cylinder_skew = 76,
.cc_sectors_min = 1220,
.cc_sectors_max = 1800,
.cc_cyl_in_zone = 48080,
.cc_seek_avg = 8500000,
.cc_seek_track_to_track = 800000,
.cc_seek_full_stroke = 16000000,
.cc_write_settle = 500000,
.cc_head_switch = 500000,
.cc_command_latency = 0,
.cc_rps = 7200/60
}

Definition at line 74 of file net_test.c.

◆ ST31000640SS [3/3]

struct chs_conf ST31000640SS
static
Initial value:
= {
.cc_storage = {
.sc_sector_size = 512,
},
.cc_heads = 4*2,
.cc_cylinders = 153352,
.cc_track_skew = 160,
.cc_cylinder_skew = 76,
.cc_sectors_min = 1220,
.cc_sectors_max = 1800,
.cc_cyl_in_zone = 48080,
.cc_seek_avg = 8500000,
.cc_seek_track_to_track = 800000,
.cc_seek_full_stroke = 16000000,
.cc_write_settle = 500000,
.cc_head_switch = 500000,
.cc_command_latency = 0,
.cc_rps = 7200/60
}

Definition at line 77 of file m0t1fs_test.c.