From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752229AbbJOJDI (ORCPT ); Thu, 15 Oct 2015 05:03:08 -0400 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:40005 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750852AbbJOJCV (ORCPT ); Thu, 15 Oct 2015 05:02:21 -0400 X-Original-SENDERIP: 156.147.1.151 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 165.244.98.203 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com From: 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 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 Message-ID: <1444899676-5852-3-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1444899676-5852-1-git-send-email-byungchul.park@lge.com> References: <1444899676-5852-1-git-send-email-byungchul.park@lge.com> X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB05/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2015/10/15 18:02:18, Serialize by Router on LGEKRMHUB05/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2015/10/15 18:02:18, Serialize complete at 2015/10/15 18:02:18 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Byungchul Park 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 --- 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