sched/rt: Account execution time for cgroup and thread group if rt entity is task
PATCH 1/1 sched/rt: Account execution time for cgroup and thread group if rt entity is task
The rt entity can be a task group. Like the fair scheduler class, we don't need to account execution time for cgroup and thread group if the rt entity isn't a task.
Check the scheduler class of the task and make sure that the rt entity is a task.
Signed-off-by Yajun Deng <[email protected]>
--- kernel/sched/rt.c | 4 ---- kernel/sched/sched.h | 12 ++++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-)
kernel/sched/rt.c +0 -4
@@ -165,8 +165,6 @@ static void destroy_rt_bandwidth(struct rt_bandwidth *rt_b)hrtimer_cancel (&rt_b->rt_period_timer); } -#define rt_entity_is_task (rt_se) (!(rt_se)->my_q) -static inline struct task_struct *rt_task_of (struct sched_rt_entity *rt_se) {#ifdef CONFIG_SCHED_DEBUG
@@ -283,8 +281,6 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent)#else /* CONFIG_RT_GROUP_SCHED */ -#define rt_entity_is_task (rt_se) (1) -static inline struct task_struct *rt_task_of (struct sched_rt_entity *rt_se) { return container_of(rt_se, struct task_struct, rt);
kernel/sched/sched.h +10 -2
@@ -779,6 +779,11 @@ static inline long se_runnable(struct sched_entity *se) }#endif +#ifdef CONFIG_RT_GROUP_SCHED +#define rt_entity_is_task (rt_se) (!(rt_se)->my_q) +#else +#define rt_entity_is_task (rt_se) (1) +#ifdef CONFIG_SMP /* * XXX we want to get rid of these helpers and use the full load resolution.
@@ -3266,9 +3271,12 @@ static inline void update_current_exec_runtime(struct task_struct *curr, u64 now, u64 delta_exec) { curr->se.sum_exec_runtime += delta_exec; -account_group_exec_runtime (curr, delta_exec); - curr->se.exec_start = now; + +if (curr->sched_class == &rt_sched_class && !rt_entity_is_task (&curr->rt)) +return ; + +account_group_exec_runtime (curr, delta_exec);cgroup_account_cputime (curr, delta_exec); }
Signature · 1 line
2.25.1
Please ignore it, it's missing '#endif'.
Quoted 66 lines · Yajun Deng
The rt entity can be a task group. Like the fair scheduler class, we don't need to account execution time for cgroup and thread group if the rt entity isn't a task.
Check the scheduler class of the task and make sure that the rt entity is a task.
Signed-off-by Yajun Deng <[email protected]>--- kernel/sched/rt.c | 4 ---- kernel/sched/sched.h | 12 ++++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-)kernel/sched/rt.c +0
-4@@ -165,8 +165,6 @@ static void destroy_rt_bandwidth(struct rt_bandwidth *rt_b)hrtimer_cancel (&rt_b->rt_period_timer); } -#define rt_entity_is_task (rt_se) (!(rt_se)->my_q) -static inline struct task_struct *rt_task_of (struct sched_rt_entity *rt_se) {#ifdef CONFIG_SCHED_DEBUG @@ -283,8 +281,6 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent)#else /* CONFIG_RT_GROUP_SCHED */ -#define rt_entity_is_task (rt_se) (1) -static inline struct task_struct *rt_task_of (struct sched_rt_entity *rt_se) { return container_of(rt_se, struct task_struct, rt);kernel/sched/sched.h +10
-2@@ -779,6 +779,11 @@ static inline long se_runnable(struct sched_entity *se) }#endif +#ifdef CONFIG_RT_GROUP_SCHED +#define rt_entity_is_task (rt_se) (!(rt_se)->my_q) +#else +#define rt_entity_is_task (rt_se) (1) +#ifdef CONFIG_SMP /* * XXX we want to get rid of these helpers and use the full load resolution. @@ -3266,9 +3271,12 @@ static inline void update_current_exec_runtime(struct task_struct *curr, u64 now, u64 delta_exec) { curr->se.sum_exec_runtime += delta_exec; -account_group_exec_runtime (curr, delta_exec); - curr->se.exec_start = now; + +if (curr->sched_class == &rt_sched_class && !rt_entity_is_task (&curr->rt)) +return ; + +account_group_exec_runtime (curr, delta_exec);cgroup_account_cputime (curr, delta_exec); }