[PATCH v8 02/14] vmstat: add vmstat_idle function

Chris Metcalf
2015-10-20T20:36:44Z

This function checks to see if a vmstat worker is not running,
and the vmstat diffs don't require an update. The function is
called from the task-isolation code to see if we need to
actually do some work to quiet vmstat.

Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
---
include/linux/vmstat.h | 2 ++
mm/vmstat.c | 10 ++++++++++
2 files changed, 12 insertions(+)

diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index c013b8d8e434..34e3b768e432 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -212,6 +212,7 @@ extern void dec_zone_state(struct zone *, enum zone_stat_item);
extern void __dec_zone_state(struct zone *, enum zone_stat_item);

void quiet_vmstat(void);
+bool vmstat_idle(void);
void cpu_vm_stats_fold(int cpu);
void refresh_zone_stat_thresholds(void);

@@ -274,6 +275,7 @@ static inline void refresh_cpu_vm_stats(int cpu) { }
static inline void refresh_zone_stat_thresholds(void) { }
static inline void cpu_vm_stats_fold(int cpu) { }
static inline void quiet_vmstat(void) { }
+static inline bool vmstat_idle(void) { return true; }

static inline void drain_zonestat(struct zone *zone,
struct per_cpu_pageset *pset) { }
diff --git a/mm/vmstat.c b/mm/vmstat.c
index a9c446353c7e..05fa1f0eefc8 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1431,6 +1431,16 @@ static bool need_update(int cpu)
return false;
}

+/*
+ * Report on whether vmstat processing is quiesced on the core currently:
+ * no vmstat worker running and no vmstat updates to perform.
+ */
+bool vmstat_idle(void)
+{
+ int cpu = smp_processor_id();
+ return cpumask_test_cpu(cpu, cpu_stat_off) && !need_update(cpu);
+}
+

/*
* Shepherd worker thread that checks the
--
2.1.2