Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1683886

[RFC PATCH v1 02/11] cpuidle: attach cpuidle governor statistics to the per-CPU device

From Aubrey Li <aubrey.li@intel.com>
Newsgroups linux.kernel
Subject [RFC PATCH v1 02/11] cpuidle: attach cpuidle governor statistics to the per-CPU device
Date 2017-07-10 03:50 +0200
Message-ID <u1vZL-6V4-3@gated-at.bofh.it> (permalink)
References <u1vZL-6V4-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Aubrey Li <aubrey.li@linux.intel.com>

A generic CPU idle governor is required to make the prediction of
how long the coming idle. The statistic data taken from the existing
menu governor is attached to the per-CPU device data structure
---
 include/linux/cpuidle.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index fc1e5d7..f17a53b 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -61,6 +61,34 @@ struct cpuidle_state {
 			      int index);
 };
 
+/*
+ * Please note when changing the tuning values:
+ * If (MAX_INTERESTING-1) * RESOLUTION > UINT_MAX, the result of
+ * a scaling operation multiplication may overflow on 32 bit platforms.
+ * In that case, #define RESOLUTION as ULL to get 64 bit result:
+ * #define RESOLUTION 1024ULL
+ *
+ * The default values do not overflow.
+ */
+#define	BUCKETS 12
+#define	INTERVAL_SHIFT 3
+#define	INTERVALS (1UL << INTERVAL_SHIFT)
+#define	RESOLUTION 1024
+#define	DECAY 8
+#define	MAX_INTERESTING 50000
+
+struct cpuidle_governor_stat {
+	int             last_state_idx;
+
+	unsigned int	next_timer_us;
+	unsigned int	predicted_us;
+	unsigned int	bucket;
+	unsigned int	correction_factor[BUCKETS];
+	unsigned int	intervals[INTERVALS];
+	int		interval_ptr;
+};
+
+
 /* Idle State Flags */
 #define CPUIDLE_FLAG_NONE       (0x00)
 #define CPUIDLE_FLAG_COUPLED	(0x02) /* state applies to multiple cpus */
@@ -89,8 +117,10 @@ struct cpuidle_device {
 	cpumask_t		coupled_cpus;
 	struct cpuidle_coupled	*coupled;
 #endif
+	struct cpuidle_governor_stat gov_stat;
 };
 
+
 DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
 DECLARE_PER_CPU(struct cpuidle_device, cpuidle_dev);
 
-- 
2.7.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[RFC PATCH v1 02/11] cpuidle: attach cpuidle governor statistics to the per-CPU device Aubrey Li <aubrey.li@intel.com> - 2017-07-10 03:50 +0200

csiph-web