mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] sched/fair: Set sched_entity::depth only when parent has changed
@ 2017-02-21 12:10 Kirill Tkhai
  2017-02-21 12:10 ` [PATCH 2/3] sched/fair: Kill task_set_group_fair() Kirill Tkhai
  2017-02-21 12:10 ` [PATCH 3/3] sched/fair: Kill task_change_group_fair() Kirill Tkhai
  0 siblings, 2 replies; 3+ messages in thread
From: Kirill Tkhai @ 2017-02-21 12:10 UTC (permalink / raw)
  To: peterz, mingo, linux-kernel, ktkhai

Currently we set depth in two places, and this confuses a reader.
Task's depth depends on parent's depth and it may change only if
parent has changed. So, set it in set_task_rq(), where parent is set.

(cfs_rq's depth is set in init_tg_cfs_entry() and it's static, so
 this change don't touch them).

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 kernel/sched/fair.c  |   11 -----------
 kernel/sched/sched.h |    1 +
 2 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 3e88b35ac157..33b46ca301f0 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9102,14 +9102,6 @@ static void attach_entity_cfs_rq(struct sched_entity *se)
 {
 	struct cfs_rq *cfs_rq = cfs_rq_of(se);
 
-#ifdef CONFIG_FAIR_GROUP_SCHED
-	/*
-	 * Since the real-depth could have been changed (only FAIR
-	 * class maintain depth value), reset depth properly.
-	 */
-	se->depth = se->parent ? se->parent->depth + 1 : 0;
-#endif
-
 	/* Synchronize entity with its cfs_rq */
 	update_load_avg(se, sched_feat(ATTACH_AGE_LOAD) ? 0 : SKIP_AGE_LOAD);
 	attach_entity_load_avg(cfs_rq, se);
@@ -9204,10 +9196,7 @@ void init_cfs_rq(struct cfs_rq *cfs_rq)
 #ifdef CONFIG_FAIR_GROUP_SCHED
 static void task_set_group_fair(struct task_struct *p)
 {
-	struct sched_entity *se = &p->se;
-
 	set_task_rq(p, task_cpu(p));
-	se->depth = se->parent ? se->parent->depth + 1 : 0;
 }
 
 static void task_move_group_fair(struct task_struct *p)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 207fc1f4c764..4a9313f0b5c8 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1123,6 +1123,7 @@ static inline void set_task_rq(struct task_struct *p, unsigned int cpu)
 	set_task_rq_fair(&p->se, p->se.cfs_rq, tg->cfs_rq[cpu]);
 	p->se.cfs_rq = tg->cfs_rq[cpu];
 	p->se.parent = tg->se[cpu];
+	p->se.depth = p->se.parent ? p->se.parent->depth + 1 : 0;
 #endif
 
 #ifdef CONFIG_RT_GROUP_SCHED

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] sched/fair: Kill task_set_group_fair()
  2017-02-21 12:10 [PATCH 1/3] sched/fair: Set sched_entity::depth only when parent has changed Kirill Tkhai
@ 2017-02-21 12:10 ` Kirill Tkhai
  2017-02-21 12:10 ` [PATCH 3/3] sched/fair: Kill task_change_group_fair() Kirill Tkhai
  1 sibling, 0 replies; 3+ messages in thread
From: Kirill Tkhai @ 2017-02-21 12:10 UTC (permalink / raw)
  To: peterz, mingo, linux-kernel, ktkhai

Now this is one-line function, which may be merged into task_change_group_fair().

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 kernel/sched/fair.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 33b46ca301f0..a005bee12e0b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9194,11 +9194,6 @@ void init_cfs_rq(struct cfs_rq *cfs_rq)
 }
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
-static void task_set_group_fair(struct task_struct *p)
-{
-	set_task_rq(p, task_cpu(p));
-}
-
 static void task_move_group_fair(struct task_struct *p)
 {
 	detach_task_cfs_rq(p);
@@ -9215,7 +9210,7 @@ static void task_change_group_fair(struct task_struct *p, int type)
 {
 	switch (type) {
 	case TASK_SET_GROUP:
-		task_set_group_fair(p);
+		set_task_rq(p, task_cpu(p));
 		break;
 
 	case TASK_MOVE_GROUP:

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 3/3] sched/fair: Kill task_change_group_fair()
  2017-02-21 12:10 [PATCH 1/3] sched/fair: Set sched_entity::depth only when parent has changed Kirill Tkhai
  2017-02-21 12:10 ` [PATCH 2/3] sched/fair: Kill task_set_group_fair() Kirill Tkhai
@ 2017-02-21 12:10 ` Kirill Tkhai
  1 sibling, 0 replies; 3+ messages in thread
From: Kirill Tkhai @ 2017-02-21 12:10 UTC (permalink / raw)
  To: peterz, mingo, linux-kernel, ktkhai

Since we need the special behaviour for TASK_MOVE_GROUP case only,
we may move the switch up to sched_change_group() and kill
task_change_group_fair().
I suppose, this may simplify the code in some way.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 kernel/sched/core.c  |    4 ++--
 kernel/sched/fair.c  |   15 +--------------
 kernel/sched/sched.h |    2 +-
 3 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8f972df76eb2..5007892342b2 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6395,8 +6395,8 @@ static void sched_change_group(struct task_struct *tsk, int type)
 	tsk->sched_task_group = tg;
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
-	if (tsk->sched_class->task_change_group)
-		tsk->sched_class->task_change_group(tsk, type);
+	if (tsk->sched_class->task_move_group && type == TASK_MOVE_GROUP)
+		tsk->sched_class->task_move_group(tsk);
 	else
 #endif
 		set_task_rq(tsk, task_cpu(tsk));
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a005bee12e0b..cf6d12513a3f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9206,19 +9206,6 @@ static void task_move_group_fair(struct task_struct *p)
 	attach_task_cfs_rq(p);
 }
 
-static void task_change_group_fair(struct task_struct *p, int type)
-{
-	switch (type) {
-	case TASK_SET_GROUP:
-		set_task_rq(p, task_cpu(p));
-		break;
-
-	case TASK_MOVE_GROUP:
-		task_move_group_fair(p);
-		break;
-	}
-}
-
 void free_fair_sched_group(struct task_group *tg)
 {
 	int i;
@@ -9462,7 +9449,7 @@ const struct sched_class fair_sched_class = {
 	.update_curr		= update_curr_fair,
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
-	.task_change_group	= task_change_group_fair,
+	.task_move_group	= task_move_group_fair,
 #endif
 };
 
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 4a9313f0b5c8..f2bc04826ea5 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1407,7 +1407,7 @@ struct sched_class {
 #define TASK_MOVE_GROUP	1
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
-	void (*task_change_group) (struct task_struct *p, int type);
+	void (*task_move_group) (struct task_struct *p);
 #endif
 };
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-21 12:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21 12:10 [PATCH 1/3] sched/fair: Set sched_entity::depth only when parent has changed Kirill Tkhai
2017-02-21 12:10 ` [PATCH 2/3] sched/fair: Kill task_set_group_fair() Kirill Tkhai
2017-02-21 12:10 ` [PATCH 3/3] sched/fair: Kill task_change_group_fair() Kirill Tkhai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®