Skip to contentSkip to conversation

few functions clean up

PATCH New Alex Shi 1 participant 4 messages Sep 14, 2012

Subsystems (2)
lore
Share & tools
lore

Alex Shi

author
#0 lore raw

PATCH v2 1/1 few functions clean up

Changed according to Peter and Suresh suggestion.

Thanks
[PATCH v2 1/3] nohz: clean up select_nohz_load_balancer() [PATCH v2 2/3] sched:nohz rename clear_nohz_tick_stopped as [PATCH v2 3/3] sched/balance: remove on_null_domain() in

author
#1 lore raw

PATCH v2 1/3 nohz: clean up select_nohz_load_balancer()

There is no load_balancer to be selected now. It just set state of nohz tick stopping.

So rename the function as nohz_balance_enter_idle according to Peter's suggestion, pass the 'cpu' from parameter and then
remove the useless calling from tick_nohz_restart_sched_tick().

---
 include/linux/sched.h    |  4 ++--
 kernel/sched/fair.c      | 19 +++++++------------
 kernel/time/tick-sched.c |  3 +--
 3 files changed, 10 insertions(+), 16 deletions(-)
include/linux/sched.h +2 -2
index b8c8664..e723a4b 100644
@@ -273,11 +273,11 @@ extern void init_idle_bootup_task(struct task_struct *idle);
 extern int runqueue_is_locked(int cpu);
 
 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
-extern void select_nohz_load_balancer(int stop_tick);
+extern void nohz_balance_enter_idle(int cpu);
 extern void set_cpu_sd_state_idle(void);
 extern int get_nohz_timer_target(void);
 #else
-static inline void select_nohz_load_balancer(int stop_tick) { }
+static inline void nohz_balance_enter_idle(int cpu) { }
 static inline void set_cpu_sd_state_idle(void) { }
 #endif
 
kernel/sched/fair.c +7 -12
index c219bf8..b681941 100644
@@ -4674,28 +4674,23 @@ void set_cpu_sd_state_idle(void)
 }
 
 /*
- * This routine will record that this cpu is going idle with tick stopped.
+ * This routine will record that the cpu is going idle with tick stopped.
  * This info will be used in performing idle load balancing in the future.
  */
-void select_nohz_load_balancer(int stop_tick)
+void nohz_balance_enter_idle(int cpu)
 {
-	int cpu = smp_processor_id();
-
 	/*
 	 * If this cpu is going down, then nothing needs to be done.
 	 */
 	if (!cpu_active(cpu))
 		return;
 
-	if (stop_tick) {
-		if (test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))
-			return;
+	if (test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))
+		return;
 
-		cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
-		atomic_inc(&nohz.nr_cpus);
-		set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
-	}
-	return;
+	cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
+	atomic_inc(&nohz.nr_cpus);
+	set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
 }
 
 static int __cpuinit sched_ilb_notifier(struct notifier_block *nfb,
kernel/time/tick-sched.c +1 -2
index 024540f..0e6a945 100644
@@ -372,7 +372,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
 		 * the scheduler tick in nohz_restart_sched_tick.
 		 */
 		if (!ts->tick_stopped) {
-			select_nohz_load_balancer(1);
+			nohz_balance_enter_idle(cpu);
 			calc_load_enter_idle();
 
 			ts->last_tick = hrtimer_get_expires(&ts->sched_timer);
@@ -569,7 +569,6 @@ static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)
 static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now)
 {
 	/* Update jiffies first */
-	select_nohz_load_balancer(0);
 	tick_do_update_jiffies64(now);
 	update_cpu_load_nohz();
 
Signature · 1 line
1.7.12
author
#2 lore raw

PATCH v2 2/3 sched:nohz rename clear_nohz_tick_stopped as nohz_balance_exit_idle

In reply to Alex Shi

This patch just rename the function clear_nohz_tick_stopped() to nohz_balance_exit_idle(), that align with nohz_balance_enter_idle.

no function changes.

---
 kernel/sched/fair.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/fair.c +3 -3
index b681941..60d5505 100644
@@ -4634,7 +4634,7 @@ static void nohz_balancer_kick(int cpu)
 	return;
 }
 
-static inline void clear_nohz_tick_stopped(int cpu)
+static inline void nohz_balance_exit_idle(int cpu)
 {
 	if (unlikely(test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))) {
 		cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
@@ -4698,7 +4698,7 @@ static int __cpuinit sched_ilb_notifier(struct notifier_block *nfb,
 {
 	switch (action & ~CPU_TASKS_FROZEN) {
 	case CPU_DYING:
-		clear_nohz_tick_stopped(smp_processor_id());
+		nohz_balance_exit_idle(smp_processor_id());
 		return NOTIFY_OK;
 	default:
 		return NOTIFY_DONE;
@@ -4858,7 +4858,7 @@ static inline int nohz_kick_needed(struct rq *rq, int cpu)
 	* busy tick after returning from idle, we will update the busy stats.
 	*/
 	set_cpu_sd_state_busy();
-	clear_nohz_tick_stopped(cpu);
+	nohz_balance_exit_idle(cpu);
 
 	/*
 	 * None are in tickless mode and hence no need for NOHZ idle load
Signature · 1 line
1.7.12
author
#3 lore raw

PATCH v2 3/3 sched/balance: remove on_null_domain() in trigger_load_balance

In reply to Alex Shi

According to Suresh's inverstigation, the first on_null_domain in trigger_load_balance is for avoiding unnecessary loadbalances(from softirq) when a SMP kernel running on UP machine.
The second on_null_domain is not needed, since nohz_kick_needed() will return 0 in this scenario.

So, remove the 2nd on_null_domain calling.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index 60d5505..1ae2c66 100644
@@ -4938,7 +4938,7 @@ void trigger_load_balance(struct rq *rq, int cpu)
 	    likely(!on_null_domain(cpu)))
 		raise_softirq(SCHED_SOFTIRQ);
 #ifdef CONFIG_NO_HZ
-	if (nohz_kick_needed(rq, cpu) && likely(!on_null_domain(cpu)))
+	if (nohz_kick_needed(rq, cpu))
 		nohz_balancer_kick(cpu);
 #endif
 }
Signature · 1 line
1.7.12