Skip to content
Snippets Groups Projects
Commit b64f2859 authored by FKHals's avatar FKHals
Browse files

Make waiting_on_io process specific

since it previously was not working correctly as it is supposed to be
set per process.
This includes adding it to the (process-wise) pevent map to be able to
retrieve it.
parent bff12acd
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment