36 #include <sys/syscall.h> 83 return syscall(SYS_gettid);
88 return m0_time(ms / 1000, ms % 1000 * 1000000);
98 return min_ms + (
rand() * 1. / RAND_MAX) * (max_ms - min_ms);
130 int interval_min_ms,
int interval_max_ms,
131 int wait_time_ms,
int callbacks_min,
int callbacks_max)
148 for (
i = 0;
i < nr_timers; ++
i) {
155 for (
i = 0;
i < nr_timers; ++
i)
164 for (
i = 0;
i < nr_timers; ++
i)
167 for (
i = 0;
i < nr_timers; ++
i)
216 int interval_min_ms,
int interval_max_ms)
235 for (
i = 0;
i < nr_timers; ++
i)
243 for (
i = 0;
i < nr_timers; ++
i) {
251 for (
i = 0;
i < nr_timers; ++
i)
254 for (
i = 0;
i < nr_timers; ++
i)
258 for (
i = 0;
i < nr_timers; ++
i) {
286 if (
tgt->tgt_group->tg_workers[
i].tgs_tid == tid) {
345 (1 + rand_r(&tg->
tg_seed) % 100) *
350 M0_CASSERT(
sizeof(
unsigned long) >=
sizeof(
void *));
443 &tg[
i],
"timer ctrller");
478 for (j = 0; j < 2; ++j)
713 #define TIMER_UB(name, init, round, fini) (struct m0_ub_bench) { \ 715 .ub_iter = UB_TIMER_NR, \ 716 .ub_init = timer_ub_##init, \ 717 .ub_fini = timer_ub_##fini, \ 718 .ub_round = timer_ub_##round, \ 721 #define TIMER_UB2(name, init, round, fini) \ 722 TIMER_UB("S-"name, soft_##init, round, fini), \ 723 TIMER_UB("H-"name, hard_##init, round, fini) 745 init_all,
_start, stop_fini_all),
747 init_start_all,
_stop, fini_all),
751 init_dummy, init_start_stop, fini_all),
753 init_dummy, init_start_stop_fini, fini_dummy),
754 TIMER_UB2(
"init-<start-callback>-stop-fini",
755 init_cb_all, start_callback, stop_fini_cb_all),
756 TIMER_UB2(
"init-start-<callback-stop>-fini",
757 init_start_cb_all, callback_stop, fini_cb_all),
758 TIMER_UB2(
"<init-start-callback-stop-fini>",
759 init_dummy, init_start_callback_stop_fini,
M0_INTERNAL void m0_timer_locality_fini(struct m0_timer_locality *loc)
struct tg_worker tg_workers[NR_THREADS_TG]
static void m0_atomic64_inc(struct m0_atomic64 *a)
M0_INTERNAL int m0_timer_thread_attach(struct m0_timer_locality *loc)
static void timer_ub_soft_init_start_all(void)
struct m0_semaphore tgt_done
#define M0_ALLOC_ARR(arr, nr)
static struct m0_semaphore wait
static void timer_locality_default_test()
static void test_timer_worker_mt(struct tg_worker *worker)
static unsigned long test_timer_callback_mt(unsigned long data)
static m0_time_t make_time_abs(int ms)
static void timer_ub__fini_cb(int index)
static unsigned long locality_test_callback(unsigned long data)
static void timer_ub__start(int index)
static void timer_ub__stop(int index)
struct m0_semaphore tg_sem_done
struct tg_timer tg_timers[NR_TIMERS_TG]
struct thread_group * tgt_group
struct m0_ub_set m0_timer_ub
static struct m0_timer timer_ub_timers[UB_TIMER_NR]
static struct m0_semaphore sem
int m0_thread_join(struct m0_thread *q)
#define M0_UB_ASSERT(cond)
static void timer_ub_soft_init_cb_all(void)
const m0_time_t M0_TIME_NEVER
static void timer_ub_hard_init_start_all(void)
static void sem_init_zero(struct m0_semaphore *sem)
static unsigned long timer_callback(unsigned long data)
static void timer_ub__init_cb(int index)
static struct m0_semaphore * test_locality_lock
static void timers_ub_fini(void)
static struct m0_semaphore loc_default_lock
struct m0_semaphore tgs_sem_resume
M0_INTERNAL void m0_timer_thread_detach(struct m0_timer_locality *loc)
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
M0_INTERNAL int m0_timer_init(struct m0_timer *timer, enum m0_timer_type type, struct m0_timer_locality *loc, m0_timer_callback_t callback, unsigned long data)
struct m0_timer tgt_timer
static void timer_ub_for_each(void(*func)(int index))
m0_time_t m0_time(uint64_t secs, long ns)
static void timer_ub_stop_fini_all(void)
static enum m0_timer_type timer_ub_type
M0_INTERNAL void m0_timer_fini(struct m0_timer *timer)
static void timer_ub_hard_init_dummy(void)
static void timer_ub_soft_init_all(void)
static int _start(const char *opts)
static void timer_ub__init(int index)
static m0_time_t make_time(int ms)
static void timer_ub__fini(int index)
static pid_t loc_default_tid
struct m0_thread tg_threads[NR_THREADS_TG]
static void timer_ub_soft_init_dummy(void)
M0_INTERNAL void m0_timer_stop(struct m0_timer *timer)
M0_INTERNAL void m0_timer_start(struct m0_timer *timer, m0_time_t expire)
m0_time_t m0_time_now(void)
unsigned long timer_ub_callback(unsigned long index)
static void timer_ub_hard_init_all(void)
void m0_thread_fini(struct m0_thread *q)
static unsigned long locality_default_callback(unsigned long data)
static void timer_ub_init_dummy(void)
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
static void timer_ub_soft_init_start_cb_all(void)
#define TIMER_UB2(name, init, round, fini)
static int timers_ub_init(const char *opts)
static void timer_ub_init_cb_dummy(void)
static void test_timer_controller_mt(struct thread_group *tg)
static void test_timer_many_timers_mt()
static struct m0_semaphore timer_ub_semaphores[UB_TIMER_NR]
struct thread_group * tgs_group
m0_time_t m0_time_add(const m0_time_t t1, const m0_time_t t2)
static m0_timer_callback_t timer_ub_cb
unsigned long(* m0_timer_callback_t)(unsigned long data)
static int64_t m0_atomic64_get(const struct m0_atomic64 *a)
static void start_stop(void)
static void timer_ub_callback_stop(int index)
static void timer_ub_start_callback(int index)
struct m0_pdclust_tgt_addr tgt
static m0_time_t timer_ub_expiration
static void timer_ub_hard_init_cb_all(void)
static void timer_locality_test(int nr_timers, int interval_min_ms, int interval_max_ms)
static void timer_ub_fini_cb_all(void)
static void timer_ub_stop_fini_cb_all(void)
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
static void timer_ub_fini_dummy(void)
static void timer_ub_init_start_stop_fini(int index)
m0_time_t m0_time_from_now(uint64_t secs, long ns)
static struct m0_atomic64 callbacks_executed
struct m0_timer_locality tg_loc
struct m0_semaphore tg_sem_init
static void timer_ub_init_start_callback_stop_fini(int index)
struct m0_semaphore tg_sem_resume
static void timer_ub_hard_init_start_cb_all(void)
static void test_timers(enum m0_timer_type timer_type, int nr_timers, int interval_min_ms, int interval_max_ms, int wait_time_ms, int callbacks_min, int callbacks_max)
M0_INTERNAL void m0_timer_locality_init(struct m0_timer_locality *loc)
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
static void timer_ub_fini_all(void)
struct m0_semaphore tgs_sem_init
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
unsigned long timer_ub_callback_dummy(unsigned long unused)
static void timer_ub_init_start_stop(int index)
static void m0_atomic64_set(struct m0_atomic64 *a, int64_t num)
static void timer_ub_start_stop(int index)
static void _init(bool mkfs, bool use_small_credits)
struct m0_thread tg_controller
static int time_rand_ms(int min_ms, int max_ms)
static pid_t test_locality_tid
int m0_nanosleep(const m0_time_t req, m0_time_t *rem)