extern int nr_processes(void);
extern unsigned long nr_running(void);
extern unsigned long nr_iowait(void);
+#ifdef CONFIG_CPUQUIET_FRAMEWORK
+extern u64 nr_running_integral(unsigned int cpu);
+#endif
extern unsigned long nr_iowait_cpu(int cpu);
extern unsigned long this_cpu_load(void);
return this->cpu_load[0];
}
+#ifdef CONFIG_CPUQUIET_FRAMEWORK
+u64 nr_running_integral(unsigned int cpu)
+{
+ unsigned int seqcnt;
+ u64 integral;
+ struct rq *q;
+
+ if (cpu >= nr_cpu_ids)
+ return 0;
+
+ q = cpu_rq(cpu);
+
+ /*
+ * Update average to avoid reading stalled value if there were
+ * no run-queue changes for a long time. On the other hand if
+ * the changes are happening right now, just read current value
+ * directly.
+ */
+
+ seqcnt = read_seqcount_begin(&q->ave_seqcnt);
+ integral = do_nr_running_integral(q);
+ if (read_seqcount_retry(&q->ave_seqcnt, seqcnt)) {
+ read_seqcount_begin(&q->ave_seqcnt);
+ integral = q->nr_running_integral;
+ }
+
+ return integral;
+}
+#endif
/*
* Global load-average calculations
#endif
int skip_clock_update;
+#ifdef CONFIG_CPUQUIET_FRAMEWORK
+ /* time-based average load */
+ u64 nr_last_stamp;
+ u64 nr_running_integral;
+ seqcount_t ave_seqcnt;
+#endif
+
/* capture load from *all* tasks on this cpu: */
struct load_weight load;
unsigned long nr_load_updates;
}
#endif
+#ifdef CONFIG_CPUQUIET_FRAMEWORK
+/* 27 ~= 134217728ns = 134.2ms
+ * 26 ~= 67108864ns = 67.1ms
+ * 25 ~= 33554432ns = 33.5ms
+ * 24 ~= 16777216ns = 16.8ms
+ */
+#define NR_AVE_SCALE(x) ((x) << FSHIFT)
+
+static inline u64 do_nr_running_integral(struct rq *rq)
+{
+ s64 nr, deltax;
+ u64 nr_running_integral = rq->nr_running_integral;
+
+ deltax = rq->clock_task - rq->nr_last_stamp;
+ nr = NR_AVE_SCALE(rq->nr_running);
+
+ nr_running_integral += nr * deltax;
+
+ return nr_running_integral;
+}
+#endif
+
static inline void inc_nr_running(struct rq *rq)
{
+#ifdef CONFIG_CPUQUIET_FRAMEWORK
+ write_seqcount_begin(&rq->ave_seqcnt);
+ rq->nr_running_integral = do_nr_running_integral(rq);
+ rq->nr_last_stamp = rq->clock_task;
+#endif
rq->nr_running++;
+#ifdef CONFIG_CPUQUIET_FRAMEWORK
+ write_seqcount_end(&rq->ave_seqcnt);
+#endif
#ifdef CONFIG_NO_HZ_FULL
if (rq->nr_running == 2) {
static inline void dec_nr_running(struct rq *rq)
{
+#ifdef CONFIG_CPUQUIET_FRAMEWORK
+ write_seqcount_begin(&rq->ave_seqcnt);
+ rq->nr_running_integral = do_nr_running_integral(rq);
+ rq->nr_last_stamp = rq->clock_task;
+#endif
rq->nr_running--;
+#ifdef CONFIG_CPUQUIET_FRAMEWORK
+ write_seqcount_end(&rq->ave_seqcnt);
+#endif
}
static inline void rq_last_tick_reset(struct rq *rq)