epoll-ctl.c (b746a1a2860f4a918f32d10dc569115d282aaf2f) epoll-ctl.c (e4d9b04b973b2dbce7b42af95ea70d07da1c936d)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2018 Davidlohr Bueso.
4 *
5 * Benchmark the various operations allowed for epoll_ctl(2).
6 * The idea is to concurrently stress a single epoll instance
7 */
8#ifdef HAVE_EVENTFD

--- 21 unchanged lines hidden (view full) ---

30
31#include <err.h>
32
33#define printinfo(fmt, arg...) \
34 do { if (__verbose) printf(fmt, ## arg); } while (0)
35
36static unsigned int nthreads = 0;
37static unsigned int nsecs = 8;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2018 Davidlohr Bueso.
4 *
5 * Benchmark the various operations allowed for epoll_ctl(2).
6 * The idea is to concurrently stress a single epoll instance
7 */
8#ifdef HAVE_EVENTFD

--- 21 unchanged lines hidden (view full) ---

30
31#include <err.h>
32
33#define printinfo(fmt, arg...) \
34 do { if (__verbose) printf(fmt, ## arg); } while (0)
35
36static unsigned int nthreads = 0;
37static unsigned int nsecs = 8;
38struct timeval start, end, runtime;
39static bool done, __verbose, randomize;
40
41/*
42 * epoll related shared variables.
43 */
44
45/* Maximum number of nesting allowed inside epoll sets */
46#define EPOLL_MAXNESTS 4

--- 42 unchanged lines hidden (view full) ---

89};
90
91static void toggle_done(int sig __maybe_unused,
92 siginfo_t *info __maybe_unused,
93 void *uc __maybe_unused)
94{
95 /* inform all threads that we're done for the day */
96 done = true;
38static bool done, __verbose, randomize;
39
40/*
41 * epoll related shared variables.
42 */
43
44/* Maximum number of nesting allowed inside epoll sets */
45#define EPOLL_MAXNESTS 4

--- 42 unchanged lines hidden (view full) ---

88};
89
90static void toggle_done(int sig __maybe_unused,
91 siginfo_t *info __maybe_unused,
92 void *uc __maybe_unused)
93{
94 /* inform all threads that we're done for the day */
95 done = true;
97 gettimeofday(&end, NULL);
98 timersub(&end, &start, &runtime);
96 gettimeofday(&bench__end, NULL);
97 timersub(&bench__end, &bench__start, &bench__runtime);
99}
100
101static void nest_epollfd(void)
102{
103 unsigned int i;
104 struct epoll_event ev;
105
106 if (nested > EPOLL_MAXNESTS)

--- 249 unchanged lines hidden (view full) ---

356 init_stats(&all_stats[i]);
357
358 pthread_mutex_init(&thread_lock, NULL);
359 pthread_cond_init(&thread_parent, NULL);
360 pthread_cond_init(&thread_worker, NULL);
361
362 threads_starting = nthreads;
363
98}
99
100static void nest_epollfd(void)
101{
102 unsigned int i;
103 struct epoll_event ev;
104
105 if (nested > EPOLL_MAXNESTS)

--- 249 unchanged lines hidden (view full) ---

355 init_stats(&all_stats[i]);
356
357 pthread_mutex_init(&thread_lock, NULL);
358 pthread_cond_init(&thread_parent, NULL);
359 pthread_cond_init(&thread_worker, NULL);
360
361 threads_starting = nthreads;
362
364 gettimeofday(&start, NULL);
363 gettimeofday(&bench__start, NULL);
365
366 do_threads(worker, cpu);
367
368 pthread_mutex_lock(&thread_lock);
369 while (threads_starting)
370 pthread_cond_wait(&thread_parent, &thread_lock);
371 pthread_cond_broadcast(&thread_worker);
372 pthread_mutex_unlock(&thread_lock);

--- 43 unchanged lines hidden ---
364
365 do_threads(worker, cpu);
366
367 pthread_mutex_lock(&thread_lock);
368 while (threads_starting)
369 pthread_cond_wait(&thread_parent, &thread_lock);
370 pthread_cond_broadcast(&thread_worker);
371 pthread_mutex_unlock(&thread_lock);

--- 43 unchanged lines hidden ---