Motr  M0
timer.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #include "ut/ut.h" /* M0_UT_ASSERT */
24 #include "lib/time.h" /* m0_time_t */
25 #include "lib/timer.h" /* m0_timer */
26 #include "lib/assert.h" /* M0_ASSERT */
27 #include "lib/thread.h" /* M0_THREAD_INIT */
28 #include "lib/semaphore.h" /* m0_semaphore */
29 #include "lib/memory.h" /* M0_ALLOC_ARR */
30 #include "lib/atomic.h" /* m0_atomic64 */
31 #include "lib/ub.h" /* m0_ub_set */
32 #include "lib/trace.h" /* M0_LOG */
33 
34 #include <stdlib.h> /* rand */
35 #include <unistd.h> /* syscall */
36 #include <sys/syscall.h> /* syscall */
37 
38 enum {
39  NR_TIMERS = 8, /* number of timers in tests */
40  NR_TG = 8, /* number of thread groups */
41  NR_THREADS_TG = 8, /* number of worker threads per thread group */
42  NR_TIMERS_TG = 50, /* number of timers per thread group */
43 };
44 
45 struct thread_group;
46 
47 struct tg_worker {
48  pid_t tgs_tid;
52 };
53 
54 struct tg_timer {
59 };
60 
61 struct thread_group {
70  unsigned int tg_seed;
71 };
72 
73 static pid_t loc_default_tid;
75 
76 static pid_t test_locality_tid;
78 
80 
81 static pid_t _gettid()
82 {
83  return syscall(SYS_gettid);
84 }
85 
86 static m0_time_t make_time(int ms)
87 {
88  return m0_time(ms / 1000, ms % 1000 * 1000000);
89 }
90 
91 static m0_time_t make_time_abs(int ms)
92 {
93  return m0_time_add(m0_time_now(), make_time(ms));
94 }
95 
96 static int time_rand_ms(int min_ms, int max_ms)
97 {
98  return min_ms + (rand() * 1. / RAND_MAX) * (max_ms - min_ms);
99 }
100 
101 static void sem_init_zero(struct m0_semaphore *sem)
102 {
103  int rc = m0_semaphore_init(sem, 0);
104  M0_UT_ASSERT(rc == 0);
105 }
106 
107 static unsigned long timer_callback(unsigned long data)
108 {
110  return 0;
111 }
112 
129 static void test_timers(enum m0_timer_type timer_type, int nr_timers,
130  int interval_min_ms, int interval_max_ms,
131  int wait_time_ms, int callbacks_min, int callbacks_max)
132 {
133  struct m0_timer *timers;
134  int i;
135  int time;
136  int rc;
137  m0_time_t wait;
138  m0_time_t rem;
139 
141  srand(0);
142  M0_ALLOC_ARR(timers, nr_timers);
143  M0_UT_ASSERT(timers != NULL);
144  if (timers == NULL)
145  return;
146 
147  /* m0_timer_init() */
148  for (i = 0; i < nr_timers; ++i) {
149  time = time_rand_ms(interval_min_ms, interval_max_ms);
150  rc = m0_timer_init(&timers[i], timer_type, NULL,
151  timer_callback, i);
152  M0_UT_ASSERT(rc == 0);
153  }
154  /* m0_timer_start() */
155  for (i = 0; i < nr_timers; ++i)
156  m0_timer_start(&timers[i], make_time_abs(time));
157  /* wait some time */
158  wait = make_time(wait_time_ms);
159  do {
160  rc = m0_nanosleep(wait, &rem);
161  wait = rem;
162  } while (rc != 0);
163  /* m0_timer_stop() */
164  for (i = 0; i < nr_timers; ++i)
165  m0_timer_stop(&timers[i]);
166  /* m0_timer_fini() */
167  for (i = 0; i < nr_timers; ++i)
168  m0_timer_fini(&timers[i]);
169 
170  M0_UT_ASSERT(m0_atomic64_get(&callbacks_executed) >= callbacks_min);
171  M0_UT_ASSERT(m0_atomic64_get(&callbacks_executed) <= callbacks_max);
172 
173  m0_free(timers);
174 }
175 
176 static unsigned long locality_default_callback(unsigned long data)
177 {
180  return 0;
181 }
182 
183 /*
184  * This test will be successful iff it is called from process main thread.
185  */
187 {
188  int rc;
189  struct m0_timer timer;
190 
191  rc = m0_timer_init(&timer, M0_TIMER_HARD, NULL,
193  M0_UT_ASSERT(rc == 0);
194 
196 
198  m0_timer_start(&timer, make_time_abs(100));
200 
201  m0_timer_stop(&timer);
202 
204  m0_timer_fini(&timer);
205 }
206 
207 static unsigned long locality_test_callback(unsigned long data)
208 {
209  M0_ASSERT(data >= 0);
212  return 0;
213 }
214 
215 static void timer_locality_test(int nr_timers,
216  int interval_min_ms, int interval_max_ms)
217 {
218  int i;
219  int rc;
220  struct m0_timer *timers;
221  struct m0_timer_locality loc = {};
222  int time;
223 
224  M0_ALLOC_ARR(timers, nr_timers);
225  M0_UT_ASSERT(timers != NULL);
226  if (timers == NULL)
227  return;
228 
229  M0_ALLOC_ARR(test_locality_lock, nr_timers);
231  if (test_locality_lock == NULL)
232  goto free_timers;
233 
235  for (i = 0; i < nr_timers; ++i)
237 
239  rc = m0_timer_thread_attach(&loc);
240  M0_UT_ASSERT(rc == 0);
241 
242  /* m0_timer_init() */
243  for (i = 0; i < nr_timers; ++i) {
244  time = time_rand_ms(interval_min_ms, interval_max_ms);
245  rc = m0_timer_init(&timers[i], M0_TIMER_HARD, &loc,
247  M0_UT_ASSERT(rc == 0);
248  }
249 
250  /* m0_timer_start() */
251  for (i = 0; i < nr_timers; ++i)
252  m0_timer_start(&timers[i], make_time_abs(time));
253 
254  for (i = 0; i < nr_timers; ++i)
256 
257  /* m0_timer_stop(), m0_timer_fini() */
258  for (i = 0; i < nr_timers; ++i) {
259  m0_timer_stop(&timers[i]);
260  m0_timer_fini(&timers[i]);
262  }
263 
266 
268 free_timers:
269  m0_free(timers);
270 }
271 
272 /*
273  It isn't safe to use M0_UT_ASSERT() in signal handler code,
274  therefore instead of M0_UT_ASSERT() was used M0_ASSERT().
275  */
276 static unsigned long test_timer_callback_mt(unsigned long data)
277 {
278  struct tg_timer *tgt = (struct tg_timer *)data;
279  bool found = false;
280  pid_t tid = _gettid();
281  int i;
282 
283  M0_ASSERT(tgt != NULL);
284  /* check thread ID */
285  for (i = 0; i < NR_THREADS_TG; ++i)
286  if (tgt->tgt_group->tg_workers[i].tgs_tid == tid) {
287  found = true;
288  break;
289  }
290  M0_ASSERT(found);
291  /* callback is done */
292  m0_semaphore_up(&tgt->tgt_done);
293  return 0;
294 }
295 
296 static void test_timer_worker_mt(struct tg_worker *worker)
297 {
298  int rc;
299 
300  worker->tgs_tid = _gettid();
301  /* add worker thread to locality */
303  M0_UT_ASSERT(rc == 0);
304  /* signal to controller thread about init */
305  m0_semaphore_up(&worker->tgs_sem_init);
306 
307  /* now m0_timer callback can be executed in this thread context */
308 
309  /* wait for controller thread */
311  /* remove current thread from thread group locality */
313 }
314 
315 static void test_timer_controller_mt(struct thread_group *tg)
316 {
317  int i;
318  int rc;
319  struct tg_timer *tgt;
320 
321  /* init() all worker semaphores */
322  for (i = 0; i < NR_THREADS_TG; ++i) {
325  }
326  /* init() timer locality */
328  /* init() and start all worker threads */
329  for (i = 0; i < NR_THREADS_TG; ++i) {
330  tg->tg_workers[i].tgs_group = tg;
331  rc = M0_THREAD_INIT(&tg->tg_threads[i], struct tg_worker *,
333  &tg->tg_workers[i], "timer worker #%d", i);
334  M0_UT_ASSERT(rc == 0);
335  }
336  /* wait until all workers initialized */
337  for (i = 0; i < NR_THREADS_TG; ++i)
339  /* init() all timers */
340  for (i = 0; i < NR_TIMERS_TG; ++i) {
341  tgt = &tg->tg_timers[i];
342  tgt->tgt_group = tg;
343  /* expiration time is in [now + 1, now + 100] ms range */
344  tgt->tgt_expire = m0_time_from_now(0,
345  (1 + rand_r(&tg->tg_seed) % 100) *
346  1000000);
347  /* init timer semaphore */
348  sem_init_zero(&tgt->tgt_done);
349  /* `unsigned long' must have enough space to contain `void*' */
350  M0_CASSERT(sizeof(unsigned long) >= sizeof(void *));
351  /*
352  * create timer.
353  * parameter for callback is pointer to corresponding
354  * `struct tg_timer'
355  */
357  &tg->tg_loc,
358  test_timer_callback_mt, (unsigned long) tgt);
359  M0_UT_ASSERT(rc == 0);
360  }
361  /* synchronize with all controller threads */
364  /* start() all timers */
365  for (i = 0; i < NR_TIMERS_TG; ++i)
366  m0_timer_start(&tg->tg_timers[i].tgt_timer, tgt->tgt_expire);
367  /* wait for all timers */
368  for (i = 0; i < NR_TIMERS_TG; ++i)
370  /* stop() all timers */
371  for (i = 0; i < NR_TIMERS_TG; ++i)
373  /* fini() all timers */
374  for (i = 0; i < NR_TIMERS_TG; ++i) {
377  }
378  /* resume all workers */
379  for (i = 0; i < NR_THREADS_TG; ++i)
381  /* fini() all worker threads */
382  for (i = 0; i < NR_THREADS_TG; ++i) {
383  rc = m0_thread_join(&tg->tg_threads[i]);
384  M0_UT_ASSERT(rc == 0);
385  m0_thread_fini(&tg->tg_threads[i]);
386  }
387  /* fini() thread group locality */
389  /* fini() all worker semaphores */
390  for (i = 0; i < NR_THREADS_TG; ++i) {
393  }
394  /* signal to main thread */
396 }
397 
423 {
424  int i;
425  int rc;
426  static struct thread_group tg[NR_TG];
427 
428  /* init() all semaphores */
429  for (i = 0; i < NR_TG; ++i) {
433  }
434 
435  /* init RNG seeds for thread groups */
436  for (i = 0; i < NR_TG; ++i)
437  tg[i].tg_seed = i;
438 
439  /* start all controllers from every thread group */
440  for (i = 0; i < NR_TG; ++i) {
441  rc = M0_THREAD_INIT(&tg[i].tg_controller, struct thread_group *,
443  &tg[i], "timer ctrller");
444  M0_UT_ASSERT(rc == 0);
445  }
446 
447  /* wait for controllers initializing */
448  for (i = 0; i < NR_TG; ++i)
450 
451  /* resume all controllers */
452  for (i = 0; i < NR_TG; ++i)
454 
455  /* wait for finishing */
456  for (i = 0; i < NR_TG; ++i)
458 
459  /* fini() all semaphores and controller threads */
460  for (i = 0; i < NR_TG; ++i) {
464 
466  M0_UT_ASSERT(rc == 0);
468  }
469 }
470 
471 void test_timer(void)
472 {
473  int i;
474  int j;
475  enum m0_timer_type timer_types[2] = {M0_TIMER_SOFT, M0_TIMER_HARD};
476 
477  /* soft and hard timers tests */
478  for (j = 0; j < 2; ++j)
479  for (i = 1; i < NR_TIMERS; ++i) {
480  /* simple test */
481  test_timers(timer_types[j], i, 0, 10, 5, 0, i);
482  /* zero-time test */
483  test_timers(timer_types[j], i, 0, 0, 50, i, i);
484  /* cancel-timer-before-callback-executed test */
485  test_timers(timer_types[j], i, 10000, 10000, 50, 0, 0);
486  }
487  /* simple hard timer default locality test */
489  /* test many hard timers in locality */
490  for (i = 1; i < NR_TIMERS; ++i)
491  timer_locality_test(i, 10, 30);
492  /* hard timer test in multithreaded environment */
494 }
495 
496 enum { UB_TIMER_NR = 0x1 };
497 
503 
504 unsigned long timer_ub_callback_dummy(unsigned long unused)
505 {
506  return 0;
507 }
508 
509 static int timers_ub_init(const char *opts)
510 {
511  return 0;
512 }
513 
514 static void timers_ub_fini(void)
515 {
516 }
517 
518 static void timer_ub__init(int index)
519 {
521  timer_ub_cb, index);
522  M0_UB_ASSERT(rc == 0);
523 }
524 
525 static void timer_ub__fini(int index)
526 {
528 }
529 
530 static void timer_ub__start(int index)
531 {
533 }
534 
535 static void timer_ub__stop(int index)
536 {
538 }
539 
540 static void timer_ub_for_each(void (*func)(int index))
541 {
542  int i;
543 
544  for (i = 0; i < UB_TIMER_NR; ++i)
545  func(i);
546 }
547 
548 static void timer_ub_init_dummy(void)
549 {
552 }
553 
554 static void timer_ub_soft_init_dummy(void)
555 {
558 }
559 
560 static void timer_ub_hard_init_dummy(void)
561 {
564 }
565 
566 static void timer_ub_soft_init_all(void)
567 {
570 }
571 
572 static void timer_ub_hard_init_all(void)
573 {
576 }
577 
579 {
582 }
583 
585 {
588 }
589 
590 static void timer_ub_fini_dummy(void)
591 {
592 }
593 
594 static void timer_ub_fini_all(void)
595 {
597 }
598 
599 static void timer_ub_stop_fini_all(void)
600 {
603 }
604 
605 static void timer_ub_start_stop(int index)
606 {
609 }
610 
612 {
616 }
617 
619 {
624 }
625 
626 unsigned long timer_ub_callback(unsigned long index)
627 {
629  return 0;
630 }
631 
632 static void timer_ub__init_cb(int index)
633 {
634  int rc;
635 
638  M0_UB_ASSERT(rc == 0);
639 }
640 
641 static void timer_ub__fini_cb(int index)
642 {
645 }
646 
647 static void timer_ub_init_cb_dummy(void)
648 {
651 }
652 
653 static void timer_ub_soft_init_cb_all(void)
654 {
658 }
659 
660 static void timer_ub_hard_init_cb_all(void)
661 {
665 }
666 
668 {
671 }
672 
674 {
677 }
678 
680 {
683 }
684 
685 static void timer_ub_fini_cb_all(void)
686 {
688 }
689 
690 static void timer_ub_stop_fini_cb_all(void)
691 {
694 }
695 
697 {
700 }
701 
703 {
711 }
712 
713 #define TIMER_UB(name, init, round, fini) (struct m0_ub_bench) { \
714  .ub_name = name, \
715  .ub_iter = UB_TIMER_NR, \
716  .ub_init = timer_ub_##init, \
717  .ub_fini = timer_ub_##fini, \
718  .ub_round = timer_ub_##round, \
719 }
720 
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)
724 
725 /*
726  * <init>-fini
727  * init-<fini>
728  * init-<start>-stop-fini
729  * init-start-<stop>-fini
730  * init-<start-stop>-fini
731  * <init-start-stop>-fini
732  * <init-start-stop-fini>
733  * init-<start-callback>-stop-fini
734  * init-start-<callback-stop>-fini
735  * <init-start-callback-stop-fini>
736  */
738  .us_name = "timer-ub",
739  .us_init = timers_ub_init,
740  .us_fini = timers_ub_fini,
741  .us_run = {
742  TIMER_UB2("<init>-fini", init_dummy, _init, fini_all),
743  TIMER_UB2("init-<fini>", init_all, _fini, fini_dummy),
744  TIMER_UB2("init-<start>-stop-fini",
745  init_all, _start, stop_fini_all),
746  TIMER_UB2("init-start-<stop>-fini",
747  init_start_all, _stop, fini_all),
748  TIMER_UB2("init-<start-stop>-fini",
749  init_all, start_stop, fini_all),
750  TIMER_UB2("<init-start-stop>-fini",
751  init_dummy, init_start_stop, fini_all),
752  TIMER_UB2("<init-start-stop-fini>",
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,
760  fini_dummy),
761  { .ub_name = NULL }
762  }
763 };
764 
765 #undef TIMER_UB
766 #undef TIMER_UB2
767 
768 /*
769  * Local variables:
770  * c-indentation-style: "K&R"
771  * c-basic-offset: 8
772  * tab-width: 8
773  * fill-column: 80
774  * scroll-step: 1
775  * End:
776  */
M0_INTERNAL void m0_timer_locality_fini(struct m0_timer_locality *loc)
Definition: timer.c:84
struct tg_worker tg_workers[NR_THREADS_TG]
Definition: timer.c:64
static void m0_atomic64_inc(struct m0_atomic64 *a)
M0_INTERNAL int m0_timer_thread_attach(struct m0_timer_locality *loc)
Definition: timer.c:127
static void timer_ub_soft_init_start_all(void)
Definition: timer.c:578
struct m0_semaphore tgt_done
Definition: timer.c:58
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
static struct m0_semaphore wait
Definition: item.c:151
static void timer_locality_default_test()
Definition: timer.c:186
static void test_timer_worker_mt(struct tg_worker *worker)
Definition: timer.c:296
static unsigned long test_timer_callback_mt(unsigned long data)
Definition: timer.c:276
static m0_time_t make_time_abs(int ms)
Definition: timer.c:91
static void timer_ub__fini_cb(int index)
Definition: timer.c:641
static unsigned long locality_test_callback(unsigned long data)
Definition: timer.c:207
static void timer_ub__start(int index)
Definition: timer.c:530
#define NULL
Definition: misc.h:38
static void timer_ub__stop(int index)
Definition: timer.c:535
struct m0_semaphore tg_sem_done
Definition: timer.c:67
struct tg_timer tg_timers[NR_TIMERS_TG]
Definition: timer.c:68
struct thread_group * tgt_group
Definition: timer.c:56
struct m0_ub_set m0_timer_ub
Definition: timer.c:737
static struct m0_timer timer_ub_timers[UB_TIMER_NR]
Definition: timer.c:498
static struct m0_semaphore sem
Definition: cp.c:32
int m0_thread_join(struct m0_thread *q)
Definition: kthread.c:169
#define M0_UB_ASSERT(cond)
Definition: ub.h:37
static void timer_ub_soft_init_cb_all(void)
Definition: timer.c:653
const m0_time_t M0_TIME_NEVER
Definition: time.c:108
static void _fini(void)
Definition: ub.c:456
uint64_t m0_time_t
Definition: time.h:37
static void timer_ub_hard_init_start_all(void)
Definition: timer.c:584
static void sem_init_zero(struct m0_semaphore *sem)
Definition: timer.c:101
#define M0_CASSERT(cond)
static unsigned long timer_callback(unsigned long data)
Definition: timer.c:107
static void timer_ub__init_cb(int index)
Definition: timer.c:632
static pid_t _gettid()
Definition: timer.c:81
static struct m0_semaphore * test_locality_lock
Definition: timer.c:77
struct m0_bufvec data
Definition: di.c:40
static void timers_ub_fini(void)
Definition: timer.c:514
static struct m0_semaphore loc_default_lock
Definition: timer.c:74
struct m0_semaphore tgs_sem_resume
Definition: timer.c:50
M0_INTERNAL void m0_timer_thread_detach(struct m0_timer_locality *loc)
Definition: timer.c:153
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
Definition: thread.h:139
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)
Definition: timer.c:39
Definition: timer.h:39
struct m0_timer tgt_timer
Definition: timer.c:55
static void timer_ub_for_each(void(*func)(int index))
Definition: timer.c:540
static void _stop(void)
Definition: ub.c:264
m0_time_t m0_time(uint64_t secs, long ns)
Definition: time.c:41
static void timer_ub_stop_fini_all(void)
Definition: timer.c:599
static enum m0_timer_type timer_ub_type
Definition: timer.c:500
M0_INTERNAL void m0_timer_fini(struct m0_timer *timer)
Definition: timer.c:65
static void timer_ub_hard_init_dummy(void)
Definition: timer.c:560
int i
Definition: dir.c:1033
static void timer_ub_soft_init_all(void)
Definition: timer.c:566
static int _start(const char *opts)
Definition: ub.c:234
static void timer_ub__init(int index)
Definition: timer.c:518
static m0_time_t make_time(int ms)
Definition: timer.c:86
static void timer_ub__fini(int index)
Definition: timer.c:525
static pid_t loc_default_tid
Definition: timer.c:73
struct m0_thread tg_threads[NR_THREADS_TG]
Definition: timer.c:63
static void timer_ub_soft_init_dummy(void)
Definition: timer.c:554
M0_INTERNAL void m0_timer_stop(struct m0_timer *timer)
Definition: timer.c:86
#define M0_ASSERT(cond)
const char * us_name
Definition: ub.h:76
M0_INTERNAL void m0_timer_start(struct m0_timer *timer, m0_time_t expire)
Definition: timer.c:75
m0_time_t m0_time_now(void)
Definition: time.c:134
unsigned int tg_seed
Definition: timer.c:70
unsigned long timer_ub_callback(unsigned long index)
Definition: timer.c:626
static void timer_ub_hard_init_all(void)
Definition: timer.c:572
int rand(void)
void m0_thread_fini(struct m0_thread *q)
Definition: thread.c:92
static unsigned long locality_default_callback(unsigned long data)
Definition: timer.c:176
m0_time_t tgt_expire
Definition: timer.c:57
static void timer_ub_init_dummy(void)
Definition: timer.c:548
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
Definition: semaphore.c:38
static void timer_ub_soft_init_start_cb_all(void)
Definition: timer.c:667
#define TIMER_UB2(name, init, round, fini)
Definition: timer.c:721
m0_timer_type
Definition: timer.h:103
static int timers_ub_init(const char *opts)
Definition: timer.c:509
static void timer_ub_init_cb_dummy(void)
Definition: timer.c:647
static void test_timer_controller_mt(struct thread_group *tg)
Definition: timer.c:315
static void test_timer_many_timers_mt()
Definition: timer.c:422
static struct m0_semaphore timer_ub_semaphores[UB_TIMER_NR]
Definition: timer.c:499
struct thread_group * tgs_group
Definition: timer.c:51
m0_time_t m0_time_add(const m0_time_t t1, const m0_time_t t2)
Definition: time.c:47
static m0_timer_callback_t timer_ub_cb
Definition: timer.c:502
unsigned long(* m0_timer_callback_t)(unsigned long data)
Definition: timer.h:96
static int64_t m0_atomic64_get(const struct m0_atomic64 *a)
static void start_stop(void)
Definition: iter_ut.c:712
static void timer_ub_callback_stop(int index)
Definition: timer.c:696
static void timer_ub_start_callback(int index)
Definition: timer.c:679
struct m0_pdclust_tgt_addr tgt
Definition: fd.c:110
static m0_time_t timer_ub_expiration
Definition: timer.c:501
static void timer_ub_hard_init_cb_all(void)
Definition: timer.c:660
static void timer_locality_test(int nr_timers, int interval_min_ms, int interval_max_ms)
Definition: timer.c:215
static void timer_ub_fini_cb_all(void)
Definition: timer.c:685
static void timer_ub_stop_fini_cb_all(void)
Definition: timer.c:690
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
Definition: semaphore.c:45
static void timer_ub_fini_dummy(void)
Definition: timer.c:590
static void timer_ub_init_start_stop_fini(int index)
Definition: timer.c:618
m0_time_t m0_time_from_now(uint64_t secs, long ns)
Definition: time.c:96
static struct m0_atomic64 callbacks_executed
Definition: timer.c:79
struct m0_timer_locality tg_loc
Definition: timer.c:69
struct m0_semaphore tg_sem_init
Definition: timer.c:65
static void timer_ub_init_start_callback_stop_fini(int index)
Definition: timer.c:702
struct m0_semaphore tg_sem_resume
Definition: timer.c:66
static void timer_ub_hard_init_start_cb_all(void)
Definition: timer.c:673
static uint64_t found
Definition: base.c:376
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)
Definition: timer.c:129
M0_INTERNAL void m0_timer_locality_init(struct m0_timer_locality *loc)
Definition: timer.c:75
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
Definition: semaphore.c:49
static void timer_ub_fini_all(void)
Definition: timer.c:594
struct m0_semaphore tgs_sem_init
Definition: timer.c:49
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
Definition: semaphore.c:65
unsigned long timer_ub_callback_dummy(unsigned long unused)
Definition: timer.c:504
void m0_free(void *data)
Definition: memory.c:146
pid_t tgs_tid
Definition: timer.c:48
int32_t rc
Definition: trigger_fop.h:47
Definition: timer.c:54
Definition: ub.h:74
#define M0_UT_ASSERT(a)
Definition: ut.h:46
Definition: timer.c:40
static void timer_ub_init_start_stop(int index)
Definition: timer.c:611
static void m0_atomic64_set(struct m0_atomic64 *a, int64_t num)
void test_timer(void)
Definition: timer.c:471
static void timer_ub_start_stop(int index)
Definition: timer.c:605
static void _init(bool mkfs, bool use_small_credits)
Definition: service_ut.c:137
struct m0_thread tg_controller
Definition: timer.c:62
static int time_rand_ms(int min_ms, int max_ms)
Definition: timer.c:96
static pid_t test_locality_tid
Definition: timer.c:76
int m0_nanosleep(const m0_time_t req, m0_time_t *rem)
Definition: ktime.c:73