diff mbox

[RFC,1/3] sched/fair: Aggregate task utilization only on root cfs_rq

Message ID 5750567F.6060601@arm.com
State New
Headers show

Commit Message

Dietmar Eggemann June 2, 2016, 3:53 p.m. UTC
On 02/06/16 10:23, Juri Lelli wrote:

>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c

>> index 218f8e83db73..212becd3708f 100644

>> --- a/kernel/sched/fair.c

>> +++ b/kernel/sched/fair.c

>> @@ -2705,6 +2705,7 @@ __update_load_avg(u64 now, int cpu, struct sched_avg *sa,

>>  	u32 contrib;

>>  	unsigned int delta_w, scaled_delta_w, decayed = 0;

>>  	unsigned long scale_freq, scale_cpu;

>> +	int update_util = 0;

>>  

>>  	delta = now - sa->last_update_time;

>>  	/*

>> @@ -2725,6 +2726,12 @@ __update_load_avg(u64 now, int cpu, struct sched_avg *sa,

>>  		return 0;

>>  	sa->last_update_time = now;

>>  

>> +	if (cfs_rq) {

>> +		if (&rq_of(cfs_rq)->cfs == cfs_rq)

> 

> Maybe we can wrap this sort of checks in a static inline improving

> readability?


Something like this?

Comments

Juri Lelli June 2, 2016, 4:11 p.m. UTC | #1
On 02/06/16 16:53, Dietmar Eggemann wrote:
> On 02/06/16 10:23, Juri Lelli wrote:

> 

> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c

> >> index 218f8e83db73..212becd3708f 100644

> >> --- a/kernel/sched/fair.c

> >> +++ b/kernel/sched/fair.c

> >> @@ -2705,6 +2705,7 @@ __update_load_avg(u64 now, int cpu, struct sched_avg *sa,

> >>  	u32 contrib;

> >>  	unsigned int delta_w, scaled_delta_w, decayed = 0;

> >>  	unsigned long scale_freq, scale_cpu;

> >> +	int update_util = 0;

> >>  

> >>  	delta = now - sa->last_update_time;

> >>  	/*

> >> @@ -2725,6 +2726,12 @@ __update_load_avg(u64 now, int cpu, struct sched_avg *sa,

> >>  		return 0;

> >>  	sa->last_update_time = now;

> >>  

> >> +	if (cfs_rq) {

> >> +		if (&rq_of(cfs_rq)->cfs == cfs_rq)

> > 

> > Maybe we can wrap this sort of checks in a static inline improving

> > readability?

> 

> Something like this?

> 

> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c

> index 218f8e83db73..01b0fa689ef9 100644

> --- a/kernel/sched/fair.c

> +++ b/kernel/sched/fair.c

> @@ -251,6 +251,18 @@ static inline struct rq *rq_of(struct cfs_rq *cfs_rq)

>         return cfs_rq->rq;

>  }

>  

> +/* cfs_rq "owned" by the root task group */

> +static inline struct cfs_rq *root_rq_of(struct cfs_rq *cfs_rq)

> +{

> +       return &rq_of(cfs_rq)->cfs;

> +}

> +

> +/* Is this cfs_rq "owned" by the root task group ? */

> +static inline bool rq_is_root(struct cfs_rq *cfs_rq)

> +{

> +       return root_rq_of(cfs_rq) == cfs_rq;

> +}

> +

>  /* An entity is a task if it doesn't "own" a runqueue */

>  #define entity_is_task(se)     (!se->my_q)

>  

> @@ -376,6 +388,16 @@ static inline struct rq *rq_of(struct cfs_rq *cfs_rq)

>         return container_of(cfs_rq, struct rq, cfs);

>  }

>  

> +static inline struct cfs_rq *root_rq_of(struct cfs_rq *cfs_rq)

> +{

> +       return cfs_rq;

> +}

> +

> +static inline bool rq_is_root(struct cfs_rq *cfs_rq)

> +{

> +       return true;

> +}

> +

>  #define entity_is_task(se)     1

> 


Looks good to me.

Thanks,

- Juri
diff mbox

Patch

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 218f8e83db73..01b0fa689ef9 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -251,6 +251,18 @@  static inline struct rq *rq_of(struct cfs_rq *cfs_rq)
        return cfs_rq->rq;
 }
 
+/* cfs_rq "owned" by the root task group */
+static inline struct cfs_rq *root_rq_of(struct cfs_rq *cfs_rq)
+{
+       return &rq_of(cfs_rq)->cfs;
+}
+
+/* Is this cfs_rq "owned" by the root task group ? */
+static inline bool rq_is_root(struct cfs_rq *cfs_rq)
+{
+       return root_rq_of(cfs_rq) == cfs_rq;
+}
+
 /* An entity is a task if it doesn't "own" a runqueue */
 #define entity_is_task(se)     (!se->my_q)
 
@@ -376,6 +388,16 @@  static inline struct rq *rq_of(struct cfs_rq *cfs_rq)
        return container_of(cfs_rq, struct rq, cfs);
 }
 
+static inline struct cfs_rq *root_rq_of(struct cfs_rq *cfs_rq)
+{
+       return cfs_rq;
+}
+
+static inline bool rq_is_root(struct cfs_rq *cfs_rq)
+{
+       return true;
+}
+
 #define entity_is_task(se)     1