aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2015-08-09 07:18:50 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2017-05-26 17:12:33 -0400
commit3e53de728b191fbd0de09cc2283878e76afa7917 (patch)
tree868207eedb9ea5f7433b90b9bf410fb28d52c460
parentb5506ae89a16f96120e68a994ade593366551849 (diff)
Hook into fork(), exec(), and exit()
Allow LITMUS^RT to do some work when a process is created or terminated.
-rw-r--r--fs/exec.c3
-rw-r--r--kernel/exit.c4
-rw-r--r--kernel/fork.c6
-rw-r--r--kernel/sched/core.c9
4 files changed, 21 insertions, 1 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 67e86571685a..8abb07bf28e2 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -58,6 +58,8 @@
58#include <linux/compat.h> 58#include <linux/compat.h>
59#include <linux/vmalloc.h> 59#include <linux/vmalloc.h>
60 60
61#include <litmus/litmus.h>
62
61#include <asm/uaccess.h> 63#include <asm/uaccess.h>
62#include <asm/mmu_context.h> 64#include <asm/mmu_context.h>
63#include <asm/tlb.h> 65#include <asm/tlb.h>
@@ -1706,6 +1708,7 @@ static int do_execveat_common(int fd, struct filename *filename,
1706 goto out_unmark; 1708 goto out_unmark;
1707 1709
1708 sched_exec(); 1710 sched_exec();
1711 litmus_exec();
1709 1712
1710 bprm->file = file; 1713 bprm->file = file;
1711 if (fd == AT_FDCWD || filename->name[0] == '/') { 1714 if (fd == AT_FDCWD || filename->name[0] == '/') {
diff --git a/kernel/exit.c b/kernel/exit.c
index 3076f3089919..89ea9c8a7305 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -60,6 +60,8 @@
60#include <asm/pgtable.h> 60#include <asm/pgtable.h>
61#include <asm/mmu_context.h> 61#include <asm/mmu_context.h>
62 62
63extern void exit_od_table(struct task_struct *t);
64
63static void __unhash_process(struct task_struct *p, bool group_dead) 65static void __unhash_process(struct task_struct *p, bool group_dead)
64{ 66{
65 nr_threads--; 67 nr_threads--;
@@ -809,6 +811,8 @@ void __noreturn do_exit(long code)
809 tty_audit_exit(); 811 tty_audit_exit();
810 audit_free(tsk); 812 audit_free(tsk);
811 813
814 exit_od_table(tsk);
815
812 tsk->exit_code = code; 816 tsk->exit_code = code;
813 taskstats_exit(tsk, group_dead); 817 taskstats_exit(tsk, group_dead);
814 818
diff --git a/kernel/fork.c b/kernel/fork.c
index 59faac4de181..a8b40275b136 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -86,6 +86,9 @@
86 86
87#include <trace/events/sched.h> 87#include <trace/events/sched.h>
88 88
89#include <litmus/litmus.h>
90#include <litmus/sched_plugin.h>
91
89#define CREATE_TRACE_POINTS 92#define CREATE_TRACE_POINTS
90#include <trace/events/task.h> 93#include <trace/events/task.h>
91 94
@@ -386,6 +389,9 @@ void __put_task_struct(struct task_struct *tsk)
386 cgroup_free(tsk); 389 cgroup_free(tsk);
387 task_numa_free(tsk); 390 task_numa_free(tsk);
388 security_task_free(tsk); 391 security_task_free(tsk);
392
393 exit_litmus(tsk);
394
389 exit_creds(tsk); 395 exit_creds(tsk);
390 delayacct_tsk_free(tsk); 396 delayacct_tsk_free(tsk);
391 put_signal_struct(tsk->signal); 397 put_signal_struct(tsk->signal);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index abdf10c424f0..d1a8feda6918 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2415,6 +2415,8 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
2415 */ 2415 */
2416 p->prio = current->normal_prio; 2416 p->prio = current->normal_prio;
2417 2417
2418 litmus_fork(p);
2419
2418 /* 2420 /*
2419 * Revert to default priority/policy on fork if requested. 2421 * Revert to default priority/policy on fork if requested.
2420 */ 2422 */
@@ -2436,7 +2438,9 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
2436 p->sched_reset_on_fork = 0; 2438 p->sched_reset_on_fork = 0;
2437 } 2439 }
2438 2440
2439 if (dl_prio(p->prio)) { 2441 if (is_realtime(p)) {
2442 p->sched_class = &litmus_sched_class;
2443 } else if (dl_prio(p->prio)) {
2440 put_cpu(); 2444 put_cpu();
2441 return -EAGAIN; 2445 return -EAGAIN;
2442 } else if (rt_prio(p->prio)) { 2446 } else if (rt_prio(p->prio)) {
@@ -2593,6 +2597,9 @@ void wake_up_new_task(struct task_struct *p)
2593 struct rq_flags rf; 2597 struct rq_flags rf;
2594 struct rq *rq; 2598 struct rq *rq;
2595 2599
2600 if (is_realtime(p))
2601 litmus->task_new(p, 1, 0);
2602
2596 raw_spin_lock_irqsave(&p->pi_lock, rf.flags); 2603 raw_spin_lock_irqsave(&p->pi_lock, rf.flags);
2597 p->state = TASK_RUNNING; 2604 p->state = TASK_RUNNING;
2598#ifdef CONFIG_SMP 2605#ifdef CONFIG_SMP