Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756241AbcJ1HLl (ORCPT ); Fri, 28 Oct 2016 03:11:41 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44700 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751269AbcJ1HLj (ORCPT ); Fri, 28 Oct 2016 03:11:39 -0400 DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org B784061657 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=markivx@codeaurora.org From: Vikram Mulukutla To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Srivatsa Vaddagiri , Steve Muckle , Olav Haugan , Syed Rameez Mustafa , Joonwoo Park , Pavankumar Kondeti , Saravana Kannan , Bryan Huntsman , Juri Lelli , Morten Rasmussen , Dietmar Eggemann , Chris Redpath , Robin Randhawa , Patrick Bellasi , Todd Kjos , Srinath Sridharan , Andres Oportus , Leo Yan , Vincent Guittot , Vikram Mulukutla , Vikram Mulukutla Subject: [RFC PATCH 1/3] sched: Introduce structures necessary for WALT Date: Fri, 28 Oct 2016 00:10:40 -0700 Message-Id: <1477638642-17428-2-git-send-email-markivx@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477638642-17428-1-git-send-email-markivx@codeaurora.org> References: <1477638642-17428-1-git-send-email-markivx@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3392 Lines: 122 From: Srivatsa Vaddagiri Add the per-task and per-runqueue data structures that will later be used by Window Assisted Load Tracking (WALT) to estimate task demand and CPU utilization. Move cap_scale into sched.h as that will be needed by WALT as well to implement frequency and capacity invariance. Signed-off-by: Srivatsa Vaddagiri Signed-off-by: Vikram Mulukutla --- include/linux/sched.h | 39 +++++++++++++++++++++++++++++++++++++++ kernel/sched/fair.c | 2 -- kernel/sched/sched.h | 8 ++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 62c68e5..64f8bec 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -315,6 +315,21 @@ extern char ___assert_task_state[1 - 2*!!( /* Task command name length */ #define TASK_COMM_LEN 16 +/* + * These events may be replaced with a combination of existing scheduler flags + * provided that that doesn't make the implementation too fragile. + */ +enum task_event { + PUT_PREV_TASK = 0, + PICK_NEXT_TASK = 1, + TASK_WAKE = 2, + TASK_MIGRATE = 3, + TASK_UPDATE = 4, + IRQ_UPDATE = 5, +}; + +extern char *task_event_names[]; + #include /* @@ -1320,6 +1335,25 @@ struct sched_statistics { }; #endif +#ifdef CONFIG_SCHED_WALT + +/* ravg represents capacity scaled cpu-usage of tasks */ +struct ravg { + /* + * 'mark_start' marks the most recent event for a task + * + * 'curr_window' represents task's cpu usage in its most recent + * window + * + * 'prev_window' represents task's cpu usage in the window prior + * to the one represented by 'curr_window' + */ + u64 mark_start; + u32 curr_window, prev_window; +}; +#endif + + struct sched_entity { struct load_weight load; /* for load-balancing */ struct rb_node run_node; @@ -1480,6 +1514,11 @@ struct task_struct { const struct sched_class *sched_class; struct sched_entity se; struct sched_rt_entity rt; + +#ifdef CONFIG_SCHED_WALT + struct ravg ravg; +#endif + #ifdef CONFIG_CGROUP_SCHED struct task_group *sched_task_group; #endif diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ce8b244..39c826d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2674,8 +2674,6 @@ static u32 __compute_runnable_contrib(u64 n) return contrib + runnable_avg_yN_sum[n]; } -#define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) - /* * We can represent the historical contribution to runnable average as the * coefficients of a geometric series. To do this we sub-divide our runnable diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index c64fc51..9bf6925 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -65,6 +65,8 @@ static inline void cpu_load_update_active(struct rq *this_rq) { } # define scale_load_down(w) (w) #endif +#define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) + /* * Task weight (visible to users) and its load (invisible to users) have * independent resolution, but they should be well calibrated. We use @@ -664,6 +666,12 @@ struct rq { u64 max_idle_balance_cost; #endif +#ifdef CONFIG_SCHED_WALT + u64 window_start; + u64 curr_runnable_sum; + u64 prev_runnable_sum; +#endif /* CONFIG_SCHED_WALT */ + #ifdef CONFIG_IRQ_TIME_ACCOUNTING u64 prev_irq_time; #endif -- TheMan