* [PATCH 0/3] sched: fix tg_has_rt_tasks(), tasklist_lock cleanups
@ 2014-09-21 19:33 Oleg Nesterov
2014-09-21 19:33 ` [PATCH 1/3] sched: fix the task-group check in tg_has_rt_tasks() Oleg Nesterov
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Oleg Nesterov @ 2014-09-21 19:33 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra; +Cc: Kirill Tkhai, Mike Galbraith, linux-kernel
This textually depends on
5d07f4202c5d63b73ba1734ed38e08461a689313
"sched: s/do_each_thread/for_each_process_thread/ in core.c"
d38e83c715270cc2e137bbf6f25206c8c023896b
"sched: s/do_each_thread/for_each_process_thread/ in debug.c"
in -tip tree.
Kirill, you seem to agree with 1/3, I'll appreciate your ack.
Oleg.
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/3] sched: fix the task-group check in tg_has_rt_tasks() 2014-09-21 19:33 [PATCH 0/3] sched: fix tg_has_rt_tasks(), tasklist_lock cleanups Oleg Nesterov @ 2014-09-21 19:33 ` Oleg Nesterov 2014-09-22 6:54 ` Kirill Tkhai 2014-09-24 14:55 ` [tip:sched/core] sched: Fix " tip-bot for Oleg Nesterov 2014-09-21 19:33 ` [PATCH 2/3] sched: normalize_rt_tasks: don't use _irqsave for tasklist_lock, use task_rq_lock() Oleg Nesterov 2014-09-21 19:33 ` [PATCH 3/3] sched: print_rq: don't use tasklist_lock Oleg Nesterov 2 siblings, 2 replies; 8+ messages in thread From: Oleg Nesterov @ 2014-09-21 19:33 UTC (permalink / raw) To: Ingo Molnar, Peter Zijlstra; +Cc: Kirill Tkhai, Mike Galbraith, linux-kernel tg_has_rt_tasks() wants to find an RT task in this task_group, but task_rq(p)->rt.tg wrongly checks the root rt_rq. Signed-off-by: Oleg Nesterov <oleg@redhat.com> --- kernel/sched/core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index eee12b3..9023f56 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7354,7 +7354,7 @@ static inline int tg_has_rt_tasks(struct task_group *tg) struct task_struct *g, *p; for_each_process_thread(g, p) { - if (rt_task(p) && task_rq(p)->rt.tg == tg) + if (rt_task(p) && task_group(p) == tg) return 1; } -- 1.5.5.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] sched: fix the task-group check in tg_has_rt_tasks() 2014-09-21 19:33 ` [PATCH 1/3] sched: fix the task-group check in tg_has_rt_tasks() Oleg Nesterov @ 2014-09-22 6:54 ` Kirill Tkhai 2014-09-24 14:55 ` [tip:sched/core] sched: Fix " tip-bot for Oleg Nesterov 1 sibling, 0 replies; 8+ messages in thread From: Kirill Tkhai @ 2014-09-22 6:54 UTC (permalink / raw) To: Oleg Nesterov; +Cc: Ingo Molnar, Peter Zijlstra, Mike Galbraith, linux-kernel В Вс, 21/09/2014 в 21:33 +0200, Oleg Nesterov пишет: > tg_has_rt_tasks() wants to find an RT task in this task_group, but > task_rq(p)->rt.tg wrongly checks the root rt_rq. > > Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Kirill Tkhai <ktkhai@parallels.com> > --- > kernel/sched/core.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index eee12b3..9023f56 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -7354,7 +7354,7 @@ static inline int tg_has_rt_tasks(struct task_group *tg) > struct task_struct *g, *p; > > for_each_process_thread(g, p) { > - if (rt_task(p) && task_rq(p)->rt.tg == tg) > + if (rt_task(p) && task_group(p) == tg) > return 1; > } > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [tip:sched/core] sched: Fix the task-group check in tg_has_rt_tasks() 2014-09-21 19:33 ` [PATCH 1/3] sched: fix the task-group check in tg_has_rt_tasks() Oleg Nesterov 2014-09-22 6:54 ` Kirill Tkhai @ 2014-09-24 14:55 ` tip-bot for Oleg Nesterov 1 sibling, 0 replies; 8+ messages in thread From: tip-bot for Oleg Nesterov @ 2014-09-24 14:55 UTC (permalink / raw) To: linux-tip-commits Cc: linux-kernel, ktkhai, hpa, mingo, peterz, umgwanakikbuti, tglx, oleg Commit-ID: 8651c65844e93af44554272b7e0d2b142837b244 Gitweb: http://git.kernel.org/tip/8651c65844e93af44554272b7e0d2b142837b244 Author: Oleg Nesterov <oleg@redhat.com> AuthorDate: Sun, 21 Sep 2014 21:33:36 +0200 Committer: Ingo Molnar <mingo@kernel.org> CommitDate: Wed, 24 Sep 2014 14:47:00 +0200 sched: Fix the task-group check in tg_has_rt_tasks() tg_has_rt_tasks() wants to find an RT task in this task_group, but task_rq(p)->rt.tg wrongly checks the root rt_rq. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Kirill Tkhai <ktkhai@parallels.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Mike Galbraith <umgwanakikbuti@gmail.com> Link: http://lkml.kernel.org/r/20140921193336.GA28618@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org> --- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 09bde2a..0abfb7e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7441,7 +7441,7 @@ static inline int tg_has_rt_tasks(struct task_group *tg) struct task_struct *g, *p; for_each_process_thread(g, p) { - if (rt_task(p) && task_rq(p)->rt.tg == tg) + if (rt_task(p) && task_group(p) == tg) return 1; } ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] sched: normalize_rt_tasks: don't use _irqsave for tasklist_lock, use task_rq_lock() 2014-09-21 19:33 [PATCH 0/3] sched: fix tg_has_rt_tasks(), tasklist_lock cleanups Oleg Nesterov 2014-09-21 19:33 ` [PATCH 1/3] sched: fix the task-group check in tg_has_rt_tasks() Oleg Nesterov @ 2014-09-21 19:33 ` Oleg Nesterov 2014-09-24 14:56 ` [tip:sched/core] sched: normalize_rt_tasks(): Don' t " tip-bot for Oleg Nesterov 2014-09-21 19:33 ` [PATCH 3/3] sched: print_rq: don't use tasklist_lock Oleg Nesterov 2 siblings, 1 reply; 8+ messages in thread From: Oleg Nesterov @ 2014-09-21 19:33 UTC (permalink / raw) To: Ingo Molnar, Peter Zijlstra; +Cc: Kirill Tkhai, Mike Galbraith, linux-kernel 1. read_lock(tasklist_lock) does not need to disable irqs. 2. ->mm != NULL is the common mistake, use PF_KTHREAD. 3. The second ->mm check can be simply removed. 4. task_rq_lock() looks better than raw_spin_lock(&p->pi_lock) + __task_rq_lock(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> --- kernel/sched/core.c | 16 ++++++---------- 1 files changed, 6 insertions(+), 10 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 8a6506f..eee12b3 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7137,12 +7137,12 @@ void normalize_rt_tasks(void) unsigned long flags; struct rq *rq; - read_lock_irqsave(&tasklist_lock, flags); + read_lock(&tasklist_lock); for_each_process_thread(g, p) { /* * Only normalize user tasks: */ - if (!p->mm) + if (p->flags & PF_KTHREAD) continue; p->se.exec_start = 0; @@ -7157,20 +7157,16 @@ void normalize_rt_tasks(void) * Renice negative nice level userspace * tasks back to 0: */ - if (task_nice(p) < 0 && p->mm) + if (task_nice(p) < 0) set_user_nice(p, 0); continue; } - raw_spin_lock(&p->pi_lock); - rq = __task_rq_lock(p); - + rq = task_rq_lock(p, &flags); normalize_task(rq, p); - - __task_rq_unlock(rq); - raw_spin_unlock(&p->pi_lock); + task_rq_unlock(rq, p, &flags); } - read_unlock_irqrestore(&tasklist_lock, flags); + read_unlock(&tasklist_lock); } #endif /* CONFIG_MAGIC_SYSRQ */ -- 1.5.5.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tip:sched/core] sched: normalize_rt_tasks(): Don' t use _irqsave for tasklist_lock, use task_rq_lock() 2014-09-21 19:33 ` [PATCH 2/3] sched: normalize_rt_tasks: don't use _irqsave for tasklist_lock, use task_rq_lock() Oleg Nesterov @ 2014-09-24 14:56 ` tip-bot for Oleg Nesterov 0 siblings, 0 replies; 8+ messages in thread From: tip-bot for Oleg Nesterov @ 2014-09-24 14:56 UTC (permalink / raw) To: linux-tip-commits Cc: linux-kernel, hpa, mingo, torvalds, peterz, umgwanakikbuti, tkhai, tglx, oleg Commit-ID: 3472eaa1f12e217e2b8b0ef658ff861b2308cbbd Gitweb: http://git.kernel.org/tip/3472eaa1f12e217e2b8b0ef658ff861b2308cbbd Author: Oleg Nesterov <oleg@redhat.com> AuthorDate: Sun, 21 Sep 2014 21:33:38 +0200 Committer: Ingo Molnar <mingo@kernel.org> CommitDate: Wed, 24 Sep 2014 14:47:03 +0200 sched: normalize_rt_tasks(): Don't use _irqsave for tasklist_lock, use task_rq_lock() 1. read_lock(tasklist_lock) does not need to disable irqs. 2. ->mm != NULL is a common mistake, use PF_KTHREAD. 3. The second ->mm check can be simply removed. 4. task_rq_lock() looks better than raw_spin_lock(&p->pi_lock) + __task_rq_lock(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Kirill Tkhai <tkhai@yandex.ru> Cc: Mike Galbraith <umgwanakikbuti@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/20140921193338.GA28621@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org> --- kernel/sched/core.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 0abfb7e..d65566d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7220,12 +7220,12 @@ void normalize_rt_tasks(void) unsigned long flags; struct rq *rq; - read_lock_irqsave(&tasklist_lock, flags); + read_lock(&tasklist_lock); for_each_process_thread(g, p) { /* * Only normalize user tasks: */ - if (!p->mm) + if (p->flags & PF_KTHREAD) continue; p->se.exec_start = 0; @@ -7240,20 +7240,16 @@ void normalize_rt_tasks(void) * Renice negative nice level userspace * tasks back to 0: */ - if (task_nice(p) < 0 && p->mm) + if (task_nice(p) < 0) set_user_nice(p, 0); continue; } - raw_spin_lock(&p->pi_lock); - rq = __task_rq_lock(p); - + rq = task_rq_lock(p, &flags); normalize_task(rq, p); - - __task_rq_unlock(rq); - raw_spin_unlock(&p->pi_lock); + task_rq_unlock(rq, p, &flags); } - read_unlock_irqrestore(&tasklist_lock, flags); + read_unlock(&tasklist_lock); } #endif /* CONFIG_MAGIC_SYSRQ */ ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] sched: print_rq: don't use tasklist_lock 2014-09-21 19:33 [PATCH 0/3] sched: fix tg_has_rt_tasks(), tasklist_lock cleanups Oleg Nesterov 2014-09-21 19:33 ` [PATCH 1/3] sched: fix the task-group check in tg_has_rt_tasks() Oleg Nesterov 2014-09-21 19:33 ` [PATCH 2/3] sched: normalize_rt_tasks: don't use _irqsave for tasklist_lock, use task_rq_lock() Oleg Nesterov @ 2014-09-21 19:33 ` Oleg Nesterov 2014-09-24 14:56 ` [tip:sched/core] sched: print_rq(): Don't " tip-bot for Oleg Nesterov 2 siblings, 1 reply; 8+ messages in thread From: Oleg Nesterov @ 2014-09-21 19:33 UTC (permalink / raw) To: Ingo Molnar, Peter Zijlstra; +Cc: Kirill Tkhai, Mike Galbraith, linux-kernel read_lock_irqsave(tasklist_lock) in print_rq() looks strange. We do not need to disable irqs, and they are already disabled by the caller. And afaics this lock buys nothing, we can rely on rcu_read_lock(). In this case it makes sense to also move rcu_read_lock/unlock from the caller to print_rq(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> --- kernel/sched/debug.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index c7fe1ea..ce33780 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -150,7 +150,6 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu) { struct task_struct *g, *p; - unsigned long flags; SEQ_printf(m, "\nrunnable tasks:\n" @@ -159,14 +158,14 @@ static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu) "------------------------------------------------------" "----------------------------------------------------\n"); - read_lock_irqsave(&tasklist_lock, flags); + rcu_read_lock(); for_each_process_thread(g, p) { if (task_cpu(p) != rq_cpu) continue; print_task(m, rq, p); } - read_unlock_irqrestore(&tasklist_lock, flags); + rcu_read_unlock(); } void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) @@ -331,9 +330,7 @@ do { \ print_cfs_stats(m, cpu); print_rt_stats(m, cpu); - rcu_read_lock(); print_rq(m, rq, cpu); - rcu_read_unlock(); spin_unlock_irqrestore(&sched_debug_lock, flags); SEQ_printf(m, "\n"); } -- 1.5.5.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tip:sched/core] sched: print_rq(): Don't use tasklist_lock 2014-09-21 19:33 ` [PATCH 3/3] sched: print_rq: don't use tasklist_lock Oleg Nesterov @ 2014-09-24 14:56 ` tip-bot for Oleg Nesterov 0 siblings, 0 replies; 8+ messages in thread From: tip-bot for Oleg Nesterov @ 2014-09-24 14:56 UTC (permalink / raw) To: linux-tip-commits Cc: linux-kernel, hpa, mingo, torvalds, peterz, umgwanakikbuti, tkhai, tglx, oleg Commit-ID: 5bd96ab6fef66ec6b9f54134364e618fd0f8f2f3 Gitweb: http://git.kernel.org/tip/5bd96ab6fef66ec6b9f54134364e618fd0f8f2f3 Author: Oleg Nesterov <oleg@redhat.com> AuthorDate: Sun, 21 Sep 2014 21:33:41 +0200 Committer: Ingo Molnar <mingo@kernel.org> CommitDate: Wed, 24 Sep 2014 14:47:04 +0200 sched: print_rq(): Don't use tasklist_lock read_lock_irqsave(tasklist_lock) in print_rq() looks strange. We do not need to disable irqs, and they are already disabled by the caller. And afaics this lock buys nothing, we can rely on rcu_read_lock(). In this case it makes sense to also move rcu_read_lock/unlock from the caller to print_rq(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Kirill Tkhai <tkhai@yandex.ru> Cc: Mike Galbraith <umgwanakikbuti@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/20140921193341.GA28628@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org> --- kernel/sched/debug.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index c7fe1ea0..ce33780 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -150,7 +150,6 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu) { struct task_struct *g, *p; - unsigned long flags; SEQ_printf(m, "\nrunnable tasks:\n" @@ -159,14 +158,14 @@ static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu) "------------------------------------------------------" "----------------------------------------------------\n"); - read_lock_irqsave(&tasklist_lock, flags); + rcu_read_lock(); for_each_process_thread(g, p) { if (task_cpu(p) != rq_cpu) continue; print_task(m, rq, p); } - read_unlock_irqrestore(&tasklist_lock, flags); + rcu_read_unlock(); } void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) @@ -331,9 +330,7 @@ do { \ print_cfs_stats(m, cpu); print_rt_stats(m, cpu); - rcu_read_lock(); print_rq(m, rq, cpu); - rcu_read_unlock(); spin_unlock_irqrestore(&sched_debug_lock, flags); SEQ_printf(m, "\n"); } ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-09-24 15:06 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-21 19:33 [PATCH 0/3] sched: fix tg_has_rt_tasks(), tasklist_lock cleanups Oleg Nesterov 2014-09-21 19:33 ` [PATCH 1/3] sched: fix the task-group check in tg_has_rt_tasks() Oleg Nesterov 2014-09-22 6:54 ` Kirill Tkhai 2014-09-24 14:55 ` [tip:sched/core] sched: Fix " tip-bot for Oleg Nesterov 2014-09-21 19:33 ` [PATCH 2/3] sched: normalize_rt_tasks: don't use _irqsave for tasklist_lock, use task_rq_lock() Oleg Nesterov 2014-09-24 14:56 ` [tip:sched/core] sched: normalize_rt_tasks(): Don' t " tip-bot for Oleg Nesterov 2014-09-21 19:33 ` [PATCH 3/3] sched: print_rq: don't use tasklist_lock Oleg Nesterov 2014-09-24 14:56 ` [tip:sched/core] sched: print_rq(): Don't " tip-bot for Oleg Nesterov
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.