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

Commit 22fc5259 authored by Andres Oportus's avatar Andres Oportus Committed by TARKZiM
Browse files

ANDROID: cpufreq: stats: Fix dead stats clearing timing



Combine task exit stats aggregation to happen at the same
time when stats are cleared, avoiding inconsistent data
(stats of uids time appear to decrease) and simplifying
the code.

Bug: 63041570
Test: Continuosly read /proc/uid_time_in_state and check
for decreasing values

Signed-off-by: default avatarAndres Oportus <andresoportus@google.com>
Signed-off-by: default avatarConnor O'Brien <connoro@google.com>
Change-Id: Ie2b4ce4a02f533140a6c5f9ae5cb7ae978c93f9e
parent 9beae7c4
Loading
Loading
Loading
Loading
+5 −13
Original line number Diff line number Diff line
@@ -259,18 +259,6 @@ void cpufreq_task_stats_init(struct task_struct *p)
	spin_unlock_irqrestore(&task_time_in_state_lock, flags);
}

void cpufreq_task_stats_exit(struct task_struct *p)
{
	unsigned long flags;
	void *temp;

	spin_lock_irqsave(&task_time_in_state_lock, flags);
	temp = p->time_in_state;
	p->time_in_state = NULL;
	spin_unlock_irqrestore(&task_time_in_state_lock, flags);
	kfree(temp);
}

int proc_time_in_state_show(struct seq_file *m, struct pid_namespace *ns,
			    struct pid *pid, struct task_struct *p)
{
@@ -973,6 +961,7 @@ static int process_notifier(struct notifier_block *self,
	struct task_struct *task = v;
	struct uid_entry *uid_entry;
	unsigned long flags;
	void *temp;
	uid_t uid;
	int i;

@@ -985,7 +974,7 @@ static int process_notifier(struct notifier_block *self,
	uid_entry = find_or_register_uid(uid);
	if (!uid_entry) {
		rt_mutex_unlock(&uid_lock);
		pr_err("%s: failed to find uid %d\n", __func__, uid);
		pr_err("%s: failed to find/register uid %d\n", __func__, uid);
		return NOTIFY_OK;
	}

@@ -1009,9 +998,12 @@ static int process_notifier(struct notifier_block *self,
				atomic_read(&task->time_in_state[i]);
		}
	}
	temp = task->time_in_state;
	task->time_in_state = NULL;
	spin_unlock_irqrestore(&task_time_in_state_lock, flags);

	rt_mutex_unlock(&uid_lock);
	kfree(temp);
	return NOTIFY_OK;
}

+0 −1
Original line number Diff line number Diff line
@@ -491,7 +491,6 @@ static inline int cpufreq_generic_exit(struct cpufreq_policy *policy)

void acct_update_power(struct task_struct *p, cputime_t cputime);
void cpufreq_task_stats_init(struct task_struct *p);
void cpufreq_task_stats_exit(struct task_struct *p);
void cpufreq_task_stats_remove_uids(uid_t uid_start, uid_t uid_end);
int  proc_time_in_state_show(struct seq_file *m, struct pid_namespace *ns,
	struct pid *pid, struct task_struct *p);
+0 −3
Original line number Diff line number Diff line
@@ -173,9 +173,6 @@ void release_task(struct task_struct * p)
{
	struct task_struct *leader;
	int zap_leader;
#ifdef CONFIG_CPU_FREQ_STAT
	cpufreq_task_stats_exit(p);
#endif
repeat:
	/* don't need to get the RCU readlock here - the process is dead and
	 * can't be modifying its own credentials. But shut RCU-lockdep up */