Skip to contentSkip to conversation

nohz_full clean up and bug fix

PATCH In review Alex Shi 4 participants 13 messages Dec 3, 2013 – Jan 25, 2014

Subsystems (2)
lore
Share & tools
lore

Alex Shi

author
#0 lore raw

v2 cover nohz_full clean up and bug fix

The first used a wrong signed-off email addr, Sorry!

--
Thanks
Alex

author
#1 lore raw

PATCH v2 1/3 nohz_full: fix code sytle issue of tick_nohz_full_stop_tick

Code usually starts with 'tab' instead of 7 'space'es in kernel

---
 kernel/time/tick-sched.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
kernel/time/tick-sched.c +8 -8
index 3612fc7..b55d1c0 100644
@@ -681,18 +681,18 @@ out:
 static void tick_nohz_full_stop_tick(struct tick_sched *ts)
 {
 #ifdef CONFIG_NO_HZ_FULL
-       int cpu = smp_processor_id();
+	int cpu = smp_processor_id();
 
-       if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
-               return;
+	if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
+		return;
 
-       if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
-	       return;
+	if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
+		return;
 
-       if (!can_stop_full_tick())
-               return;
+	if (!can_stop_full_tick())
+		return;
 
-       tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
+	tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
 #endif
 }
 
Signature · 1 line
1.8.1.2
#2 lore raw

Re: [PATCH v2 1/3] nohz_full: fix code sytle issue of tick_nohz_full_stop_tick

In subject: s/sytle/style/

Quoted 42 lines · Alex Shi

Code usually starts with 'tab' instead of 7 'space'es in kernel

---
 kernel/time/tick-sched.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
kernel/time/tick-sched.c +8 -8
index 3612fc7..b55d1c0 100644
@@ -681,18 +681,18 @@ out:
 static void tick_nohz_full_stop_tick(struct tick_sched *ts)
 {
 #ifdef CONFIG_NO_HZ_FULL
-       int cpu = smp_processor_id();
+	int cpu = smp_processor_id();
 
-       if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
-               return;
+	if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
+		return;
 
-       if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
-	       return;
+	if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
+		return;
 
-       if (!can_stop_full_tick())
-               return;
+	if (!can_stop_full_tick())
+		return;
 
-       tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
+	tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
 #endif
 }
 
Signature · 1 line
1.8.1.2
author
#3 lore raw

Re: [PATCH v2 1/3] nohz_full: fix code sytle issue of tick_nohz_full_stop_tick

Quoted 2 lines · Morten Rasmussen

In subject: s/sytle/style/

Thanks for this catch. updated.

===

Quoted 1 line

From 8d430d26c06c31d536c5ad38b8711d738fc25eff Mon Sep 17 00:00:00 2001

From: Alex Shi <[email protected]>
Date: Thu, 28 Nov 2013 14:27:11 +0800
Subject: [PATCH v2 1/3] nohz_full: fix code style issue of
tick_nohz_full_stop_tick

Code usually starts with 'tab' instead of 7 'space' in kernel

---
 kernel/time/tick-sched.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
kernel/time/tick-sched.c +8 -8
index 3612fc7..b55d1c0 100644
@@ -681,18 +681,18 @@ out:
 static void tick_nohz_full_stop_tick(struct tick_sched *ts)
 {
 #ifdef CONFIG_NO_HZ_FULL
-       int cpu = smp_processor_id();
+	int cpu = smp_processor_id();
 
-       if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
-               return;
+	if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
+		return;
 
-       if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
-	       return;
+	if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
+		return;
 
-       if (!can_stop_full_tick())
-               return;
+	if (!can_stop_full_tick())
+		return;
 
-       tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
+	tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
 #endif
 }
 
Signature · 6 lines
1.8.1.2


-- 
Thanks
    Alex
author
#4 lore raw

Re: [PATCH v2 1/3] nohz_full: fix code sytle issue of tick_nohz_full_stop_tick

In reply to Morten Rasmussen
Quoted 5 lines · Morten Rasmussen

In subject: s/sytle/style/

Quoted 2 lines · Alex Shi
Quoted 2 lines

Code usually starts with 'tab' instead of 7 'space'es in kernel

Found another function has the code style issue too.

Quoted 1 line

From f594f0b721e57f90b51d0dd1692e5aae67d83b81 Mon Sep 17 00:00:00 2001

From: Alex Shi <[email protected]>
Date: Thu, 28 Nov 2013 14:27:11 +0800
Subject: [PATCH 1/4] nohz_full: fix code style issue

Code usually starts with 'tab' instead of 7 'space'es in kernel.

---
 kernel/sched/core.c      | 16 ++++++++--------
 kernel/time/tick-sched.c | 16 ++++++++--------
 2 files changed, 16 insertions(+), 16 deletions(-)
kernel/sched/core.c +8 -8
index c180860..636d89e 100644
@@ -664,18 +664,18 @@ static inline bool got_nohz_idle_kick(void)
 #ifdef CONFIG_NO_HZ_FULL
 bool sched_can_stop_tick(void)
 {
-       struct rq *rq;
+	struct rq *rq;
 
-       rq = this_rq();
+	rq = this_rq();
 
-       /* Make sure rq->nr_running update is visible after the IPI */
-       smp_rmb();
+	/* Make sure rq->nr_running update is visible after the IPI */
+	smp_rmb();
 
-       /* More than one running task need preemption */
-       if (rq->nr_running > 1)
-               return false;
+	/* More than one running task need preemption */
+	if (rq->nr_running > 1)
+		return false;
 
-       return true;
+	return true;
 }
 #endif /* CONFIG_NO_HZ_FULL */
 
kernel/time/tick-sched.c +8 -8
index 3612fc7..b55d1c0 100644
@@ -681,18 +681,18 @@ out:
 static void tick_nohz_full_stop_tick(struct tick_sched *ts)
 {
 #ifdef CONFIG_NO_HZ_FULL
-       int cpu = smp_processor_id();
+	int cpu = smp_processor_id();
 
-       if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
-               return;
+	if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
+		return;
 
-       if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
-	       return;
+	if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
+		return;
 
-       if (!can_stop_full_tick())
-               return;
+	if (!can_stop_full_tick())
+		return;
 
-       tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
+	tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
 #endif
 }
 
Signature · 6 lines
1.8.1.2


-- 
Thanks
    Alex
#5 lore raw

[tip:timers/urgent] nohz_full: fix code style issue of tick_nohz_full_stop_tick

In reply to Alex Shi
nohz_full: fix code style issue of tick_nohz_full_stop_tick
Commit-ID:  e9a2eb403bd953788cd2abfd0d2646d43bd22671
Gitweb:     http://git.kernel.org/tip/e9a2eb403bd953788cd2abfd0d2646d43bd22671
Author:     Alex Shi <[email protected]>
AuthorDate: Thu, 28 Nov 2013 14:27:11 +0800
Committer:  Frederic Weisbecker <[email protected]>
CommitDate: Wed, 15 Jan 2014 23:07:11 +0100

nohz_full: fix code style issue of tick_nohz_full_stop_tick

Code usually starts with 'tab' instead of 7 'space' in kernel

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Alex Shi <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc John Stultz <[email protected]>
Cc Kevin Hilman <[email protected]>
---
 kernel/time/tick-sched.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
kernel/time/tick-sched.c +8 -8
index 68331d1..d603bad 100644
@@ -679,18 +679,18 @@ out:
 static void tick_nohz_full_stop_tick(struct tick_sched *ts)
 {
 #ifdef CONFIG_NO_HZ_FULL
-       int cpu = smp_processor_id();
+	int cpu = smp_processor_id();
 
-       if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
-               return;
+	if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
+		return;
 
-       if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
-	       return;
+	if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
+		return;
 
-       if (!can_stop_full_tick())
-               return;
+	if (!can_stop_full_tick())
+		return;
 
-       tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
+	tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
 #endif
 }
 
author
#6 lore raw

PATCH v2 2/3 nohz_full: unify nohz_full funcs

In reply to Alex Shi

All other nohz_full funcs named like xxx_nohz_full_xxx. So renaming wake_up_full_nohz_cpu to wake_up_nohz_full_cpu to unify funs.

---
 kernel/sched/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/core.c +2 -2
index c180860..6c9f9b0 100644
@@ -616,7 +616,7 @@ static void wake_up_idle_cpu(int cpu)
 		smp_send_reschedule(cpu);
 }
 
-static bool wake_up_full_nohz_cpu(int cpu)
+static bool wake_up_nohz_full_cpu(int cpu)
 {
 	if (tick_nohz_full_cpu(cpu)) {
 		if (cpu != smp_processor_id() ||
@@ -630,7 +630,7 @@ static bool wake_up_full_nohz_cpu(int cpu)
 
 void wake_up_nohz_cpu(int cpu)
 {
-	if (!wake_up_full_nohz_cpu(cpu))
+	if (!wake_up_nohz_full_cpu(cpu))
 		wake_up_idle_cpu(cpu);
 }
 
Signature · 1 line
1.8.1.2
author
#7 lore raw

PATCH v2 3/3 nohz_full: update cpu load fix in nohz_full

In reply to Alex Shi

We are not always 0 when update nohz cpu load, after nohz_full enabled. But current code still treat the cpu as idle. that is incorrect. Fix it to use correct cpu_load.

---
 kernel/sched/proc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/sched/proc.c +7 -1
index 16f5a30..f1441f0 100644
@@ -568,8 +568,14 @@ void update_cpu_load_nohz(void)
 		/*
 		 * We were idle, this means load 0, the current load might be
 		 * !0 due to remote wakeups and the sort.
+		 * or we may has only one task and in NO_HZ_FULL, then still use
+		 * normal cpu load.
 		 */
-		__update_cpu_load(this_rq, 0, pending_updates);
+		if (this_rq->cfs.h_nr_running) {
+			unsigned load = get_rq_runnable_load(this_rq);
+			__update_cpu_load(this_rq, load, pending_updates);
+		} else
+			__update_cpu_load(this_rq, 0, pending_updates);
 	}
 	raw_spin_unlock(&this_rq->lock);
 }
Signature · 1 line
1.8.1.2
author
#8 lore raw

Re: [PATCH v2 3/3] nohz_full: update cpu load fix in nohz_full

Quoted 3 lines · Alex Shi

We are not always 0 when update nohz cpu load, after nohz_full enabled. But current code still treat the cpu as idle. that is incorrect. Fix it to use correct cpu_load.

Frederic, Could you like to give some comments?

Quoted 27 lines
---
 kernel/sched/proc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/sched/proc.c +7 -1
index 16f5a30..f1441f0 100644
@@ -568,8 +568,14 @@ void update_cpu_load_nohz(void)
 		/*
 		 * We were idle, this means load 0, the current load might be
 		 * !0 due to remote wakeups and the sort.
+		 * or we may has only one task and in NO_HZ_FULL, then still use
+		 * normal cpu load.
 		 */
-		__update_cpu_load(this_rq, 0, pending_updates);
+		if (this_rq->cfs.h_nr_running) {
+			unsigned load = get_rq_runnable_load(this_rq);
+			__update_cpu_load(this_rq, load, pending_updates);
+		} else
+			__update_cpu_load(this_rq, 0, pending_updates);
 	}
 	raw_spin_unlock(&this_rq->lock);
 }
Signature · 2 lines
Thanks
    Alex
author
#9 lore raw

Re: [PATCH v2 3/3] nohz_full: update cpu load fix in nohz_full

Quoted 6 lines · Alex Shi
Quoted 3 lines · Alex Shi
Quoted 3 lines

We are not always 0 when update nohz cpu load, after nohz_full enabled. But current code still treat the cpu as idle. that is incorrect. Fix it to use correct cpu_load.

Frederic, Could you like to give some comments?

ping Frederic.

Signature · 2 lines
Thanks
    Alex
#10 lore raw

Re: [PATCH v2 3/3] nohz_full: update cpu load fix in nohz_full

In reply to Alex Shi
Quoted 16 lines · Alex Shi

We are not always 0 when update nohz cpu load, after nohz_full enabled. But current code still treat the cpu as idle. that is incorrect. Fix it to use correct cpu_load.

---
 kernel/sched/proc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/sched/proc.c +0 -0
index 16f5a30..f1441f0 100644
@@ -568,8 +568,14 @@ void update_cpu_load_nohz(void)
 		/*
 		 * We were idle, this means load 0, the current load might be

kernel/sched/proc.c void update_cpu_load_nohz(void) · line 578

Quoted 10 lines
kernel/sched/proc.c +7 -1
 		 * !0 due to remote wakeups and the sort.
+		 * or we may has only one task and in NO_HZ_FULL, then still use
+		 * normal cpu load.
 		 */
-		__update_cpu_load(this_rq, 0, pending_updates);
+		if (this_rq->cfs.h_nr_running) {
+			unsigned load = get_rq_runnable_load(this_rq);
+			__update_cpu_load(this_rq, load, pending_updates);
+		} else
+			__update_cpu_load(this_rq, 0, pending_updates);

But decay_load_missed() doesnt handle non 0 loads, right? It probably make more sense to first fix __update_cpu_load() to make it handle this kind of thing before fixing the caller.

Now you had patches that remove the cpu_load secondary idx I think? You should move this patch to that series.

Quoted 6 lines
kernel/sched/proc.c +0 -0
 	}
 	raw_spin_unlock(&this_rq->lock);
 }
Signature · 1 line
1.8.1.2
author
#11 lore raw

Re: [PATCH v2 3/3] nohz_full: update cpu load fix in nohz_full

Quoted 14 lines · Frederic Weisbecker
Quoted 11 lines

kernel/sched/proc.c void update_cpu_load_nohz(void) · line 578

Quoted 11 lines
kernel/sched/proc.c +7 -1
 		 * We were idle, this means load 0, the current load might be
 		 * !0 due to remote wakeups and the sort.
+		 * or we may has only one task and in NO_HZ_FULL, then still use
+		 * normal cpu load.
 		 */
-		__update_cpu_load(this_rq, 0, pending_updates);
+		if (this_rq->cfs.h_nr_running) {
+			unsigned load = get_rq_runnable_load(this_rq);
+			__update_cpu_load(this_rq, load, pending_updates);
+		} else
+			__update_cpu_load(this_rq, 0, pending_updates);

But decay_load_missed() doesnt handle non 0 loads, right? It probably make more sense to first fix __update_cpu_load() to make it handle this kind of thing before fixing the caller.

Quoted 1 line

Now you had patches that remove the cpu_load secondary idx I think? You should move this patc

Thanks for response!
Yes, after get your review, I plan to merge this patch with cpu_load decay removing, if that patchset possible get to upstream. :)

Signature · 2 lines
Thanks
    Alex
author
#12 lore raw
In reply to Alex Shi
Quoted 1 line · Alex Shi

The first used a wrong signed-off email addr, Sorry!

The first version -- v1 used a wrong email address. Sorry!

Quoted 5 lines

--
Thanks
Alex

Signature · 2 lines
Thanks
    Alex