Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1384805 > unrolled thread

[PATCH v3] sched/cpufreq: optimize cpufreq update kicker to avoid update multiple times

Started byWanpeng Li <kernellwp@gmail.com>
First post2016-04-22 11:10 +0200
Last post2016-04-28 12:30 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v3] sched/cpufreq: optimize cpufreq update kicker to avoid update multiple times Wanpeng Li <kernellwp@gmail.com> - 2016-04-22 11:10 +0200
    Re: [PATCH v3] sched/cpufreq: optimize cpufreq update kicker to avoid  update multiple times "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> - 2016-04-22 14:10 +0200
      Re: [PATCH v3] sched/cpufreq: optimize cpufreq update kicker to  avoid update multiple times Peter Zijlstra <peterz@infradead.org> - 2016-04-25 16:40 +0200
    [tip:sched/core] sched/cpufreq: Optimize cpufreq update kicker to  avoid update multiple times tip-bot for Wanpeng Li <tipbot@zytor.com> - 2016-04-28 12:30 +0200

#1384805 — [PATCH v3] sched/cpufreq: optimize cpufreq update kicker to avoid update multiple times

FromWanpeng Li <kernellwp@gmail.com>
Date2016-04-22 11:10 +0200
Subject[PATCH v3] sched/cpufreq: optimize cpufreq update kicker to avoid update multiple times
Message-ID<rqFg5-7ZV-9@gated-at.bofh.it>
From: Wanpeng Li <wanpeng.li@hotmail.com>

Sometimes delta_exec is 0 due to update_curr() is called multiple times,
this is captured by:

	u64 delta_exec = rq_clock_task(rq) - curr->se.exec_start;

This patch optimizes the cpufreq update kicker by bailing out when nothing 
changed, it will benefit the upcoming schedutil, since otherwise it will 
(over)react to the special util/max combination.

Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
v1 -> v2:
 * add From: head
v2 -> v3:
 * update changelog

 kernel/sched/deadline.c | 8 ++++----
 kernel/sched/rt.c       | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index affd97e..8f9b5af 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -717,10 +717,6 @@ static void update_curr_dl(struct rq *rq)
 	if (!dl_task(curr) || !on_dl_rq(dl_se))
 		return;
 
-	/* Kick cpufreq (see the comment in linux/cpufreq.h). */
-	if (cpu_of(rq) == smp_processor_id())
-		cpufreq_trigger_update(rq_clock(rq));
-
 	/*
 	 * Consumed budget is computed considering the time as
 	 * observed by schedulable tasks (excluding time spent
@@ -736,6 +732,10 @@ static void update_curr_dl(struct rq *rq)
 		return;
 	}
 
+	/* kick cpufreq (see the comment in linux/cpufreq.h). */
+	if (cpu_of(rq) == smp_processor_id())
+		cpufreq_trigger_update(rq_clock(rq));
+
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
 
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index c41ea7a..19e1306 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -953,14 +953,14 @@ static void update_curr_rt(struct rq *rq)
 	if (curr->sched_class != &rt_sched_class)
 		return;
 
-	/* Kick cpufreq (see the comment in linux/cpufreq.h). */
-	if (cpu_of(rq) == smp_processor_id())
-		cpufreq_trigger_update(rq_clock(rq));
-
 	delta_exec = rq_clock_task(rq) - curr->se.exec_start;
 	if (unlikely((s64)delta_exec <= 0))
 		return;
 
+	/* Kick cpufreq (see the comment in linux/cpufreq.h). */
+	if (cpu_of(rq) == smp_processor_id())
+		cpufreq_trigger_update(rq_clock(rq));
+
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1385109 — Re: [PATCH v3] sched/cpufreq: optimize cpufreq update kicker to avoid update multiple times

From"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Date2016-04-22 14:10 +0200
SubjectRe: [PATCH v3] sched/cpufreq: optimize cpufreq update kicker to avoid update multiple times
Message-ID<rqI4i-1GC-15@gated-at.bofh.it>
In reply to#1384805
[Added linux-pm to the CC - can you please do so for PM-related patches 
in the future?]

On 4/22/2016 11:07 AM, Wanpeng Li wrote:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> Sometimes delta_exec is 0 due to update_curr() is called multiple times,
> this is captured by:
>
> 	u64 delta_exec = rq_clock_task(rq) - curr->se.exec_start;
>
> This patch optimizes the cpufreq update kicker by bailing out when nothing
> changed, it will benefit the upcoming schedutil, since otherwise it will
> (over)react to the special util/max combination.
>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>

The changelog looks better now, thanks!

Peter, do I think correctly that you're going to take care of this one?  
Or do you want me to take it?

> ---
> v1 -> v2:
>   * add From: head
> v2 -> v3:
>   * update changelog
>
>   kernel/sched/deadline.c | 8 ++++----
>   kernel/sched/rt.c       | 8 ++++----
>   2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index affd97e..8f9b5af 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -717,10 +717,6 @@ static void update_curr_dl(struct rq *rq)
>   	if (!dl_task(curr) || !on_dl_rq(dl_se))
>   		return;
>   
> -	/* Kick cpufreq (see the comment in linux/cpufreq.h). */
> -	if (cpu_of(rq) == smp_processor_id())
> -		cpufreq_trigger_update(rq_clock(rq));
> -
>   	/*
>   	 * Consumed budget is computed considering the time as
>   	 * observed by schedulable tasks (excluding time spent
> @@ -736,6 +732,10 @@ static void update_curr_dl(struct rq *rq)
>   		return;
>   	}
>   
> +	/* kick cpufreq (see the comment in linux/cpufreq.h). */
> +	if (cpu_of(rq) == smp_processor_id())
> +		cpufreq_trigger_update(rq_clock(rq));
> +
>   	schedstat_set(curr->se.statistics.exec_max,
>   		      max(curr->se.statistics.exec_max, delta_exec));
>   
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index c41ea7a..19e1306 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -953,14 +953,14 @@ static void update_curr_rt(struct rq *rq)
>   	if (curr->sched_class != &rt_sched_class)
>   		return;
>   
> -	/* Kick cpufreq (see the comment in linux/cpufreq.h). */
> -	if (cpu_of(rq) == smp_processor_id())
> -		cpufreq_trigger_update(rq_clock(rq));
> -
>   	delta_exec = rq_clock_task(rq) - curr->se.exec_start;
>   	if (unlikely((s64)delta_exec <= 0))
>   		return;
>   
> +	/* Kick cpufreq (see the comment in linux/cpufreq.h). */
> +	if (cpu_of(rq) == smp_processor_id())
> +		cpufreq_trigger_update(rq_clock(rq));
> +
>   	schedstat_set(curr->se.statistics.exec_max,
>   		      max(curr->se.statistics.exec_max, delta_exec));
>   

[toc] | [prev] | [next] | [standalone]


#1386534 — Re: [PATCH v3] sched/cpufreq: optimize cpufreq update kicker to avoid update multiple times

FromPeter Zijlstra <peterz@infradead.org>
Date2016-04-25 16:40 +0200
SubjectRe: [PATCH v3] sched/cpufreq: optimize cpufreq update kicker to avoid update multiple times
Message-ID<rrPQ7-7se-41@gated-at.bofh.it>
In reply to#1385109
On Fri, Apr 22, 2016 at 02:04:56PM +0200, Rafael J. Wysocki wrote:
> [Added linux-pm to the CC - can you please do so for PM-related patches in
> the future?]
> 
> On 4/22/2016 11:07 AM, Wanpeng Li wrote:
> >From: Wanpeng Li <wanpeng.li@hotmail.com>
> >
> >Sometimes delta_exec is 0 due to update_curr() is called multiple times,
> >this is captured by:
> >
> >	u64 delta_exec = rq_clock_task(rq) - curr->se.exec_start;
> >
> >This patch optimizes the cpufreq update kicker by bailing out when nothing
> >changed, it will benefit the upcoming schedutil, since otherwise it will
> >(over)react to the special util/max combination.
> >
> >Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> 
> The changelog looks better now, thanks!
> 
> Peter, do I think correctly that you're going to take care of this one?  Or
> do you want me to take it?

YEah, looks fine. I'll take it.

Thanks!

[toc] | [prev] | [next] | [standalone]


#1389977 — [tip:sched/core] sched/cpufreq: Optimize cpufreq update kicker to avoid update multiple times

Fromtip-bot for Wanpeng Li <tipbot@zytor.com>
Date2016-04-28 12:30 +0200
Subject[tip:sched/core] sched/cpufreq: Optimize cpufreq update kicker to avoid update multiple times
Message-ID<rsRmO-1va-27@gated-at.bofh.it>
In reply to#1384805
Commit-ID:  594dd290cf5403a9a5818619dfff42d8e8e0518e
Gitweb:     http://git.kernel.org/tip/594dd290cf5403a9a5818619dfff42d8e8e0518e
Author:     Wanpeng Li <wanpeng.li@hotmail.com>
AuthorDate: Fri, 22 Apr 2016 17:07:24 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 28 Apr 2016 10:39:54 +0200

sched/cpufreq: Optimize cpufreq update kicker to avoid update multiple times

Sometimes delta_exec is 0 due to update_curr() is called multiple times,
this is captured by:

	u64 delta_exec = rq_clock_task(rq) - curr->se.exec_start;

This patch optimizes the cpufreq update kicker by bailing out when nothing
changed, it will benefit the upcoming schedutil, since otherwise it will
(over)react to the special util/max combination.

Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1461316044-9520-1-git-send-email-wanpeng.li@hotmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/deadline.c | 8 ++++----
 kernel/sched/rt.c       | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index affd97e..8f9b5af 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -717,10 +717,6 @@ static void update_curr_dl(struct rq *rq)
 	if (!dl_task(curr) || !on_dl_rq(dl_se))
 		return;
 
-	/* Kick cpufreq (see the comment in linux/cpufreq.h). */
-	if (cpu_of(rq) == smp_processor_id())
-		cpufreq_trigger_update(rq_clock(rq));
-
 	/*
 	 * Consumed budget is computed considering the time as
 	 * observed by schedulable tasks (excluding time spent
@@ -736,6 +732,10 @@ static void update_curr_dl(struct rq *rq)
 		return;
 	}
 
+	/* kick cpufreq (see the comment in linux/cpufreq.h). */
+	if (cpu_of(rq) == smp_processor_id())
+		cpufreq_trigger_update(rq_clock(rq));
+
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
 
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index c41ea7a..19e1306 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -953,14 +953,14 @@ static void update_curr_rt(struct rq *rq)
 	if (curr->sched_class != &rt_sched_class)
 		return;
 
-	/* Kick cpufreq (see the comment in linux/cpufreq.h). */
-	if (cpu_of(rq) == smp_processor_id())
-		cpufreq_trigger_update(rq_clock(rq));
-
 	delta_exec = rq_clock_task(rq) - curr->se.exec_start;
 	if (unlikely((s64)delta_exec <= 0))
 		return;
 
+	/* Kick cpufreq (see the comment in linux/cpufreq.h). */
+	if (cpu_of(rq) == smp_processor_id())
+		cpufreq_trigger_update(rq_clock(rq));
+
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web