From 5d890d80fee5bc4338cec459b9ce004dfc5f422c Mon Sep 17 00:00:00 2001 From: FKHals <5229803-FKHals@users.noreply.gitlab.com> Date: Wed, 25 Jan 2023 17:25:55 +0100 Subject: [PATCH] [DO NOT MERGE] Intermediate commit --- kernel/fork.c | 13 +++++++++ pb_utils/pb_submitter/test_prog.c | 47 +++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index b7e9e57b71ea..c4ccda40ce7d 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -98,6 +98,8 @@ #include <trace/events/sched.h> +#include "sched/perf_error_detection.h" + #define CREATE_TRACE_POINTS #include <trace/events/task.h> @@ -2069,6 +2071,17 @@ long _do_fork(unsigned long clone_flags, } put_pid(pid); +/* + struct rq* rq = this_rq(); + struct pb_rq *pb = &(rq->pb); + if (pb && pb->is_initialized) { + u64 perf_counter; + u64 read_error = get_perf_counter(pb->pevent, &perf_counter); + if (read_error) { + printk(KERN_WARNING "FORK: FETCHING PERFORMANCE COUNTER IN PB SCHEDULER FAILED WITH %llu\n", read_error); + } + printk("FORK: PERFORMANCE COUNTER: %llu", perf_counter); + }*/ } else { nr = PTR_ERR(p); } diff --git a/pb_utils/pb_submitter/test_prog.c b/pb_utils/pb_submitter/test_prog.c index 98e6bece6dc9..57467d38813a 100644 --- a/pb_utils/pb_submitter/test_prog.c +++ b/pb_utils/pb_submitter/test_prog.c @@ -1,25 +1,50 @@ #include <stdio.h> #include <unistd.h> +#define NUM_CHILDS 1 + int main(void) { - int i; + int id; int j; + pid_t child_pid, wpid; + int status = 0; + + // parent code (before child processes start) + { + // Make sure program is not finished before pb scheduler takes control + sleep(1); + + printf("=========================================================\n"); + printf("I am the parent=%d and i am going to do some forking...\n", getpid()); + } - // Make sure program is not finished before pb scheduler takes control - sleep(1); + for (id = 0; id < NUM_CHILDS; id++) { + if ((child_pid = fork()) == 0) { + // child code + { + printf("I am the child, return from fork=%d with parent=%d\n", getpid(), getppid()); - // this outer for loop is around 8 instructions per iteration - for (i = 0; i < 100; i++) { - // this for loop results in 4 cpu instructions per iteration - // nop, add, compare, jmp - for (j = 0; j < 100000; j++){ - __asm__ volatile("nop"); + // this for loop results in 4 cpu instructions per iteration + // nop, add, compare, jmp + for (j = 0; j < 100000; j++){ + __asm__ volatile("nop"); + } + printf("Child %d exiting\n", getpid()); + } } + } + + // barrier: let the father wait for all the child processes + while ((wpid = wait(&status)) > 0) {}; + + // parent code (after all child processes end) + { + printf("Parent exiting!\n"); // check if program runs && syscall to switch tasks - printf("run #%d completed\n", i); - usleep(1); +- printf("run completed\n"); +- usleep(1); } printf("main end\n"); -- GitLab