From: Oleg Nesterov <oleg@redhat.com>
To: Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>
Cc: Kirill Tkhai <tkhai@yandex.ru>,
Mike Galbraith <umgwanakikbuti@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] sched: normalize_rt_tasks: don't use _irqsave for tasklist_lock, use task_rq_lock()
Date: Sun, 21 Sep 2014 21:33:38 +0200 [thread overview]
Message-ID: <20140921193338.GA28621@redhat.com> (raw)
In-Reply-To: <20140921193316.GA28596@redhat.com>
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
next prev parent reply other threads:[~2014-09-21 19:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Oleg Nesterov [this message]
2014-09-24 14:56 ` [tip:sched/core] sched: normalize_rt_tasks(): Don' t use _irqsave for tasklist_lock, use task_rq_lock() 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140921193338.GA28621@redhat.com \
--to=oleg@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tkhai@yandex.ru \
--cc=umgwanakikbuti@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).