[Devel] [PATCH rh8 2/6] sched: Make calc_global_load() return true when it's need to update ve statistic

Konstantin Khorenko khorenko at virtuozzo.com
Thu Oct 22 15:54:48 MSK 2020


From: Kirill Tkhai <ktkhai at virtuozzo.com>

This will be used in next patches to call calc_load_ve() out of jiffies lock.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>

=========================
Patchset description:
Make calc_load_ve() be executed out of jiffies_lock

https://jira.sw.ru/browse/PSBM-84967

Kirill Tkhai (3):
      sched: Make calc_global_load() return true when it's need to
	     update ve statistic
      sched: Export calc_load_ve()
      sched: Call calc_load_ve() out of jiffies_lock

(cherry picked from vz commit b26208e2f8bae0bc539bef9f37d5fc650e47e092)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 include/linux/sched/loadavg.h | 4 +++-
 kernel/sched/loadavg.c        | 5 +++--
 kernel/time/timekeeping.c     | 4 ++--
 kernel/time/timekeeping.h     | 2 +-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/include/linux/sched/loadavg.h b/include/linux/sched/loadavg.h
index 4859bea47a7b..34061919f880 100644
--- a/include/linux/sched/loadavg.h
+++ b/include/linux/sched/loadavg.h
@@ -2,6 +2,8 @@
 #ifndef _LINUX_SCHED_LOADAVG_H
 #define _LINUX_SCHED_LOADAVG_H
 
+#include <linux/types.h>
+
 /*
  * These are the constant used to fake the fixed-point load-average
  * counting. Some notes:
@@ -43,6 +45,6 @@ extern unsigned long calc_load_n(unsigned long load, unsigned long exp,
 #define LOAD_INT(x) ((x) >> FSHIFT)
 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
 
-extern void calc_global_load(unsigned long ticks);
+extern bool calc_global_load(unsigned long ticks);
 
 #endif /* _LINUX_SCHED_LOADAVG_H */
diff --git a/kernel/sched/loadavg.c b/kernel/sched/loadavg.c
index de22da666ac7..a7b373053dc4 100644
--- a/kernel/sched/loadavg.c
+++ b/kernel/sched/loadavg.c
@@ -347,14 +347,14 @@ static inline void calc_global_nohz(void) { }
  *
  * Called from the global timer code.
  */
-void calc_global_load(unsigned long ticks)
+bool calc_global_load(unsigned long ticks)
 {
 	unsigned long sample_window;
 	long active, delta;
 
 	sample_window = READ_ONCE(calc_load_update);
 	if (time_before(jiffies, sample_window + 10))
-		return;
+		return false;
 
 	/*
 	 * Fold the 'old' NO_HZ-delta to include all NO_HZ CPUs.
@@ -377,6 +377,7 @@ void calc_global_load(unsigned long ticks)
 	 * catch up in bulk.
 	 */
 	calc_global_nohz();
+	return true;
 }
 
 /*
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 4118179d8c75..bce92a9952f4 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2192,10 +2192,10 @@ EXPORT_SYMBOL(ktime_get_coarse_ts64);
 /*
  * Must hold jiffies_lock
  */
-void do_timer(unsigned long ticks)
+bool do_timer(unsigned long ticks)
 {
 	jiffies_64 += ticks;
-	calc_global_load(ticks);
+	return calc_global_load(ticks);
 }
 
 /**
diff --git a/kernel/time/timekeeping.h b/kernel/time/timekeeping.h
index 7a9b4eb7a1d5..7b6cdb0563f4 100644
--- a/kernel/time/timekeeping.h
+++ b/kernel/time/timekeeping.h
@@ -15,7 +15,7 @@ extern void timekeeping_warp_clock(void);
 extern int timekeeping_suspend(void);
 extern void timekeeping_resume(void);
 
-extern void do_timer(unsigned long ticks);
+extern bool do_timer(unsigned long ticks);
 extern void update_wall_time(void);
 
 extern seqlock_t jiffies_lock;
-- 
2.28.0



More information about the Devel mailing list