From: Kirill Tkhai <ktkhai@virtuozzo.com>
To: mingo@redhat.com, peterz@infradead.org,
linux-kernel@vger.kernel.org, ktkhai@virtuozzo.com
Subject: [PATCH 1/4] sched: Move manipulations with nr_iowait counter to separate functions
Date: Mon, 06 Nov 2017 17:40:23 +0300 [thread overview]
Message-ID: <150997922365.4082.11459898182580905440.stgit@localhost.localdomain> (raw)
In-Reply-To: <150997831079.4082.2128628793286090861.stgit@localhost.localdomain>
Move the (repeating) code to new helpers to reduce its volume and
to improve its readability.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
kernel/sched/core.c | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 72d1ab9550c0..712ee54edaa1 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -794,6 +794,18 @@ void deactivate_task(struct rq *rq, struct task_struct *p, int flags)
dequeue_task(rq, p, flags);
}
+static void task_iowait_start(struct rq *rq, struct task_struct *p)
+{
+ atomic_inc(&rq->nr_iowait);
+ delayacct_blkio_start();
+}
+
+static void task_iowait_end(struct rq *rq, struct task_struct *p)
+{
+ delayacct_blkio_end();
+ atomic_dec(&rq->nr_iowait);
+}
+
/*
* __normal_prio - return the priority that is based on the static prio
*/
@@ -2051,10 +2063,8 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
p->sched_contributes_to_load = !!task_contributes_to_load(p);
p->state = TASK_WAKING;
- if (p->in_iowait) {
- delayacct_blkio_end();
- atomic_dec(&task_rq(p)->nr_iowait);
- }
+ if (p->in_iowait)
+ task_iowait_end(task_rq(p), p);
cpu = select_task_rq(p, p->wake_cpu, SD_BALANCE_WAKE, wake_flags);
if (task_cpu(p) != cpu) {
@@ -2064,10 +2074,8 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
#else /* CONFIG_SMP */
- if (p->in_iowait) {
- delayacct_blkio_end();
- atomic_dec(&task_rq(p)->nr_iowait);
- }
+ if (p->in_iowait)
+ task_iowait_end(task_rq(p), p);
#endif /* CONFIG_SMP */
@@ -2117,10 +2125,8 @@ static void try_to_wake_up_local(struct task_struct *p, struct rq_flags *rf)
trace_sched_waking(p);
if (!task_on_rq_queued(p)) {
- if (p->in_iowait) {
- delayacct_blkio_end();
- atomic_dec(&rq->nr_iowait);
- }
+ if (p->in_iowait)
+ task_iowait_end(rq, p);
ttwu_activate(rq, p, ENQUEUE_WAKEUP | ENQUEUE_NOCLOCK);
}
@@ -3320,10 +3326,8 @@ static void __sched notrace __schedule(bool preempt)
deactivate_task(rq, prev, DEQUEUE_SLEEP | DEQUEUE_NOCLOCK);
prev->on_rq = 0;
- if (prev->in_iowait) {
- atomic_inc(&rq->nr_iowait);
- delayacct_blkio_start();
- }
+ if (prev->in_iowait)
+ task_iowait_start(rq, prev);
/*
* If a worker went to sleep, notify and ask workqueue
next prev parent reply other threads:[~2017-11-06 14:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-06 14:40 [PATCH 0/4] Show cpu cgroup's nr_running and nr_iowait in cpu.stat file Kirill Tkhai
2017-11-06 14:40 ` Kirill Tkhai [this message]
2017-11-06 14:40 ` [PATCH 2/4] sched: Account per task_group nr_iowait Kirill Tkhai
2017-11-06 16:06 ` Peter Zijlstra
2017-11-06 16:12 ` Kirill Tkhai
2017-11-06 16:24 ` Peter Zijlstra
2017-11-06 16:25 ` Peter Zijlstra
2017-11-06 14:40 ` [PATCH 3/4] sched: Export per task_cgroup nr_iowait to userspace Kirill Tkhai
2017-11-06 14:40 ` [PATCH 4/4] sched: Export per task_cgroup nr_running " Kirill Tkhai
2017-11-06 16:04 ` [PATCH 0/4] Show cpu cgroup's nr_running and nr_iowait in cpu.stat file Peter Zijlstra
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=150997922365.4082.11459898182580905440.stgit@localhost.localdomain \
--to=ktkhai@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/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
all inboxes | Powered by JetHome®