aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r--kernel/sched/core.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 5c883fe8e440..2a906f20fba7 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -74,6 +74,7 @@
74#include <linux/context_tracking.h> 74#include <linux/context_tracking.h>
75#include <linux/compiler.h> 75#include <linux/compiler.h>
76#include <linux/frame.h> 76#include <linux/frame.h>
77#include <linux/prefetch.h>
77 78
78#include <asm/switch_to.h> 79#include <asm/switch_to.h>
79#include <asm/tlb.h> 80#include <asm/tlb.h>
@@ -2972,6 +2973,23 @@ EXPORT_PER_CPU_SYMBOL(kstat);
2972EXPORT_PER_CPU_SYMBOL(kernel_cpustat); 2973EXPORT_PER_CPU_SYMBOL(kernel_cpustat);
2973 2974
2974/* 2975/*
2976 * The function fair_sched_class.update_curr accesses the struct curr
2977 * and its field curr->exec_start; when called from task_sched_runtime(),
2978 * we observe a high rate of cache misses in practice.
2979 * Prefetching this data results in improved performance.
2980 */
2981static inline void prefetch_curr_exec_start(struct task_struct *p)
2982{
2983#ifdef CONFIG_FAIR_GROUP_SCHED
2984 struct sched_entity *curr = (&p->se)->cfs_rq->curr;
2985#else
2986 struct sched_entity *curr = (&task_rq(p)->cfs)->curr;
2987#endif
2988 prefetch(curr);
2989 prefetch(&curr->exec_start);
2990}
2991
2992/*
2975 * Return accounted runtime for the task. 2993 * Return accounted runtime for the task.
2976 * In case the task is currently running, return the runtime plus current's 2994 * In case the task is currently running, return the runtime plus current's
2977 * pending runtime that have not been accounted yet. 2995 * pending runtime that have not been accounted yet.
@@ -3005,6 +3023,7 @@ unsigned long long task_sched_runtime(struct task_struct *p)
3005 * thread, breaking clock_gettime(). 3023 * thread, breaking clock_gettime().
3006 */ 3024 */
3007 if (task_current(rq, p) && task_on_rq_queued(p)) { 3025 if (task_current(rq, p) && task_on_rq_queued(p)) {
3026 prefetch_curr_exec_start(p);
3008 update_rq_clock(rq); 3027 update_rq_clock(rq);
3009 p->sched_class->update_curr(rq); 3028 p->sched_class->update_curr(rq);
3010 } 3029 }