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

Disable preemption inside the PBM-functions

since all of those operate on shared data structures and therefore are
mostly critical sections.
parent 2aa7926b
Branches pbm
No related tags found
No related merge requests found
...@@ -340,7 +340,6 @@ int pbm_task_start(PBM* pbm, uint8_t type, struct task_struct* proc) { ...@@ -340,7 +340,6 @@ int pbm_task_start(PBM* pbm, uint8_t type, struct task_struct* proc) {
/* Conclude the last task of the given PBM */ /* Conclude the last task of the given PBM */
int pbm_task_end(PBM* pbm) { int pbm_task_end(PBM* pbm) {
unsigned long irq_flags;
int read_error; int read_error;
struct perf_event *pevent; struct perf_event *pevent;
u64 perf_counter; u64 perf_counter;
...@@ -379,11 +378,8 @@ int pbm_task_end(PBM* pbm) { ...@@ -379,11 +378,8 @@ int pbm_task_end(PBM* pbm) {
pbm->last->count = perf_counter; pbm->last->count = perf_counter;
} }
// disable performance counter while preventing context switching
local_irq_save(irq_flags);
perf_event_disable(pevent); perf_event_disable(pevent);
perf_event_release_kernel(pevent); perf_event_release_kernel(pevent);
local_irq_restore(irq_flags);
pevent = NULL; pevent = NULL;
printk(KERN_WARNING "TASK: %u | ...Counting stopped: %llu instr.\n", current->pid, perf_counter); printk(KERN_WARNING "TASK: %u | ...Counting stopped: %llu instr.\n", current->pid, perf_counter);
...@@ -449,8 +445,6 @@ int pbm_task_end(PBM* pbm) { ...@@ -449,8 +445,6 @@ int pbm_task_end(PBM* pbm) {
* run (current == child) otherwise the perf counting will fail! * run (current == child) otherwise the perf counting will fail!
*/ */
int pbm_fork(struct task_struct* proc, pid_t parent_pid, pbm_NODE* fork_node) { int pbm_fork(struct task_struct* proc, pid_t parent_pid, pbm_NODE* fork_node) {
unsigned long irq_flags;
PBM* parent_pbm; PBM* parent_pbm;
PBM* child_pbm; PBM* child_pbm;
...@@ -459,13 +453,10 @@ int pbm_fork(struct task_struct* proc, pid_t parent_pid, pbm_NODE* fork_node) { ...@@ -459,13 +453,10 @@ int pbm_fork(struct task_struct* proc, pid_t parent_pid, pbm_NODE* fork_node) {
* pbm_fork_parent_new_task() to not be called but pbm_fork() since the child is "mpirun" so we * pbm_fork_parent_new_task() to not be called but pbm_fork() since the child is "mpirun" so we
* put the initialization in here instead of into pbm_fork_parent_new_task(). * put the initialization in here instead of into pbm_fork_parent_new_task().
*/ */
// avoid context switching during initialization by disabling interrupts
local_irq_save(irq_flags);
if (!is_initialized) { if (!is_initialized) {
pbm_init(); pbm_init();
is_initialized = 1; is_initialized = 1;
} }
local_irq_restore(irq_flags);
child_pbm = get_pbm_by_pid(proc->pid); child_pbm = get_pbm_by_pid(proc->pid);
parent_pbm = get_pbm_by_pid(parent_pid); parent_pbm = get_pbm_by_pid(parent_pid);
...@@ -532,8 +523,10 @@ int pbm_fork(struct task_struct* proc, pid_t parent_pid, pbm_NODE* fork_node) { ...@@ -532,8 +523,10 @@ int pbm_fork(struct task_struct* proc, pid_t parent_pid, pbm_NODE* fork_node) {
// only one before the join-operation) // only one before the join-operation)
// * child_pbm->root != NULL: since the previously called pbm_task_start() should have // * child_pbm->root != NULL: since the previously called pbm_task_start() should have
// written to that // written to that
child_pbm->root->next_sib = fork_node->children; if (fork_node) {
fork_node->children = child_pbm->root; child_pbm->root->next_sib = fork_node->children;
fork_node->children = child_pbm->root;
}
return 1; return 1;
} }
......
...@@ -767,6 +767,7 @@ void __noreturn do_exit(long code) ...@@ -767,6 +767,7 @@ void __noreturn do_exit(long code)
struct task_struct *tsk = current; struct task_struct *tsk = current;
int group_dead; int group_dead;
preempt_disable();
// call the readout before the process is terminated // call the readout before the process is terminated
if (is_relevant_process(tsk)) { if (is_relevant_process(tsk)) {
pbm_exit(tsk->pid, tsk->real_parent->pid); pbm_exit(tsk->pid, tsk->real_parent->pid);
...@@ -775,6 +776,7 @@ void __noreturn do_exit(long code) ...@@ -775,6 +776,7 @@ void __noreturn do_exit(long code)
pbm_join_and_print_graph_self(tsk->pid); pbm_join_and_print_graph_self(tsk->pid);
} }
printk(KERN_EMERG "EXIT: %u, CMD: '%s', PARENT-CMD: '%s', PTR: %llu\n", tsk->pid, tsk->comm, tsk->real_parent->comm, (u64)tsk); printk(KERN_EMERG "EXIT: %u, CMD: '%s', PARENT-CMD: '%s', PTR: %llu\n", tsk->pid, tsk->comm, tsk->real_parent->comm, (u64)tsk);
preempt_enable();
TASKS_RCU(int tasks_rcu_i); TASKS_RCU(int tasks_rcu_i);
......
...@@ -2021,10 +2021,12 @@ long _do_fork(unsigned long clone_flags, ...@@ -2021,10 +2021,12 @@ long _do_fork(unsigned long clone_flags,
fork_date = NULL; fork_date = NULL;
// FIXME: This will not get called for mpirun since then bash will be the parent here // FIXME: This will not get called for mpirun since then bash will be the parent here
preempt_disable();
if (is_relevant_process(current)) { if (is_relevant_process(current)) {
printk(KERN_EMERG "DO FORK CALLED by: '%s' %u\n", current->comm ,parent_pid); printk(KERN_EMERG "DO FORK CALLED by: '%s' %u\n", current->comm ,parent_pid);
fork_date = pbm_fork_parent_new_task(current); fork_date = pbm_fork_parent_new_task(current);
} }
preempt_enable();
/* /*
* Determine whether and which event to report to ptracer. When * Determine whether and which event to report to ptracer. When
...@@ -2084,12 +2086,14 @@ long _do_fork(unsigned long clone_flags, ...@@ -2084,12 +2086,14 @@ long _do_fork(unsigned long clone_flags,
// FIXME: The problem is that at this stage we can not identify the MPIrun process since // FIXME: The problem is that at this stage we can not identify the MPIrun process since
// the p->comm is not up to date yet so we simply record all bash childs which is // the p->comm is not up to date yet so we simply record all bash childs which is
// rather wasteful! // rather wasteful!
preempt_disable();
if (is_relevant_process(p) || (strcmp(p->comm, "bash") == 0)) { if (is_relevant_process(p) || (strcmp(p->comm, "bash") == 0)) {
// At this point p->comm is not up to date but shows the command of the parent! // At this point p->comm is not up to date but shows the command of the parent!
printk(KERN_EMERG "FORKED!!!!: %u, Parent: %s, Super-Parent:%s\n", printk(KERN_EMERG "FORKED!!!!: %u, Parent: %s, Super-Parent:%s\n",
p->pid, p->comm, p->real_parent->real_parent->comm); p->pid, p->comm, p->real_parent->real_parent->comm);
pbm_fork(p, parent_pid, fork_date); pbm_fork(p, parent_pid, fork_date);
} }
preempt_enable();
} else { } else {
nr = PTR_ERR(p); nr = PTR_ERR(p);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment