ContainerTracer  0.1
Data Structures | Macros | Enumerations | Functions
tr-driver.h File Reference

driver declaration part of run trace-replay More...

#include <linux/limits.h>
#include <unistd.h>
#include <sys/types.h>
#include <json.h>
#include <generic.h>
#include <trace_replay.h>
Include dependency graph for tr-driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tr_json_field
 Support structure of the tr_stats_serializer() function. More...
 
struct  tr_total_json_object
 Support structure of the total_results structures which located in include/trace_replay.h. More...
 
struct  tr_info
 This structure has the major information of the each process. More...
 

Macros

#define tr_info_list_traverse(ptr, head)   for (ptr = head; ptr != NULL; ptr = ptr->next)
 Traverse the tr_info structures. More...
 
#define tr_json_field_traverse(ptr, begin, end)   for (ptr = begin; ptr != end; ptr++)
 Traverse the tr_json_field structures. More...
 
#define TR_CGROUP_PREFIX   "/sys/fs/cgroup/blkio/"
 
#define TR_CGROUP_WEIGHT_PREFIX   "blkio"
 
#define TR_CGROUP_SET_PID   "tasks"
 

Enumerations

enum  { TR_IPC_NOT_FREE = 0x0, TR_IPC_FREE = 0x1 }
 
enum  { TR_NOT_SYNTH = 0, TR_SYNTH = 0x1 }
 
enum  { TR_ERROR_PRINT, TR_PRINT_NONE }
 

Functions

int tr_init (void *object)
 Initialize the global configuration and per processes configuration. More...
 
int tr_runner (void)
 Run all processes' trace-replay part. More...
 
int tr_valid_scheduler_test (const char *scheduler)
 Check the current inputted scheduler text can be supported by the driver. More...
 
int tr_has_weight_scheduler (const int scheduler_index)
 Check the parameter's scheduler_index supports weight. More...
 
int tr_get_interval (const char *key, char *buffer)
 Get execution-time results from trace-replay. More...
 
int tr_get_total (const char *key, char *buffer)
 Get end-time results from trace-replay. More...
 
void tr_free (void)
 Deallocate resources of this driver. More...
 
void tr_total_serializer (const struct tr_info *info, const struct total_results *total, char *buffer)
 Converts total_results to JSON string. More...
 
void tr_realtime_serializer (const struct tr_info *info, const struct realtime_log *log, char *buffer)
 Converts realtime_log to JSON string. More...
 
struct tr_infotr_info_init (struct json_object *setting, int index)
 Generate and construct the per processes info object and return it. More...
 
int tr_shm_init (struct tr_info *info)
 Do the __tr_shm_init() and __tr_sem_init() More...
 
int tr_shm_get (const struct tr_info *info, void *buffer)
 Retrieve the data from Shared Memory. More...
 
void tr_shm_free (struct tr_info *info, int flags)
 Deallocate the Shared Memory resources. More...
 
int tr_mq_init (struct tr_info *info)
 Wrapping function of __tr_mq_init() More...
 
int tr_mq_get (const struct tr_info *info, void *buffer)
 Retrieve the data from Message Queue. More...
 
void tr_mq_free (struct tr_info *info, int flags)
 Deallocate the Message Queue resources. More...
 

Detailed Description

driver declaration part of run trace-replay

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Author
BlaCkinkGJ (ss5ki.nosp@m.jun@.nosp@m.gmail.nosp@m..com)
Version
0.1.1
Date
2020-08-05

Macro Definition Documentation

◆ TR_CGROUP_PREFIX

#define TR_CGROUP_PREFIX   "/sys/fs/cgroup/blkio/"

◆ TR_CGROUP_SET_PID

#define TR_CGROUP_SET_PID   "tasks"

◆ TR_CGROUP_WEIGHT_PREFIX

#define TR_CGROUP_WEIGHT_PREFIX   "blkio"

◆ tr_info_list_traverse

#define tr_info_list_traverse (   ptr,
  head 
)    for (ptr = head; ptr != NULL; ptr = ptr->next)

Traverse the tr_info structures.

Parameters
[out]ptrCurrent pointer of tr_info structure.
[in]headStart pointer of the traverse.

◆ tr_json_field_traverse

#define tr_json_field_traverse (   ptr,
  begin,
  end 
)    for (ptr = begin; ptr != end; ptr++)

Traverse the tr_json_field structures.

Parameters
[out]ptrCurrent pointer of tr_json_field structures.
[in]beginStart pointer of the traverse.
[in]endEnd pointer of the traverse.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TR_IPC_NOT_FREE 

Cannot remove the IPC object.

TR_IPC_FREE 

Remove the IPC Object

◆ anonymous enum

anonymous enum
Enumerator
TR_NOT_SYNTH 

The value is not synthetic

TR_SYNTH 

The value is synthetic.

◆ anonymous enum

anonymous enum
Enumerator
TR_ERROR_PRINT 

Reveal the JSON error to user.

TR_PRINT_NONE 

Doesn't reveal the JSON error to user

Function Documentation

◆ tr_free()

void tr_free ( void  )

Deallocate resources of this driver.

Here is the call graph for this function:

◆ tr_get_interval()

int tr_get_interval ( const char *  key,
char *  buffer 
)

Get execution-time results from trace-replay.

Parameters
[in]keycgroup_id value which specifies the location of data I want to get.
[out]bufferData contains the execution-time results based on key.
Returns
log.type for success to get information, negative value for fail to get information.
Warning
buffer must be allocated memory over and equal INTERVAL_RESULT_STRING_SIZE
Here is the call graph for this function:

◆ tr_get_total()

int tr_get_total ( const char *  key,
char *  buffer 
)

Get end-time results from trace-replay.

Parameters
[in]keycgroup_id value which specifies the location of data I want to get.
[out]bufferData contains the end-time results based on key.
Returns
0 for success to get information, negative value for fail to get information.
Warning
buffer must be allocated memory over and equal TOTAL_RESULT_STRING_SIZE
Here is the call graph for this function:

◆ tr_has_weight_scheduler()

int tr_has_weight_scheduler ( const int  scheduler_index)

Check the parameter's scheduler_index supports weight.

Parameters
[in]scheduler_indexThe scheduler's index which is based on tr_valid_scheduler and wants to check.
Returns
0 for doesn't support the weight, 1 for supporting the weight

◆ tr_info_init()

struct tr_info* tr_info_init ( struct json_object *  setting,
int  index 
)

Generate and construct the per processes info object and return it.

Parameters
[in]settingJSON object pointer which has the setting value.
[in]indextask_option array's index.
Returns
0 for success to init, error number for fail to init
Here is the call graph for this function:

◆ tr_init()

int tr_init ( void *  object)

Initialize the global configuration and per processes configuration.

Parameters
[in]objectglobal runner_config pointer.
Returns
0 for success to init, error number for fail to init.
Warning
Do not run this function in child process.
Here is the call graph for this function:

◆ tr_mq_free()

void tr_mq_free ( struct tr_info info,
int  flags 
)

Deallocate the Message Queue resources.

Parameters
[in]infotr_info structure which wants to deallocate.
[in]flagsSet a range of deallocation.

◆ tr_mq_get()

int tr_mq_get ( const struct tr_info info,
void *  buffer 
)

Retrieve the data from Message Queue.

Parameters
[in]infotr_info structure which wants to get data.
[out]bufferDestination of data will be stored
Returns
0 for success to init, negative value for fail to init.

◆ tr_mq_init()

int tr_mq_init ( struct tr_info info)

Wrapping function of __tr_mq_init()

Parameters
[in]infotr_info structure which wants to init.
Returns
0 for success to init, negative value for fail to init.
Here is the call graph for this function:

◆ tr_realtime_serializer()

void tr_realtime_serializer ( const struct tr_info info,
const struct realtime_log log,
char *  buffer 
)

Converts realtime_log to JSON string.

Parameters
[in]infotr_info structure's pointer.
[in]logrealtime_log structure's pointer.
[out]bufferData contains the execution-time results which are converted to JSON.
Warning
buffer must be allocated memory over and equal INTERVAL_RESULT_STRING_SIZE
Here is the call graph for this function:

◆ tr_runner()

int tr_runner ( void  )

Run all processes' trace-replay part.

Returns
0 for success to run, error number for fail to run.
Here is the call graph for this function:

◆ tr_shm_free()

void tr_shm_free ( struct tr_info info,
int  flags 
)

Deallocate the Shared Memory resources.

Parameters
[in]infotr_info structure which wants to deallocate.
[in]flagsSet a range of deallocation.

◆ tr_shm_get()

int tr_shm_get ( const struct tr_info info,
void *  buffer 
)

Retrieve the data from Shared Memory.

Parameters
[in]infotr_info structure which wants to get data.
[out]bufferDestination of data will be stored
Returns
0 for success to init, negative value for fail to init.
Here is the call graph for this function:

◆ tr_shm_init()

int tr_shm_init ( struct tr_info info)

Do the __tr_shm_init() and __tr_sem_init()

Parameters
[in]infotr_info structure which wants to init.
Returns
0 for success to init, negative value for fail to init.
Here is the call graph for this function:

◆ tr_total_serializer()

void tr_total_serializer ( const struct tr_info info,
const struct total_results total,
char *  buffer 
)

Converts total_results to JSON string.

Parameters
[in]infotr_info structure's pointer.
[in]totaltotal_results structure's pointer.
[out]bufferData contains the end-time results which are converted to JSON.
Warning
buffer must be allocated memory over and equal TOTAL_RESULT_STRING_SIZE
Here is the call graph for this function:

◆ tr_valid_scheduler_test()

int tr_valid_scheduler_test ( const char *  scheduler)

Check the current inputted scheduler text can be supported by the driver.

Parameters
[in]schedulerInputted scheduler string.
Returns
0 and positive integer for mean support the scheduler, -EINVAL for mean don't support the scheduler.