Explorar o código

sched: add latency tracer callbacks to the scheduler

add 3 lightweight callbacks to the tracer backend.

zero impact if tracing is turned off.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Ingo Molnar %!s(int64=17) %!d(string=hai) anos
pai
achega
bd3bff9e20
Modificáronse 2 ficheiros con 29 adicións e 0 borrados
  1. 26 0
      include/linux/sched.h
  2. 3 0
      kernel/sched.c

+ 26 - 0
include/linux/sched.h

@@ -2117,6 +2117,32 @@ static inline void arch_pick_mmap_layout(struct mm_struct *mm)
 }
 }
 #endif
 #endif
 
 
+#ifdef CONFIG_CONTEXT_SWITCH_TRACER
+extern void
+ftrace_ctx_switch(struct task_struct *prev, struct task_struct *next);
+#else
+static inline void
+ftrace_ctx_switch(struct task_struct *prev, struct task_struct *next)
+{
+}
+#endif
+
+#ifdef CONFIG_SCHED_TRACER
+extern void
+ftrace_wake_up_task(struct task_struct *wakee, struct task_struct *curr);
+extern void
+ftrace_wake_up_new_task(struct task_struct *wakee, struct task_struct *curr);
+#else
+static inline void
+ftrace_wake_up_task(struct task_struct *wakee, struct task_struct *curr)
+{
+}
+static inline void
+ftrace_wake_up_new_task(struct task_struct *wakee, struct task_struct *curr)
+{
+}
+#endif
+
 extern long sched_setaffinity(pid_t pid, const cpumask_t *new_mask);
 extern long sched_setaffinity(pid_t pid, const cpumask_t *new_mask);
 extern long sched_getaffinity(pid_t pid, cpumask_t *mask);
 extern long sched_getaffinity(pid_t pid, cpumask_t *mask);
 
 

+ 3 - 0
kernel/sched.c

@@ -2467,6 +2467,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync)
 
 
 out_activate:
 out_activate:
 #endif /* CONFIG_SMP */
 #endif /* CONFIG_SMP */
+	ftrace_wake_up_task(p, rq->curr);
 	schedstat_inc(p, se.nr_wakeups);
 	schedstat_inc(p, se.nr_wakeups);
 	if (sync)
 	if (sync)
 		schedstat_inc(p, se.nr_wakeups_sync);
 		schedstat_inc(p, se.nr_wakeups_sync);
@@ -2611,6 +2612,7 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
 		p->sched_class->task_new(rq, p);
 		p->sched_class->task_new(rq, p);
 		inc_nr_running(rq);
 		inc_nr_running(rq);
 	}
 	}
+	ftrace_wake_up_new_task(p, rq->curr);
 	check_preempt_curr(rq, p);
 	check_preempt_curr(rq, p);
 #ifdef CONFIG_SMP
 #ifdef CONFIG_SMP
 	if (p->sched_class->task_wake_up)
 	if (p->sched_class->task_wake_up)
@@ -2783,6 +2785,7 @@ context_switch(struct rq *rq, struct task_struct *prev,
 	struct mm_struct *mm, *oldmm;
 	struct mm_struct *mm, *oldmm;
 
 
 	prepare_task_switch(rq, prev, next);
 	prepare_task_switch(rq, prev, next);
+	ftrace_ctx_switch(prev, next);
 	mm = next->mm;
 	mm = next->mm;
 	oldmm = prev->active_mm;
 	oldmm = prev->active_mm;
 	/*
 	/*