Skip to contentSkip to conversation

sched/nohz: add debugfs control over sched_tick_max_deferment

PATCH In review Kevin Hilman 2 participants 4 messages Sep 26, 2014 – Sep 29, 2014 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/nohz: add debugfs control over sched_tick_max_deferment

From: Kevin Hilman <[email protected]>

Allow debugfs override of sched_tick_max_deferment in order to ease finding/fixing the remaining issues with full nohz.

The value to be written is in jiffies, and -1 means the max deferment is disabled (scheduler_tick_max_deferment() returns KTIME_MAX.)

Cc Frederic Weisbecker <[email protected]>
---
 kernel/sched/core.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
kernel/sched/core.c +15 -1
index bc1638b33449..dee044a5d447 100644
@@ -2514,6 +2514,8 @@ void scheduler_tick(void)
 }
 
 #ifdef CONFIG_NO_HZ_FULL
+static u32 sched_tick_max_deferment = HZ;
+
 /**
  * scheduler_tick_max_deferment
  *
@@ -2532,13 +2534,25 @@ u64 scheduler_tick_max_deferment(void)
 	struct rq *rq = this_rq();
 	unsigned long next, now = ACCESS_ONCE(jiffies);
 
-	next = rq->last_sched_tick + HZ;
+	if (sched_tick_max_deferment == -1)
+		return KTIME_MAX;
+
+	next = rq->last_sched_tick + sched_tick_max_deferment;
 
 	if (time_before_eq(next, now))
 		return 0;
 
 	return jiffies_to_nsecs(next - now);
 }
+
+static __init int sched_nohz_full_init_debug(void)
+{
+	debugfs_create_u32("sched_tick_max_deferment", 0644, NULL,
+			   &sched_tick_max_deferment);
+
+	return 0;
+}
+late_initcall(sched_nohz_full_init_debug);
 #endif
 
 notrace unsigned long get_parent_ip(unsigned long addr)
Signature · 1 line
2.1.0
#1 lore raw

Hi Frederic,

Quoted 10 lines · Kevin Hilman

From: Kevin Hilman <[email protected]>

Allow debugfs override of sched_tick_max_deferment in order to ease finding/fixing the remaining issues with full nohz.

The value to be written is in jiffies, and -1 means the max deferment is disabled (scheduler_tick_max_deferment() returns KTIME_MAX.)

Cc Frederic Weisbecker <[email protected]>

This is just an attempt to revive and hopefully finalize the discussion started a while back[1].

Kevin

[1] https://lkml.org/lkml/2014/1/14/914

#2 lore raw
In reply to Kevin Hilman
Quoted 10 lines · Kevin Hilman

From: Kevin Hilman <[email protected]>

Allow debugfs override of sched_tick_max_deferment in order to ease finding/fixing the remaining issues with full nohz.

The value to be written is in jiffies, and -1 means the max deferment is disabled (scheduler_tick_max_deferment() returns KTIME_MAX.)

Cc Frederic Weisbecker <[email protected]>

So, I'm worried that it becomes a hack that everybody uses to shutdown the tick completely then nobody will come and fix the issue that prevents from doing it properly.

I seriously doubt this will be used for development purpose to help fixing the real problem. Quite the opposite. If developers want to do testing, they can as well comment out the call to scheduler_max_tick_deferment().

Quoted 47 lines
---
 kernel/sched/core.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
kernel/sched/core.c +15 -1
index bc1638b33449..dee044a5d447 100644
@@ -2514,6 +2514,8 @@ void scheduler_tick(void)
 }
 
 #ifdef CONFIG_NO_HZ_FULL
+static u32 sched_tick_max_deferment = HZ;
+
 /**
  * scheduler_tick_max_deferment
  *
@@ -2532,13 +2534,25 @@ u64 scheduler_tick_max_deferment(void)
 	struct rq *rq = this_rq();
 	unsigned long next, now = ACCESS_ONCE(jiffies);
 
-	next = rq->last_sched_tick + HZ;
+	if (sched_tick_max_deferment == -1)
+		return KTIME_MAX;
+
+	next = rq->last_sched_tick + sched_tick_max_deferment;
 
 	if (time_before_eq(next, now))
 		return 0;
 
 	return jiffies_to_nsecs(next - now);
 }
+
+static __init int sched_nohz_full_init_debug(void)
+{
+	debugfs_create_u32("sched_tick_max_deferment", 0644, NULL,
+			   &sched_tick_max_deferment);
+
+	return 0;
+}
+late_initcall(sched_nohz_full_init_debug);
 #endif
 
 notrace unsigned long get_parent_ip(unsigned long addr)
Signature · 1 line
2.1.0
#3 lore raw
Quoted 9 lines · Frederic Weisbecker
Quoted 8 lines · Kevin Hilman

From: Kevin Hilman <[email protected]>

Allow debugfs override of sched_tick_max_deferment in order to ease finding/fixing the remaining issues with full nohz.

The value to be written is in jiffies, and -1 means the max deferment is disabled (scheduler_tick_max_deferment() returns KTIME_MAX.)

Quoted 6 lines
Quoted 2 lines
Cc Frederic Weisbecker <[email protected]>

So, I'm worried that it becomes a hack that everybody uses to shutdown the tick completely then nobody will come and fix the issue that prevents from doing it properly.

OK.

Quoted 2 lines

I seriously doubt this will be used for development purpose to help fixing the real problem.

Well, that's what I was using it for, until I was distracted by other tasks.

Quoted 2 lines

Quite the opposite. If developers want to do
testing, they can as well comment out the call to scheduler_max_tick_deferment().

OK, fair enough.

Thanks,

Kevin