ContainerTracer  0.1
tr-driver.h
Go to the documentation of this file.
1 
25 #ifndef _TR_DRIVER_H
26 #define _TR_DRIVER_H
27 
28 #include <linux/limits.h>
29 #include <unistd.h>
30 #include <sys/types.h>
31 
32 #include <json.h>
33 
34 #include <generic.h>
35 #include <trace_replay.h>
36 
44 #define tr_info_list_traverse(ptr, head) \
45  for (ptr = head; ptr != NULL; ptr = ptr->next)
46 
54 #define tr_json_field_traverse(ptr, begin, end) \
55  for (ptr = begin; ptr != end; ptr++)
56 
57 #ifdef REDHAT_LINUX
58 #pragma message "Compile redhat version"
59 #define TR_CGROUP_PREFIX "/sys/fs/cgroup/"
60 #define TR_CGROUP_WEIGHT_PREFIX "io"
61 #define TR_CGROUP_SET_PID "cgroup.procs"
62 #endif
63 
64 #ifndef REDHAT_LINUX
65 #pragma message "Compile not redhat version"
66 #define TR_CGROUP_PREFIX "/sys/fs/cgroup/blkio/"
67 #define TR_CGROUP_WEIGHT_PREFIX "blkio"
68 #define TR_CGROUP_SET_PID "tasks"
69 #endif
70 
71 #ifdef DEBUG
72 #define tr_print_info(info) \
73  pr_info(INFO, \
74  "\n" \
75  "\t\t[[ current %p ]]\n" \
76  "\t\tpid: %d\n" \
77  "\t\ttime: %u\n" \
78  "\t\tq_depth: %u\n" \
79  "\t\tnr_thread: %u\n" \
80  "\t\tweight: %u\n" \
81  "\t\ttrace_repeat: %u\n" \
82  "\t\twss: %u\n" \
83  "\t\tutilization: %u\n" \
84  "\t\tiosize: %u\n" \
85  "\t\tmqid: %d\n" \
86  "\t\tshmid: %d\n" \
87  "\t\tsemid: %d\n" \
88  "\t\tprefix_cgroup_name: %s\n" \
89  "\t\tscheduler: %s\n" \
90  "\t\tname: %s\n" \
91  "\t\ttrace_replay_path: %s\n" \
92  "\t\ttrace_data_path: %s\n" \
93  "\t\tdevice: %s\n" \
94  "\t\tglobal_config: %p\n" \
95  "\t\tnext: %p\n", \
96  (info), (info)->pid, (info)->time, (info)->q_depth, \
97  (info)->nr_thread, (info)->weight, (info)->trace_repeat, \
98  (info)->wss, (info)->utilization, (info)->iosize, \
99  (info)->mqid, (info)->shmid, (info)->semid, \
100  (info)->prefix_cgroup_name, (info)->scheduler, \
101  (info)->cgroup_id, (info)->trace_replay_path, \
102  (info)->trace_data_path, (info)->device, \
103  (info)->global_config, (info)->next);
104 #endif
105 
106 enum { TR_IPC_NOT_FREE = 0x0,
107  TR_IPC_FREE = 0x1, };
109 
110 enum { TR_NOT_SYNTH = 0,
111  TR_SYNTH = 0x1, };
113 
117 
122  const char *name;
123  const void *member;
124 };
125 
130  struct json_object
131  *trace[MAX_THREADS];
132  struct json_object *per_trace
133  [MAX_THREADS];
134  struct json_object *synthetic
135  [MAX_THREADS];
136  struct json_object
137  *stats[MAX_THREADS];
138 };
139 
143 struct tr_info {
144  pid_t ppid;
145  pid_t pid;
147  unsigned int
149  unsigned int
151  unsigned int nr_thread;
153  unsigned int weight;
155  int mqid;
156  int shmid;
157  int semid;
159  unsigned int trace_repeat;
160  unsigned int wss;
161  unsigned int utilization;
162  unsigned int iosize;
164  char prefix_cgroup_name
165  [NAME_MAX];
166  char device[NAME_MAX];
167  char scheduler[NAME_MAX];
168  char cgroup_id
169  [NAME_MAX];
170  char trace_replay_path[PATH_MAX];
171  char trace_data_path[PATH_MAX];
174  struct tr_info *next;
175 };
176 
177 /* tr-driver.c */
178 int tr_init(void *object);
179 int tr_runner(void);
180 int tr_valid_scheduler_test(const char *scheduler);
181 int tr_has_weight_scheduler(const int scheduler_index);
182 int tr_get_interval(const char *key, char *buffer);
183 int tr_get_total(const char *key, char *buffer);
184 void tr_free(void);
185 
186 /* tr-serializer.c */
187 void tr_total_serializer(const struct tr_info *info,
188  const struct total_results *total, char *buffer);
189 void tr_realtime_serializer(const struct tr_info *info,
190  const struct realtime_log *log, char *buffer);
191 /* tr-info.c */
192 struct tr_info *tr_info_init(struct json_object *setting, int index);
193 
194 /* tr-shm.c */
195 int tr_shm_init(struct tr_info *info);
196 int tr_shm_get(const struct tr_info *info, void *buffer);
197 void tr_shm_free(struct tr_info *info, int flags);
198 
199 /* tr-mq.c */
200 int tr_mq_init(struct tr_info *info);
201 int tr_mq_get(const struct tr_info *info, void *buffer);
202 void tr_mq_free(struct tr_info *info, int flags);
203 
204 #endif
unsigned int time
Definition: tr-driver.h:148
Definition: tr-driver.h:106
void tr_free(void)
Deallocate resources of this driver.
Definition: tr-driver.c:536
int tr_has_weight_scheduler(const int scheduler_index)
Check the parameter&#39;s scheduler_index supports weight.
Definition: tr-driver.c:162
static const char * key[]
Definition: docker-driver-test.c:55
Support structure of the tr_stats_serializer() function.
Definition: tr-driver.h:121
Support structure of the total_results structures which located in include/trace_replay.h.
Definition: tr-driver.h:129
void tr_realtime_serializer(const struct tr_info *info, const struct realtime_log *log, char *buffer)
Converts realtime_log to JSON string.
Definition: tr-serializer.c:399
int shmid
Definition: tr-driver.h:156
int tr_shm_get(const struct tr_info *info, void *buffer)
Retrieve the data from Shared Memory.
Definition: tr-shm.c:241
int tr_mq_init(struct tr_info *info)
Wrapping function of __tr_mq_init()
Definition: tr-mq.c:98
int tr_init(void *object)
Initialize the global configuration and per processes configuration.
Definition: tr-driver.c:182
Definition: tr-driver.h:107
void tr_total_serializer(const struct tr_info *info, const struct total_results *total, char *buffer)
Converts total_results to JSON string.
Definition: tr-serializer.c:427
This structure has the major information of the each process.
Definition: tr-driver.h:143
pid_t pid
Definition: tr-driver.h:145
const void * member
Definition: tr-driver.h:123
void tr_mq_free(struct tr_info *info, int flags)
Deallocate the Message Queue resources.
Definition: tr-mq.c:151
int semid
Definition: tr-driver.h:157
Definition: trace_replay.h:193
Definition: trace_replay.h:239
struct tr_info * tr_info_init(struct json_object *setting, int index)
Generate and construct the per processes info object and return it.
Definition: tr-info.c:232
int tr_valid_scheduler_test(const char *scheduler)
Check the current inputted scheduler text can be supported by the driver.
Definition: tr-driver.c:143
struct tr_info * next
Definition: tr-driver.h:174
Definition: trace_replay.h:160
#define MAX_THREADS
Definition: trace_replay.h:34
int tr_shm_init(struct tr_info *info)
Do the __tr_shm_init() and __tr_sem_init()
Definition: tr-shm.c:201
int tr_get_interval(const char *key, char *buffer)
Get execution-time results from trace-replay.
Definition: tr-driver.c:461
Definition: tr-driver.h:110
Definition: tr-driver.h:115
void * global_config
Definition: tr-driver.h:173
unsigned int q_depth
Definition: tr-driver.h:150
unsigned int trace_repeat
Definition: tr-driver.h:159
Definition: tr-driver.h:111
pid_t ppid
Definition: tr-driver.h:144
void tr_shm_free(struct tr_info *info, int flags)
Deallocate the Shared Memory resources.
Definition: tr-shm.c:266
unsigned int utilization
Definition: tr-driver.h:161
Definition: trace_replay.h:176
int tr_mq_get(const struct tr_info *info, void *buffer)
Retrieve the data from Message Queue.
Definition: tr-mq.c:128
unsigned int nr_thread
Definition: tr-driver.h:151
def info()
Definition: routes.py:6
int tr_get_total(const char *key, char *buffer)
Get end-time results from trace-replay.
Definition: tr-driver.c:502
int tr_runner(void)
Run all processes&#39; trace-replay part.
Definition: tr-driver.c:379
unsigned int wss
Definition: tr-driver.h:160
Definition: tr-driver.h:114
int mqid
Definition: tr-driver.h:155
unsigned int iosize
Definition: tr-driver.h:162
unsigned int weight
Definition: tr-driver.h:153
const char * name
Definition: tr-driver.h:122
char scheduler[NAME_MAX]
Definition: tr-driver.h:167
This header maintain the driver&#39;s mapping information. It&#39;s definition in runner/generic.c.