Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6202eb5c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "vmstat: make vmstat_updater deferrable again and shut down on idle"

parents 1e0ac94b 2d30d088
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -231,6 +231,7 @@ extern void __inc_zone_state(struct zone *, enum zone_stat_item);
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);
void cpu_vm_stats_fold(int cpu);
void refresh_zone_stat_thresholds(void);

@@ -292,6 +293,7 @@ static inline void __dec_zone_page_state(struct page *page,
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 void drain_zonestat(struct zone *zone,
			struct per_cpu_pageset *pset) { }
+1 −0
Original line number Diff line number Diff line
@@ -199,6 +199,7 @@ static void cpu_idle_loop(void)
		 */

		__current_set_polling();
		quiet_vmstat();
		tick_nohz_idle_enter();

		while (!need_resched()) {
+45 −26
Original line number Diff line number Diff line
@@ -455,7 +455,7 @@ static int fold_diff(int *diff)
 *
 * The function returns the number of global counters updated.
 */
static int refresh_cpu_vm_stats(void)
static int refresh_cpu_vm_stats(bool do_pagesets)
{
	struct zone *zone;
	int i;
@@ -479,8 +479,9 @@ static int refresh_cpu_vm_stats(void)
#endif
			}
		}
		cond_resched();
#ifdef CONFIG_NUMA
		if (do_pagesets) {
			cond_resched();
			/*
			 * Deal with draining the remote pageset of this
			 * processor
@@ -507,6 +508,7 @@ static int refresh_cpu_vm_stats(void)
				drain_zone_pages(zone, this_cpu_ptr(&p->pcp));
				changes++;
			}
		}
#endif
	}
	changes += fold_diff(global_diff);
@@ -1355,7 +1357,7 @@ static cpumask_var_t cpu_stat_off;

static void vmstat_update(struct work_struct *w)
{
	if (refresh_cpu_vm_stats())
	if (refresh_cpu_vm_stats(true)) {
		/*
		 * Counters were updated so we expect more updates
		 * to occur in the future. Keep on running the
@@ -1364,7 +1366,7 @@ static void vmstat_update(struct work_struct *w)
		schedule_delayed_work_on(smp_processor_id(),
				this_cpu_ptr(&vmstat_work),
			round_jiffies_relative(sysctl_stat_interval));
	else {
	} else {
		/*
		 * We did not update any counters so the app may be in
		 * a mode where it does not cause counter updates.
@@ -1386,6 +1388,23 @@ static void vmstat_update(struct work_struct *w)
	}
}

/*
 * Switch off vmstat processing and then fold all the remaining differentials
 * until the diffs stay at zero. The function is used by NOHZ and can only be
 * invoked when tick processing is not active.
 */
void quiet_vmstat(void)
{
	if (system_state != SYSTEM_RUNNING)
		return;

	do {
		if (!cpumask_test_and_set_cpu(smp_processor_id(), cpu_stat_off))
			cancel_delayed_work(this_cpu_ptr(&vmstat_work));

	} while (refresh_cpu_vm_stats(false));
}

/*
 * Check if the diffs for a certain cpu indicate that
 * an update is needed.
@@ -1418,7 +1437,7 @@ static bool need_update(int cpu)
 */
static void vmstat_shepherd(struct work_struct *w);

static DECLARE_DELAYED_WORK(shepherd, vmstat_shepherd);
static DECLARE_DEFERRABLE_WORK(shepherd, vmstat_shepherd);

static void vmstat_shepherd(struct work_struct *w)
{