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

Commit b0bf3abc authored by Lina Iyer's avatar Lina Iyer
Browse files

drivers: qcom: lpm-stats: reset CPU stats from that CPU



Currently when the LPM stats are reset, they are saved stats are reset
without synchronizing with the idle state of the CPU. As a result, CPUs
that are currently idle when the stats are reset may throw a wrench into
the accounting by adding the sleep time from before the point of reset.

Fix this by waking up each CPU and resetting the CPU's stats from that
CPU when the stats are reset. This behavior is only supported when the
stats are reset from the overall stats.

echo reset > /sys/kernel/debug/lpm_stats/stats

Change-Id: I2751bf0fb8d9ce9cb79c2429b5b59dd7b9681adb
Signed-off-by: default avatarLina Iyer <ilina@codeaurora.org>
parent 336e98a2
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <linux/debugfs.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/smp.h>
#include <linux/suspend.h>
#include <soc/qcom/spm.h>
#include <soc/qcom/pm.h>
@@ -255,6 +256,15 @@ static ssize_t level_stats_file_write(struct file *file,
	return count;
}

static void reset_cpu_stats(void *info)
{
	struct lpm_stats *stats = &(*this_cpu_ptr(&(cpu_stats)));
	int i;

	for (i = 0; i < stats->num_levels; i++)
		level_stats_reset(&stats->time_stats[i]);
}

static ssize_t lpm_stats_file_write(struct file *file,
	const char __user *buffer, size_t count, loff_t *off)
{
@@ -276,6 +286,12 @@ static ssize_t lpm_stats_file_write(struct file *file,
		return -EINVAL;

	level_stats_reset_all(stats);
	/*
	 * Wake up each CPU and reset the stats from that CPU,
	 * for that CPU, so we could have better timestamp for
	 * accounting.
	 */
	on_each_cpu(reset_cpu_stats, NULL, 1);

	return count;
}