Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
mq_perf_tests.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <signal.h>
#include <pthread.h>
#include <sched.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <mqueue.h>
#include <popt.h>

Go to the source code of this file.

Data Structures

struct  test
 

Macros

#define _GNU_SOURCE
 
#define min(a, b)   ((a) < (b) ? (a) : (b))
 
#define MAX_CPUS   64
 
#define MSG_SIZE   16
 
#define TEST1_LOOPS   10000000
 
#define TEST2_LOOPS   100000
 
#define drain_queue()   while (mq_receive(queue, buff, MSG_SIZE, &prio_in) == MSG_SIZE)
 
#define do_untimed_send()
 
#define do_send_recv()
 

Functions

void shutdown (int exit_val, char *err_cause, int line_no)
 
void sig_action_SIGUSR1 (int signum, siginfo_t *info, void *context)
 
void sig_action (int signum, siginfo_t *info, void *context)
 
void increase_limits (void)
 
voidfake_cont_thread (void *arg)
 
voidcont_thread (void *arg)
 
void const_prio (int *prio)
 
void inc_prio (int *prio)
 
void dec_prio (int *prio)
 
void random_prio (int *prio)
 
voidperf_test_thread (void *arg)
 
int main (int argc, char *argv[])
 

Variables

charMAX_MSGS = "/proc/sys/fs/mqueue/msg_max"
 
charMAX_MSGSIZE = "/proc/sys/fs/mqueue/msgsize_max"
 
charcpu_option_string
 
int cpus_to_pin [MAX_CPUS]
 
int num_cpus_to_pin
 
pthread_t cpu_threads [MAX_CPUS]
 
pthread_t main_thread
 
cpu_set_t * cpu_set
 
int cpu_set_size
 
int cpus_online
 
int continuous_mode
 
int continuous_mode_fake
 
struct rlimit saved_limits cur_limits
 
int saved_max_msgs
 
int saved_max_msgsize
 
int cur_max_msgs
 
int cur_max_msgsize
 
FILE * max_msgs
 
FILE * max_msgsize
 
int cur_nice
 
charqueue_path = "/mq_perf_tests"
 
mqd_t queue = -1
 
struct mq_attr result
 
int mq_prio_max
 
struct poptOption options []
 
struct test test2 []
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 23 of file mq_perf_tests.c.

#define do_send_recv ( )
Value:
do { \
clock_gettime(clock, &start); \
if (mq_send(queue, buff, MSG_SIZE, prio_out)) \
shutdown(3, "Test send failure", __LINE__); \
clock_gettime(clock, &middle); \
if (mq_receive(queue, buff, MSG_SIZE, &prio_in) != MSG_SIZE) \
shutdown(3, "Test receive failure", __LINE__); \
clock_gettime(clock, &end); \
nsec = ((middle.tv_sec - start.tv_sec) * 1000000000) + \
(middle.tv_nsec - start.tv_nsec); \
send_total.tv_nsec += nsec; \
if (send_total.tv_nsec >= 1000000000) { \
send_total.tv_sec++; \
send_total.tv_nsec -= 1000000000; \
} \
nsec = ((end.tv_sec - middle.tv_sec) * 1000000000) + \
(end.tv_nsec - middle.tv_nsec); \
recv_total.tv_nsec += nsec; \
if (recv_total.tv_nsec >= 1000000000) { \
recv_total.tv_sec++; \
recv_total.tv_nsec -= 1000000000; \
} \
} while (0)

Definition at line 343 of file mq_perf_tests.c.

#define do_untimed_send ( )
Value:
do { \
if (mq_send(queue, buff, MSG_SIZE, prio_out)) \
shutdown(3, "Test send failure", __LINE__); \
} while (0)

Definition at line 337 of file mq_perf_tests.c.

#define drain_queue ( )    while (mq_receive(queue, buff, MSG_SIZE, &prio_in) == MSG_SIZE)

Definition at line 334 of file mq_perf_tests.c.

#define MAX_CPUS   64

Definition at line 74 of file mq_perf_tests.c.

#define min (   a,
  b 
)    ((a) < (b) ? (a) : (b))

Definition at line 73 of file mq_perf_tests.c.

#define MSG_SIZE   16

Definition at line 84 of file mq_perf_tests.c.

#define TEST1_LOOPS   10000000

Definition at line 85 of file mq_perf_tests.c.

#define TEST2_LOOPS   100000

Definition at line 86 of file mq_perf_tests.c.

Function Documentation

void const_prio ( int prio)

Definition at line 373 of file mq_perf_tests.c.

void* cont_thread ( void arg)

Definition at line 317 of file mq_perf_tests.c.

void dec_prio ( int prio)

Definition at line 384 of file mq_perf_tests.c.

void* fake_cont_thread ( void arg)

Definition at line 304 of file mq_perf_tests.c.

void inc_prio ( int prio)

Definition at line 378 of file mq_perf_tests.c.

void increase_limits ( void  )

Definition at line 519 of file mq_perf_tests.c.

int main ( int  argc,
char argv[] 
)

Definition at line 535 of file mq_perf_tests.c.

void* perf_test_thread ( void arg)

Tests to perform (all done with MSG_SIZE messages):

1) Time to add/remove message with 0 messages on queue 1a) with constant prio 2) Time to add/remove message when queue close to capacity: 2a) with constant prio 2b) with increasing prio 2c) with decreasing prio 2d) with random prio 3) Test limits of priorities honored (double check _SC_MQ_PRIO_MAX)

Definition at line 419 of file mq_perf_tests.c.

void random_prio ( int prio)

Definition at line 390 of file mq_perf_tests.c.

void shutdown ( int  exit_val,
char err_cause,
int  line_no 
)
void sig_action ( int  signum,
siginfo_t info,
void context 
)

Definition at line 220 of file mq_perf_tests.c.

void sig_action_SIGUSR1 ( int  signum,
siginfo_t info,
void context 
)

Definition at line 207 of file mq_perf_tests.c.

Variable Documentation

int continuous_mode

Definition at line 87 of file mq_perf_tests.c.

int continuous_mode_fake

Definition at line 88 of file mq_perf_tests.c.

char* cpu_option_string

Definition at line 75 of file mq_perf_tests.c.

cpu_set_t* cpu_set

Definition at line 80 of file mq_perf_tests.c.

int cpu_set_size

Definition at line 81 of file mq_perf_tests.c.

pthread_t cpu_threads[MAX_CPUS]

Definition at line 78 of file mq_perf_tests.c.

int cpus_online

Definition at line 82 of file mq_perf_tests.c.

int cpus_to_pin[MAX_CPUS]

Definition at line 76 of file mq_perf_tests.c.

struct rlimit saved_limits cur_limits

Definition at line 90 of file mq_perf_tests.c.

int cur_max_msgs

Definition at line 92 of file mq_perf_tests.c.

int cur_max_msgsize

Definition at line 92 of file mq_perf_tests.c.

int cur_nice

Definition at line 94 of file mq_perf_tests.c.

pthread_t main_thread

Definition at line 79 of file mq_perf_tests.c.

char* MAX_MSGS = "/proc/sys/fs/mqueue/msg_max"

Definition at line 70 of file mq_perf_tests.c.

FILE* max_msgs

Definition at line 93 of file mq_perf_tests.c.

char* MAX_MSGSIZE = "/proc/sys/fs/mqueue/msgsize_max"

Definition at line 71 of file mq_perf_tests.c.

FILE * max_msgsize

Definition at line 93 of file mq_perf_tests.c.

int mq_prio_max

Definition at line 98 of file mq_perf_tests.c.

int num_cpus_to_pin

Definition at line 77 of file mq_perf_tests.c.

struct poptOption options[]

Definition at line 100 of file mq_perf_tests.c.

mqd_t queue = -1

Definition at line 96 of file mq_perf_tests.c.

char* queue_path = "/mq_perf_tests"

Definition at line 95 of file mq_perf_tests.c.

struct mq_attr result

Definition at line 97 of file mq_perf_tests.c.

int saved_max_msgs

Definition at line 91 of file mq_perf_tests.c.

int saved_max_msgsize

Definition at line 91 of file mq_perf_tests.c.

struct test test2[]
Initial value:
= {
{"\n\tTest #2a: Time send/recv message, queue full, constant prio\n",
{"\n\tTest #2b: Time send/recv message, queue full, increasing prio\n",
{"\n\tTest #2c: Time send/recv message, queue full, decreasing prio\n",
{"\n\tTest #2d: Time send/recv message, queue full, random prio\n",
}

Definition at line 395 of file mq_perf_tests.c.