diff --git a/kernel/sched/pb.c b/kernel/sched/pb.c index c102a9729c342223706d1f92c42cb305f7c638c4..6563a62e4d27c2b99b064258f85026d25ef91038 100644 --- a/kernel/sched/pb.c +++ b/kernel/sched/pb.c @@ -125,7 +125,6 @@ void init_pb_rq(struct pb_rq *pb_rq) pb_rq->count_admin_cycles = 0; pb_rq->mode = PB_DISABLED_MODE; pb_rq->is_initialized = 0; - pb_rq->waiting_on_io = 0; init_pid_2_pevent_map(); } @@ -142,7 +141,7 @@ static void enqueue_task_pb(struct rq *rq, struct task_struct *p, int flags) { struct pb_rq *pb = &(rq->pb); - pb->waiting_on_io = 0; + *(waiting_on_io_by_pid(p->pid)) = 0; if (rq->pb.mode == PB_EXEC_MODE) { printk(KERN_WARNING "ENQEUE TASK %u\n", p->pid); @@ -222,11 +221,11 @@ static void dequeue_task_pb(struct rq *rq, struct task_struct *p, int flags) //printk("Dequeue task: %u\n", p->pid); - if (pb->waiting_on_io && p->state != TASK_DEAD) { + if (*(waiting_on_io_by_pid(p->pid))/* && p->state != TASK_DEAD*/) { printk("Waiting for IO\n"); return; } - pb->waiting_on_io = 1; + *(waiting_on_io_by_pid(p->pid)) = 1; // safe current process for later use since the plan_rt_state might get modified plan_rt_state_peek(&cur_node, &cur_proc); diff --git a/kernel/sched/perf_error_detection.c b/kernel/sched/perf_error_detection.c index 87244e1aaa8352aa69a75935ca6ec09bc5938173..963c3d1ebce5f67a9c8ae7b9766296bea66c34c8 100644 --- a/kernel/sched/perf_error_detection.c +++ b/kernel/sched/perf_error_detection.c @@ -123,7 +123,8 @@ void init_pid_2_pevent_map(void) int i; for (i = 0; i < PROC_BUF_SIZE; ++i) { pid_2_pevent.index_to_pid[i] = 0; - pid_2_pevent.index_to_pevent[i] = NULL; + pid_2_pevent.index_to_task_data[i].pevent = NULL; + pid_2_pevent.index_to_task_data[i].waiting_on_io = 0; } pid_2_pevent.last_proc_index = 0; } @@ -148,7 +149,20 @@ struct perf_event* get_pevent_by_pid(pid_t pid) break; } } - return proc_index != 0 ? pid_2_pevent.index_to_pevent[proc_index] : NULL; + return proc_index != 0 ? pid_2_pevent.index_to_task_data[proc_index].pevent : NULL; +} + +volatile int* waiting_on_io_by_pid(pid_t pid) +{ + size_t i; + size_t proc_index = 0; + for(i = 0; i < PROC_BUF_SIZE; i++) { + if (pid_2_pevent.index_to_pid[i] == pid) { + proc_index = i; + break; + } + } + return proc_index != 0 ? &(pid_2_pevent.index_to_task_data[proc_index].waiting_on_io) : NULL; } /* @@ -165,7 +179,7 @@ int add_proc_to_pevent_map(pid_t pid, struct perf_event* pevent) printk(KERN_WARNING "i: %lu, pid: %u\n", pid_2_pevent.last_proc_index, pid); pid_2_pevent.last_proc_index++; pid_2_pevent.index_to_pid[pid_2_pevent.last_proc_index] = pid; - pid_2_pevent.index_to_pevent[pid_2_pevent.last_proc_index] = pevent; + pid_2_pevent.index_to_task_data[pid_2_pevent.last_proc_index].pevent = pevent; return 1; } diff --git a/kernel/sched/perf_error_detection.h b/kernel/sched/perf_error_detection.h index 02113e82f8afd45c8a3f4ee0280c17021c35d1b5..af609294e551ccc7992f68be8e0efe73c2739976 100644 --- a/kernel/sched/perf_error_detection.h +++ b/kernel/sched/perf_error_detection.h @@ -12,11 +12,16 @@ u64 get_perf_counter(struct perf_event *pevent, u64 *perf_counter); u64 terminate_perf_event(struct perf_event* pevent); +typedef struct { + struct perf_event* pevent; + volatile int waiting_on_io; // changes to this flag must never be optimized away +} pb_task_data; + typedef struct { // primitive int -> int and int -> pevent* hashmap combination // the two arrays store the pid and corresponding PBM* at the same index pid_t index_to_pid[PROC_BUF_SIZE]; - struct perf_event* index_to_pevent[PROC_BUF_SIZE]; + pb_task_data index_to_task_data[PROC_BUF_SIZE]; // index of currently last process in the arrays size_t last_proc_index; //pthread_mutex_t lock; @@ -24,6 +29,7 @@ typedef struct { void init_pid_2_pevent_map(void); struct perf_event* get_pevent_by_pid(pid_t pid); +volatile int* waiting_on_io_by_pid(pid_t pid); int add_proc_to_pevent_map(pid_t pid, struct perf_event* pevent); int init_perf_event_into_map(struct task_struct* proc, u64 num_instr); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index e336142b167155c191d0d05d2a80737032f9efbc..c8e15448321bfe3e958767697b61c7d1b70d6753 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -551,7 +551,6 @@ struct pb_rq * this variable must be initialized last */ volatile int is_initialized; - volatile int waiting_on_io; }; int pb_submit_plan(struct rq *rq);