Skip to content

Commit

Permalink
updating files for version-1.3 which includes app-vt tracer support w…
Browse files Browse the repository at this point in the history
…ith pintool
  • Loading branch information
Vignesh2208 committed Sep 27, 2020
1 parent 974c2c0 commit 09c63b9
Show file tree
Hide file tree
Showing 4,453 changed files with 639,381 additions and 69 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ SUBDIR= $(shell pwd)
GCC:=gcc
RM:=rm
CD:=cd
CP:=cp
ECHO:=echo
CHMOD:=chmod

nCpus=$(shell nproc --all)

all: clean build

.PHONY : clean
clean: clean_core clean_utils clean_api clean_tracer clean_scripts
clean: clean_core clean_utils clean_api clean_tracer clean_scripts clean_pintool

.PHONY : build
build: build_core build_api build_tracer build_scripts
build: build_core build_api build_tracer build_scripts build_pintool

.PHONY : setup_kernel
setup_kernel: download_4_4_kernel compile_4_4_kernel
Expand Down Expand Up @@ -46,6 +48,15 @@ build_api:
build_tracer:
@$(CD) src/tracer; $(MAKE) build;

.PHONY : build_pintool
build_pintool:
@$(ECHO) "Building pintool ..."
@$(CD) src/tracer/pintool; $(MAKE) obj-intel64/inscount_tls.so TARGET=intel64
@$(CP) src/tracer/pintool/pin-3.13/pin /usr/bin
@$(CHMOD) 0777 /usr/bin/pin
@$(CP) src/tracer/pintool/obj-intel64/inscount_tls.so /usr/lib/inscount_tls.so
@$(CHMOD) 0777 /usr/lib/inscount_tls.so

.PHONY : build_scripts
build_scripts:
@$(CD) scripts; $(MAKE) build;
Expand Down Expand Up @@ -79,6 +90,13 @@ clean_api:
@$(RM) -f src/api/*.o
@$(CD) src/api && $(MAKE) clean

.PHONY : clean_pintool
clean_pintool:
@$(ECHO) "Cleaning pintool ..."
$(RM) -rf src/tracer/pintool/obj-intel64 > /dev/null
$(RM) -f /usr/bin/pin > /dev/null
$(RM) -f /usr/lib/inscount_tls.so > /dev/null

.PHONY : clean_tracer
clean_tracer:
@$(ECHO) "Cleaning Tracer files ..."
Expand Down
10 changes: 5 additions & 5 deletions examples/cmds_to_run_file.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/home/kronos/Kronos/src/tracer/tests/sleep-test/test
/home/kronos/Kronos/src/tracer/tests/sleep-test/test
/home/kronos/Kronos/src/tracer/tests/sleep-test/test
/home/kronos/Kronos/src/tracer/tests/sleep-test/test
/home/kronos/Kronos/src/tracer/tests/sleep-test/test
/usr/bin/sysbench --test=cpu --cpu-max-prime=1000 run
/usr/bin/sysbench --test=cpu --cpu-max-prime=1000 run
/usr/bin/sysbench --test=cpu --cpu-max-prime=1000 run
/usr/bin/sysbench --test=cpu --cpu-max-prime=1000 run
/usr/bin/sysbench --test=cpu --cpu-max-prime=1000 run
26 changes: 12 additions & 14 deletions examples/example_app_vt_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import sys
import os
import time
import vt_functions as kf
import kronos_functions as kf
import sys
import argparse


def start_new_dilated_process(tracer_id, total_num_tracers, cmd_to_run, log_file_fd):
def start_new_dilated_process(total_num_tracers, cmd_to_run, log_file_fd):
newpid = os.fork()
if newpid == 0:
os.dup2(log_file_fd, sys.stdout.fileno())
os.dup2(log_file_fd, sys.stderr.fileno())
args = ["app_vt_tracer", "-n", str(total_num_tracers), "-i", str(tracer_id), "-c", cmd_to_run]
args = ["/usr/bin/app_vt_tracer", "-n", str(total_num_tracers), "-c", cmd_to_run]
os.execvp(args[0], args)
else:
return newpid
Expand All @@ -33,11 +33,11 @@ def main():

parser.add_argument('--num_insns_per_round', dest='num_insns_per_round',
help='Number of insns per round', type=int,
default=100000)
default=1000000)

parser.add_argument('--num_progress_rounds', dest='num_progress_rounds',
help='Number of rounds to run', type=int,
default=200)
default=2000)

args = parser.parse_args()
log_fds = []
Expand Down Expand Up @@ -67,38 +67,36 @@ def main():

print ("Initializing VT Module !" )
if kf.initializeExp(num_tracers) < 0 :
print "VT module initialization failed ! Make sure you are running\
the dilated kernel and kronos module is loaded !"
print ("VT module initialization failed ! Make sure you are running "
"the dilated kernel and kronos module is loaded !")
sys.exit(0)

input('Press any key to continue !')

print ("Starting all commands to run !")

for i in range(0, num_tracers):
print "Starting tracer: %d" %(i + 1)
start_new_dilated_process(i + 1, num_tracers, cmds_to_run[i], log_fds[i])
print ("Starting tracer: %d" %(i + 1))
start_new_dilated_process(num_tracers, cmds_to_run[i], log_fds[i])

print ("Synchronizing anf freezing tracers ...")
while kf.synchronizeAndFreeze() <= 0:
print "VT Module >> Synchronize and Freeze failed. Retrying in 1 sec"
print ("VT Module >> Synchronize and Freeze failed. Retrying in 1 sec")
time.sleep(1)

input('Press any key to continue !')
print ("Starting Synchronized Experiment !")

start_time = float(time.time())
if args.num_progress_rounds > 0 :
print ("Running for %d rounds ... " %(args.num_progress_rounds))
num_finised_rounds = 0
step_size = min(1, args.num_progress_rounds)
step_size = min(10, args.num_progress_rounds)
while num_finised_rounds < args.num_progress_rounds:
kf.progressBy(args.num_insns_per_round, step_size)
num_finised_rounds += step_size
#input("Press Enter to continue...")
print ("Ran %d rounds ..." %(num_finised_rounds),
" elapsed time ...", float(time.time()) - start_time)
#time.sleep(0.1)
#input("Press Enter to continue...")

elapsed_time = float(time.time()) - start_time
print ("Total time elapsed (secs) = ", elapsed_time)
Expand Down
4 changes: 3 additions & 1 deletion src/core/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,14 @@ void AddToTracerScheduleQueue(tracer * tracer_entry,
tracee->pid, tracer_entry->tracer_id);

new_elem = (lxc_schedule_elem *)kmalloc(sizeof(lxc_schedule_elem), GFP_KERNEL);
memset(new_elem, 0, sizeof(lxc_schedule_elem));

if (!new_elem) {
PDEBUG_E("AddToTracerScheduleQueue: "
"Tracer %d, tracee %d. Failed to alot Memory\n",
tracer_entry->tracer_id, tracee->pid);
return;
}
memset(new_elem, 0, sizeof(lxc_schedule_elem));

new_elem->pid = tracee->pid;
new_elem->curr_task = tracee;
Expand Down Expand Up @@ -252,6 +253,7 @@ void AddToTracerScheduleQueue(tracer * tracer_entry,
tracee->wakeup_time = 0;
tracee->burst_target = 0;
}


tracee->assigned_timeline = tracer_entry->timeline_assignment;

Expand Down
40 changes: 21 additions & 19 deletions src/core/sync_experiment.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ int InitializeExperimentComponents(int exp_type, int num_timelines,
chaintask[i] = kthread_create(&PerTimelineWorker, &values[i],
"PerTimelineWorker");
if (!IS_ERR(chaintask[i])) {
kthread_bind(chaintask[i], i % EXP_CPUS);
kthread_bind(chaintask[i], EXP_CPUS + i % (TOTAL_CPUS - EXP_CPUS));
wake_up_process(chaintask[i]);
PDEBUG_A("Timeline Worker %d: Pid = %d\n", i,
chaintask[i]->pid);
chaintask[i]->pid);
}
}

Expand Down Expand Up @@ -831,6 +831,21 @@ int UpdateAllRunnableTaskTimeslices(tracer * curr_tracer) {
PutTracerStructRead(curr_tracer);
GetTracerStructWrite(curr_tracer);

if (curr_tracer->last_run != NULL && curr_tracer->last_run->quanta_left_from_prev_round) {

last_run = curr_tracer->last_run;
if (alotted_quanta + last_run->quanta_left_from_prev_round > total_quanta) {
last_run->quanta_curr_round = total_quanta - alotted_quanta;
last_run->quanta_left_from_prev_round =
last_run->quanta_left_from_prev_round - last_run->quanta_curr_round;
alotted_quanta = total_quanta;
curr_tracer->last_run = last_run;
PutTracerStructWrite(curr_tracer);
GetTracerStructRead(curr_tracer);
return 1;
}

}

while (head != NULL) {
curr_elem = (lxc_schedule_elem *)head->item;
Expand Down Expand Up @@ -894,24 +909,8 @@ int UpdateAllRunnableTaskTimeslices(tracer * curr_tracer) {
return alteast_one_task_runnable;
}


head = run_queue->head;

if (curr_tracer->last_run != NULL && curr_tracer->last_run->quanta_left_from_prev_round) {

last_run = curr_tracer->last_run;
if (alotted_quanta + last_run->quanta_left_from_prev_round > total_quanta) {
last_run->quanta_curr_round = total_quanta - alotted_quanta;
last_run->quanta_left_from_prev_round =
last_run->quanta_left_from_prev_round - last_run->quanta_curr_round;
alotted_quanta = total_quanta;
curr_tracer->last_run = last_run;
PutTracerStructWrite(curr_tracer);
GetTracerStructRead(curr_tracer);
return 1;
}

}

while (head != NULL && alotted_quanta < total_quanta) {
curr_elem = (lxc_schedule_elem *)head->item;
Expand Down Expand Up @@ -984,6 +983,8 @@ int UpdateAllRunnableTaskTimeslices(tracer * curr_tracer) {

curr_elem = (lxc_schedule_elem *)head->item;
if (!curr_elem) {
PutTracerStructWrite(curr_tracer);
GetTracerStructRead(curr_tracer);
return alteast_one_task_runnable;
}

Expand All @@ -998,7 +999,7 @@ int UpdateAllRunnableTaskTimeslices(tracer * curr_tracer) {


if (alotted_quanta + curr_elem->base_quanta >= total_quanta) {
curr_elem->quanta_curr_round = total_quanta - alotted_quanta;
curr_elem->quanta_curr_round += total_quanta - alotted_quanta;
curr_elem->quanta_left_from_prev_round =
curr_elem->base_quanta - (total_quanta - alotted_quanta);
alotted_quanta = total_quanta;
Expand Down Expand Up @@ -1101,6 +1102,7 @@ int UnfreezeProcExpSingleCoreMode(tracer * curr_tracer) {
}

total_quanta = curr_tracer->nxt_round_burst_length;
PDEBUG_V("Tracer: %d, TOTAL QUANTA = %lld\n", curr_tracer->tracer_id, total_quanta);
if (curr_tracer->last_run)
PDEBUG_V("Tracer: %d, LAST RUN = %d\n", curr_tracer->tracer_id,
curr_tracer->last_run->pid);
Expand Down
11 changes: 5 additions & 6 deletions src/core/vt_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ ssize_t vtWrite(struct file *file, const char __user *buffer, size_t count,
int tracer_id;
tracer *curr_tracer;

memset(api_integer_args, 0, sizeof(int) * MAX_API_ARGUMENT_SIZE);

if(count > MAX_API_ARGUMENT_SIZE) {
buffer_size = MAX_API_ARGUMENT_SIZE;
} else {
Expand Down Expand Up @@ -170,8 +172,6 @@ ssize_t vtWrite(struct file *file, const char __user *buffer, size_t count,
GetTracerStructWrite(curr_tracer);
for (i = 1; i < num_integer_args; i++) {
AddToTracerScheduleQueue(curr_tracer, api_integer_args[i]);
PDEBUG_E("VT_ADD_PROCESS_TO_SQ: Tracer : %d, process: %d\n",
tracer_id, api_integer_args[i]);
}
PutTracerStructWrite(curr_tracer);
return 0;
Expand Down Expand Up @@ -207,9 +207,8 @@ ssize_t vtWrite(struct file *file, const char __user *buffer, size_t count,

current->ready = 1;


HandleTracerResults(curr_tracer, &api_integer_args[1],
num_integer_args - 1);
HandleTracerResults(curr_tracer, &api_integer_args[1],
num_integer_args - 1);

wait_event_interruptible(
*curr_tracer->w_queue,
Expand Down Expand Up @@ -371,7 +370,7 @@ long vtIoctl(struct file *filp, unsigned int cmd, unsigned long arg) {
api_info_tmp.api_argument, api_integer_args, MAX_API_ARGUMENT_SIZE);

if (num_integer_args < 1) {
PDEBUG_E("VT_RM_PROCESS_FROM_SQ: Not enough arguments !");
PDEBUG_E("VT_WRITE_RESULTS: Not enough arguments !");
return -EINVAL;
}

Expand Down
22 changes: 18 additions & 4 deletions src/tracer/app_vt_tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
#include <sys/syscall.h>
#include <sys/ptrace.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>

const char *homedir;


#define MAX_COMMAND_LENGTH 1000
#define MAX_CONTROLLABLE_PROCESSES 100
#define MAX_BUF_SIZ 100
#define MAX_BUF_SIZ 1000
#define FAIL -1

#include "Kronos_functions.h"
Expand Down Expand Up @@ -74,8 +80,13 @@ int createSpinnerTask(pid_t *child_pid) {
//! Envelop orig command to be started under the control of intel-pin
void envelopeCommandUnderPin(char * enveloped_cmd_str, char * orig_command_str,
int total_num_tracers, int tracer_id) {
char * pin_binary_path = "/home/titan/pin/pin";
char * pintool_path = "/home/titan/Titan/src/tracer/pintool/obj-intel64/inscount_tls.so";
if ((homedir = getenv("HOME")) == NULL) {
homedir = getpwuid(getuid())->pw_dir;
}
char pin_binary_path[MAX_COMMAND_LENGTH];
memset(pin_binary_path, 0, MAX_COMMAND_LENGTH);
sprintf(pin_binary_path, "%s/Kronos/src/tracer/pintool/pin-3.13/pin", homedir);
char * pintool_path = "/usr/lib/inscount_tls.so";
memset(enveloped_cmd_str, 0, MAX_COMMAND_LENGTH);
sprintf(enveloped_cmd_str, "%s -t %s -n %d -i %d -- %s", pin_binary_path,
pintool_path, total_num_tracers, tracer_id, orig_command_str);
Expand Down Expand Up @@ -234,7 +245,10 @@ int main(int argc, char * argv[]) {
while ((option = getopt(argc, argv, "i:f:n:st:c:h")) != -1) {
switch (option) {
case 'i' : tracer_id = atoi(optarg);
if (tracer_id <= 0) {fprintf(stderr, "Explicitly assigned tracer-id must be positive\n"); exit(FAIL); }
if (tracer_id <= 0) {
fprintf(stderr, "Explicitly assigned tracer-id must be positive > 0\n");
exit(FAIL);
}
break;
case 'n' : total_num_tracers = atoi(optarg);
break;
Expand Down
Loading

0 comments on commit 09c63b9

Please sign in to comment.