From: <byungchul.park@lge.com>
To: mingo@kernel.org, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, yuyang.du@intel.com,
pjt@google.com, efault@gmx.de, tglx@linutronix.de,
Byungchul Park <byungchul.park@lge.com>
Subject: [PATCH v3 2/3] sched: factor out the code getting cfs_rq's last_update_time
Date: Thu, 15 Oct 2015 18:01:15 +0900 [thread overview]
Message-ID: <1444899676-5852-3-git-send-email-byungchul.park@lge.com> (raw)
In-Reply-To: <1444899676-5852-1-git-send-email-byungchul.park@lge.com>
From: Byungchul Park <byungchul.park@lge.com>
In the case that rq->lock may not be held, care must be taken to get a
cfs_rq's last_update_time instead of just reading the variable. Since
it can happen at serveral places in the code in future, this patch
factors it out to a helper function.
Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
kernel/sched/fair.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0f76903..08589a0 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2809,15 +2809,10 @@ dequeue_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
max_t(s64, cfs_rq->runnable_load_sum - se->avg.load_sum, 0);
}
-/*
- * Task first catches up with cfs_rq, and then subtract
- * itself from the cfs_rq (task must be off the queue now).
- */
-void remove_entity_load_avg(struct sched_entity *se)
+/* This function is useful for the case that rq->lock may not be held */
+static inline u64 get_last_update_time(struct cfs_rq *cfs_rq)
{
- struct cfs_rq *cfs_rq = cfs_rq_of(se);
u64 last_update_time;
-
#ifndef CONFIG_64BIT
u64 last_update_time_copy;
@@ -2829,6 +2824,17 @@ void remove_entity_load_avg(struct sched_entity *se)
#else
last_update_time = cfs_rq->avg.last_update_time;
#endif
+ return last_update_time;
+}
+
+/*
+ * Task first catches up with cfs_rq, and then subtract
+ * itself from the cfs_rq (task must be off the queue now).
+ */
+void remove_entity_load_avg(struct sched_entity *se)
+{
+ struct cfs_rq *cfs_rq = cfs_rq_of(se);
+ u64 last_update_time = get_last_update_time(cfs_rq);
__update_load_avg(last_update_time, cpu_of(rq_of(cfs_rq)), &se->avg, 0, 0, NULL);
atomic_long_add(se->avg.load_avg, &cfs_rq->removed_load_avg);
--
1.7.9.5
next prev parent reply other threads:[~2015-10-15 9:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-15 9:01 [PATCH v3 0/3] sched: account fair load avg consistently byungchul.park
2015-10-15 9:01 ` [PATCH v3 1/3] sched: introduce a new migration flag to task_struct byungchul.park
2015-10-15 11:18 ` Peter Zijlstra
2015-10-15 12:26 ` Byungchul Park
2015-10-15 18:34 ` Peter Zijlstra
2015-10-15 9:01 ` byungchul.park [this message]
2015-10-15 9:01 ` [PATCH v3 3/3] sched: make it possible to account fair class load avg consistently byungchul.park
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=1444899676-5852-3-git-send-email-byungchul.park@lge.com \
--to=byungchul.park@lge.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=tglx@linutronix.de \
--cc=yuyang.du@intel.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
all inboxes | Powered by JetHome®