diff --git a/pb_utils/mod_gen_new/Makefile b/pb_utils/mod_gen_new/Makefile deleted file mode 100644 index 55503d9ce1a2506057a149867545ea2ac4ebb8ca..0000000000000000000000000000000000000000 --- a/pb_utils/mod_gen_new/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -obj-m += pb_module.o - -all: - make -C $(PWD)/../../ M=$(PWD) modules - -clean: - make -C $(PWD)/../../ M=$(PWD) clean diff --git a/pb_utils/mod_gen_new/build.sh b/pb_utils/mod_gen_new/build.sh deleted file mode 100755 index 98a5f15fe0adc880c01d54745ec8c2630390694c..0000000000000000000000000000000000000000 --- a/pb_utils/mod_gen_new/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -#make -mkdir -p mnt - -gcc -static -o test test.c - -sudo mount -o loop ../build/qemu-image.img ./mnt -sudo cp test ./mnt/root - -sudo umount ./mnt - -echo "All done. Run ./run_qemu.sh now" diff --git a/pb_utils/mod_gen_new/test.c b/pb_utils/mod_gen_new/test.c deleted file mode 100644 index a7abb227be8d4cfc7e2f2f7e921f98d53d9a7ce1..0000000000000000000000000000000000000000 --- a/pb_utils/mod_gen_new/test.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <stdio.h> -#include <sys/syscall.h> -#include <unistd.h> - -#define PB_SET_PLAN 0x1337 - -typedef struct { - int tmp; -} plan_t; - -// check kernel log with dmesg command afterwards -int main(void) -{ - plan_t plan = {0}; - plan.tmp = 0x414141; - - int ret = syscall(PB_SET_PLAN, &plan); - if (ret < 0) { - perror("pb: "); - return -1; - } - - puts("Done. Check kernel log with dmesg for message"); - - return 0; -} diff --git a/pb_utils/pb_submitter/build.sh b/pb_utils/pb_submitter/build.sh index b2da7093921f6358296740f44b07480f5a56e9bc..4b92faed1e929a87ba42d7e403e4d719ac51f7dc 100755 --- a/pb_utils/pb_submitter/build.sh +++ b/pb_utils/pb_submitter/build.sh @@ -7,7 +7,7 @@ gcc -static -o pb_submitter pb_submitter.c gcc -static -o test_prog test_prog.c sudo mount -o loop ../build/qemu-image.img ./mnt -sudo cp pb_submitter test_prog example_run.sh ./mnt/root +sudo cp pb_submitter test_prog example_run.sh example_plan ./mnt/root sudo umount ./mnt diff --git a/pb_utils/pb_submitter/example_plan b/pb_utils/pb_submitter/example_plan new file mode 100644 index 0000000000000000000000000000000000000000..d3a1ca1428a9fd497a6cbd5c3a9d60ce031e9abb --- /dev/null +++ b/pb_utils/pb_submitter/example_plan @@ -0,0 +1,110 @@ +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 +100000 diff --git a/pb_utils/pb_submitter/example_run.sh b/pb_utils/pb_submitter/example_run.sh index b399f1bf492422cf5c254cb4d63cbd4fb972e8e2..f4ebc4074e578babe6c2faa71d53d24c4e247211 100755 --- a/pb_utils/pb_submitter/example_run.sh +++ b/pb_utils/pb_submitter/example_run.sh @@ -1,3 +1,3 @@ #!/bin/sh -./pb_submitter ./test 16 16 +./pb_submitter test example_plan diff --git a/pb_utils/pb_submitter/pb_submitter.c b/pb_utils/pb_submitter/pb_submitter.c index 61de4581ffc41db2bd9c9ed1e807ee14d6ddcf79..3a677d3c30b6b688dac55d5eb1f514661c8bf5dd 100644 --- a/pb_utils/pb_submitter/pb_submitter.c +++ b/pb_utils/pb_submitter/pb_submitter.c @@ -14,41 +14,75 @@ typedef struct { static void usage(void) { - puts("Usage: ./pb_submitter <prog_name> <inst_cnt> <num_tasks>"); + puts("Usage: ./pb_submitter <prog_name> <plan_file>"); +} + +static size_t count_lines(FILE *fp) +{ + char c; + size_t lines = 0; + while (!feof(fp)) { + c = fgetc(fp); + if (c == '\n') { + lines++; + } + } + + rewind(fp); + + return lines; } int main(int argc, char** argv) { - if (argc < 0x4) { + if (argc < 0x3) { usage(); return -1; } int ret; pb_plan_t plan = { 0 }; - - ret = sscanf(argv[3], "%zu", &plan.num_tasks); - if (ret != 1) { + FILE *fp; + char *line = NULL; + size_t len = 0; + ssize_t read; + + fp = fopen(argv[2], "r"); + if (fp == NULL) { usage(); return -1; } + plan.num_tasks = count_lines(fp); + + printf("num_tasks: %zu \n", plan.num_tasks); + uint64_t* inst_cnt = calloc(plan.num_tasks, sizeof(uint64_t)); if (inst_cnt == NULL) { perror("calloc"); return -1; } - // todo only for testing: - // need to pass in a file that contains all the inst_cnts at some point - for (int i = 0; i < 0x10; i++) { - inst_cnt[i] = 0x10000; + for (size_t i = 0; i < plan.num_tasks; i++) { + read = getline(&line, &len, fp); + + if (read < 0) { + perror("getline"); + return -1; + } + + uint64_t cnt = strtoull(line, NULL, 10); + + if (inst_cnt == 0) { + puts("Inst_cnt conversion failure"); + return -1; + } + + inst_cnt[i] = cnt; } plan.inst_cnt = inst_cnt; - printf("inst_cnt address: %p \n", inst_cnt); - plan.pid = getpid(); ret = syscall(PB_SET_PLAN, &plan); diff --git a/pb_utils/pb_submitter/test_prog.c b/pb_utils/pb_submitter/test_prog.c index 902617de5e3261759059f9fa1af467b472e3b840..07e16b3618d0ddf6445230922e09e76648f7deb7 100644 --- a/pb_utils/pb_submitter/test_prog.c +++ b/pb_utils/pb_submitter/test_prog.c @@ -5,8 +5,11 @@ int main(void) unsigned int c = 0; // printk(KERN_WARNING "Hello from Module.\n"); int a = 0; + int b = 0; // printk(KERN_WARNING "A.\n"); - for (;a < 200000; a++){asm("");} + for (;b < 100; b++) { + for (;a < 100000; a++){asm("");} + } // printk(KERN_WARNING "B.\n"); c++; // printk(KERN_WARNING "Bye from module.\n");