Skip to contentSkip to conversation

nohz: Affining unpinned timers

PATCH RESEND Preeti U Murthy 4 participants 7 messages Jun 24, 2015 – Aug 3, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20150623083133.GA587@vatika-Inspiron-3443

Preeti U Murthy

author Reviewed-by
#1 lore raw
Quoted 10 lines · Vatika Harlalka

The problem addressed in this patch is about affining unpinned timers. Adaptive or Full Dynticks CPUs should not be disturbed by unnecessary jitter due to firing of such timers on them.
This patch will affine timers to online CPUs which are not Full Dynticks in FULL_NOHZ configured systems. It will not bring about functional changes if NOHZ_FULL is not configured, because is_housekeeping_cpu() always returns true in CONFIG_NO_HZ_FULL=n.

Signed-off by: Vatika Harlalka <[email protected]>
---

Quoted 63 lines

Changes: Patch sent to the right recipients.

 include/linux/tick.h | 9 ++++++++-
 kernel/sched/core.c  | 9 +++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
include/linux/tick.h +8 -1
index f8492da5..145bcba 100644
@@ -133,13 +133,20 @@ static inline bool tick_nohz_full_cpu(int cpu)
 
 	return cpumask_test_cpu(cpu, tick_nohz_full_mask);
 }
-
+static inline int housekeeping_any_cpu(void)
+{
+	return cpumask_any_and(housekeeping_mask, cpu_online_mask);
+}
 extern void __tick_nohz_full_check(void);
 extern void tick_nohz_full_kick(void);
 extern void tick_nohz_full_kick_cpu(int cpu);
 extern void tick_nohz_full_kick_all(void);
 extern void __tick_nohz_task_switch(struct task_struct *tsk);
 #else
+static inline int housekeeping_any_cpu(void)
+{
+	return smp_processor_id();
+}
 static inline bool tick_nohz_full_enabled(void) { return false; }
 static inline bool tick_nohz_full_cpu(int cpu) { return false; }
 static inline void __tick_nohz_full_check(void) { }
kernel/sched/core.c +7 -2
index 57bd333..acee856 100644
@@ -599,18 +599,23 @@ int get_nohz_timer_target(int pinned)
 	int i;
 	struct sched_domain *sd;
 
-	if (pinned || !get_sysctl_timer_migration() || !idle_cpu(cpu))
+	if (pinned || !get_sysctl_timer_migration() ||
+		(!idle_cpu(cpu) && is_housekeeping_cpu(cpu)))
 		return cpu;
 
 	rcu_read_lock();
 	for_each_domain(cpu, sd) {
 		for_each_cpu(i, sched_domain_span(sd)) {
-			if (!idle_cpu(i)) {
+			if (!idle_cpu(i) && is_housekeeping_cpu(cpu)) {
 				cpu = i;
 				goto unlock;
 			}
 		}
 	}
+
+	if (!is_housekeeping_cpu(cpu))
+		cpu = housekeeping_any_cpu();
+
 unlock:
 	rcu_read_unlock();
 	return cpu;
#2 lore raw
In reply to a message not in the archive

I hope everybody received the patch because there is a ";" after each address :-)

Quoted 9 lines · Vatika Harlalka

The problem addressed in this patch is about affining unpinned timers. Adaptive or Full Dynticks CPUs should not be disturbed by unnecessary jitter due to firing of such timers on them.
This patch will affine timers to online CPUs which are not Full Dynticks in FULL_NOHZ configured systems. It will not bring about functional changes if NOHZ_FULL is not configured, because is_housekeeping_cpu() always returns true in CONFIG_NO_HZ_FULL=n.

Signed-off by: Vatika Harlalka <[email protected]>

The patch looks good to me. Peter, Thomas, are you ok with it too?

Thanks.

Quoted 66 lines

---
Changes: Patch sent to the right recipients.

 include/linux/tick.h | 9 ++++++++-
 kernel/sched/core.c  | 9 +++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
include/linux/tick.h +8 -1
index f8492da5..145bcba 100644
@@ -133,13 +133,20 @@ static inline bool tick_nohz_full_cpu(int cpu)
 
 	return cpumask_test_cpu(cpu, tick_nohz_full_mask);
 }
-
+static inline int housekeeping_any_cpu(void)
+{
+	return cpumask_any_and(housekeeping_mask, cpu_online_mask);
+}
 extern void __tick_nohz_full_check(void);
 extern void tick_nohz_full_kick(void);
 extern void tick_nohz_full_kick_cpu(int cpu);
 extern void tick_nohz_full_kick_all(void);
 extern void __tick_nohz_task_switch(struct task_struct *tsk);
 #else
+static inline int housekeeping_any_cpu(void)
+{
+	return smp_processor_id();
+}
 static inline bool tick_nohz_full_enabled(void) { return false; }
 static inline bool tick_nohz_full_cpu(int cpu) { return false; }
 static inline void __tick_nohz_full_check(void) { }
kernel/sched/core.c +7 -2
index 57bd333..acee856 100644
@@ -599,18 +599,23 @@ int get_nohz_timer_target(int pinned)
 	int i;
 	struct sched_domain *sd;
 
-	if (pinned || !get_sysctl_timer_migration() || !idle_cpu(cpu))
+	if (pinned || !get_sysctl_timer_migration() ||
+		(!idle_cpu(cpu) && is_housekeeping_cpu(cpu)))
 		return cpu;
 
 	rcu_read_lock();
 	for_each_domain(cpu, sd) {
 		for_each_cpu(i, sched_domain_span(sd)) {
-			if (!idle_cpu(i)) {
+			if (!idle_cpu(i) && is_housekeeping_cpu(cpu)) {
 				cpu = i;
 				goto unlock;
 			}
 		}
 	}
+
+	if (!is_housekeeping_cpu(cpu))
+		cpu = housekeeping_any_cpu();
+
 unlock:
 	rcu_read_unlock();
 	return cpu;
Signature · 1 line
2.4.2
#3 lore raw
Quoted 11 lines · Frederic Weisbecker

I hope everybody received the patch because there is a ";" after each address :-)

Quoted 8 lines · Vatika Harlalka

The problem addressed in this patch is about affining unpinned timers. Adaptive or Full Dynticks CPUs should not be disturbed by unnecessary jitter due to firing of such timers on them.
This patch will affine timers to online CPUs which are not Full Dynticks in FULL_NOHZ configured systems. It will not bring about functional changes if NOHZ_FULL is not configured, because is_housekeeping_cpu() always returns true in CONFIG_NO_HZ_FULL=n.

Quoted 3 lines
Quoted 1 line

Signed-off by: Vatika Harlalka <[email protected]>

The patch looks good to me. Peter, Thomas, are you ok with it too?

By some definition of OK. The overhead of this is growing and growing.

We really need to make this a pull not a push model.

Thanks,

tglx

#4 lore raw
Quoted 12 lines · Thomas Gleixner
Quoted 11 lines · Frederic Weisbecker

I hope everybody received the patch because there is a ";" after each address :-)

Quoted 8 lines · Vatika Harlalka

The problem addressed in this patch is about affining unpinned timers. Adaptive or Full Dynticks CPUs should not be disturbed by unnecessary jitter due to firing of such timers on them.
This patch will affine timers to online CPUs which are not Full Dynticks in FULL_NOHZ configured systems. It will not bring about functional changes if NOHZ_FULL is not configured, because is_housekeeping_cpu() always returns true in CONFIG_NO_HZ_FULL=n.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Signed-off by: Vatika Harlalka <[email protected]>

The patch looks good to me. Peter, Thomas, are you ok with it too?

By some definition of OK. The overhead of this is growing and growing.

We really need to make this a pull not a push model.

I'm currently working toward that.
See "[PATCH 0/8] tick/nohz: Tick dependency quick check + cleanups" as a first step.

Now for this very patch, I don't know how we could make it better. Any suggestion?

Quoted 3 lines

Thanks,

tglx

#5 lore raw
Quoted 19 lines · Frederic Weisbecker
Quoted 18 lines · Thomas Gleixner
Quoted 11 lines · Frederic Weisbecker

I hope everybody received the patch because there is a ";" after each address :-)

Quoted 8 lines · Vatika Harlalka

The problem addressed in this patch is about affining unpinned timers. Adaptive or Full Dynticks CPUs should not be disturbed by unnecessary jitter due to firing of such timers on them.
This patch will affine timers to online CPUs which are not Full Dynticks in FULL_NOHZ configured systems. It will not bring about functional changes if NOHZ_FULL is not configured, because is_housekeeping_cpu() always returns true in CONFIG_NO_HZ_FULL=n.

Quoted 3 lines
Quoted 1 line

Signed-off by: Vatika Harlalka <[email protected]>

The patch looks good to me. Peter, Thomas, are you ok with it too?

By some definition of OK. The overhead of this is growing and growing.

Quoted 8 lines
Quoted 1 line

We really need to make this a pull not a push model.

I'm currently working toward that.
See "[PATCH 0/8] tick/nohz: Tick dependency quick check + cleanups" as a first step.

Now for this very patch, I don't know how we could make it better. Any suggestion?

Not for the time being. When I'm done with the timer wheel overhaul we should look into queueing stuff in different wheels and let the non idle cpus pull from there instead of pushing stuff at enqueue time. The latter is really silly because most of these timers are removed before they expire. Needs some thoughts, but anything which avoids the whole target cpu crap at enqueue time is better than what we have now.

Thanks,

tglx

#6 lore raw

If everyone thinks its alright, could this patch be applied please? :)

Thanks
Vatika

#7 lore raw

I'm going to resend the patch :)

Quoted 4 lines · Vatika Harlalka

If everyone thinks its alright, could this patch be applied please? :)

Thanks
Vatika