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

Commit 6b5b4132 authored by Amit Pundir's avatar Amit Pundir
Browse files

Merge branch 'android-3.18' of https://android.googlesource.com/kernel/common

* android-3.18:
  cpufreq_stats: fix use of cpufreq_for_each_valid_entry() iterator
  initramfs: Add skip_initramfs command line option
  cpu_power: Avoids race condition when the task exits.
  uid_cputime: Avoids double accounting of process stime, utime and cpu_power in task exit.
  Shrink ashmem directly through shmem_fallocate
  sched: cpufreq: update power usage only if cpufreq_stat is enabled
  cpufreq: Iterate over all the possible cpus to create powerstats.
  uid_cputime: Extends the cputime functionality to report power per uid
  sched: cpufreq: Adds a field cpu_power in the task_struct
parents 028d5c1b 309cd2c0
Loading
Loading
Loading
Loading
+27 −5
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/sort.h>
#include <linux/of.h>
#include <linux/sched.h>
#include <linux/cputime.h>

static spinlock_t cpufreq_stats_lock;
@@ -125,6 +126,25 @@ static int get_index_all_cpufreq_stat(struct all_cpufreq_stats *all_stat,
	return -1;
}

void acct_update_power(struct task_struct *task, cputime_t cputime) {
	struct cpufreq_power_stats *powerstats;
	struct cpufreq_stats *stats;
	unsigned int cpu_num, curr;

	if (!task)
		return;
	cpu_num = task_cpu(task);
	powerstats = per_cpu(cpufreq_power_stats, cpu_num);
	stats = per_cpu(cpufreq_stats_table, cpu_num);
	if (!powerstats || !stats)
		return;

	curr = powerstats->curr[stats->last_index];
	if (task->cpu_power != ULLONG_MAX)
		task->cpu_power += curr * cputime_to_usecs(cputime);
}
EXPORT_SYMBOL_GPL(acct_update_power);

static ssize_t show_current_in_state(struct kobject *kobj,
		struct kobj_attribute *attr, char *buf)
{
@@ -557,7 +577,7 @@ static void cpufreq_stats_create_table(unsigned int cpu)

	table = cpufreq_frequency_get_table(policy->cpu);
	if (likely(table)) {
		cpufreq_for_each_valid_entry(pos, table);
		cpufreq_for_each_valid_entry(pos, table)
			count++;

		if (!per_cpu(all_cpufreq_stats, cpu))
@@ -577,7 +597,7 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
	int ret = 0, count = 0;
	struct cpufreq_policy *policy = data;
	struct cpufreq_frequency_table *table, *pos;
	unsigned int cpu = policy->cpu;
	unsigned int cpu_num, cpu = policy->cpu;

	if (val == CPUFREQ_UPDATE_POLICY_CPU) {
		cpufreq_stats_update_policy_cpu(policy);
@@ -588,14 +608,16 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
	if (!table)
		return 0;

	cpufreq_for_each_valid_entry(pos, table);
	cpufreq_for_each_valid_entry(pos, table)
		count++;

	if (!per_cpu(all_cpufreq_stats, cpu))
		cpufreq_allstats_create(cpu, table, count);

	if (!per_cpu(cpufreq_power_stats, cpu))
		cpufreq_powerstats_create(cpu, table, count);
	for_each_possible_cpu(cpu_num) {
		if (!per_cpu(cpufreq_power_stats, cpu_num))
			cpufreq_powerstats_create(cpu_num, table, count);
	}

	if (val == CPUFREQ_CREATE_POLICY)
		ret = __cpufreq_stats_create_table(policy, table, count);
+16 −2
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ struct uid_entry {
	cputime_t stime;
	cputime_t active_utime;
	cputime_t active_stime;
	unsigned long long active_power;
	unsigned long long power;
	struct hlist_node hash;
};

@@ -83,6 +85,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
	hash_for_each(hash_table, bkt, uid_entry, hash) {
		uid_entry->active_stime = 0;
		uid_entry->active_utime = 0;
		uid_entry->active_power = 0;
	}

	read_lock(&tasklist_lock);
@@ -97,9 +100,15 @@ static int uid_stat_show(struct seq_file *m, void *v)
				task_uid(task)));
			return -ENOMEM;
		}
		/* if this task is exiting, we have already accounted for the
		 * time and power.
		 */
		if (task->cpu_power == ULLONG_MAX)
			continue;
		task_cputime_adjusted(task, &utime, &stime);
		uid_entry->active_utime += utime;
		uid_entry->active_stime += stime;
		uid_entry->active_power += task->cpu_power;
	}
	read_unlock(&tasklist_lock);

@@ -108,9 +117,12 @@ static int uid_stat_show(struct seq_file *m, void *v)
							uid_entry->active_utime;
		cputime_t total_stime = uid_entry->stime +
							uid_entry->active_stime;
		seq_printf(m, "%d: %u %u\n", uid_entry->uid,
		unsigned long long total_power = uid_entry->power +
							uid_entry->active_power;
		seq_printf(m, "%d: %u %u %llu\n", uid_entry->uid,
						cputime_to_usecs(total_utime),
						cputime_to_usecs(total_stime));
						cputime_to_usecs(total_stime),
						total_power);
	}

	mutex_unlock(&uid_lock);
@@ -203,6 +215,8 @@ static int process_notifier(struct notifier_block *self,
	task_cputime_adjusted(task, &utime, &stime);
	uid_entry->utime += utime;
	uid_entry->stime += stime;
	uid_entry->power += task->cpu_power;
	task->cpu_power = ULLONG_MAX;

exit:
	mutex_unlock(&uid_lock);
+1 −1
Original line number Diff line number Diff line
@@ -440,7 +440,7 @@ ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
		loff_t start = range->pgstart * PAGE_SIZE;
		loff_t end = (range->pgend + 1) * PAGE_SIZE;

		do_fallocate(range->asma->file,
		range->asma->file->f_op->fallocate(range->asma->file,
				FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
				start, end - start);
		range->purged = ASHMEM_WAS_PURGED;
+9 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#include <linux/notifier.h>
#include <linux/spinlock.h>
#include <linux/sysfs.h>
#include <asm/cputime.h>


/*********************************************************************
 *                        CPUFREQ INTERFACE                          *
@@ -600,4 +602,11 @@ unsigned int cpufreq_generic_get(unsigned int cpu);
int cpufreq_generic_init(struct cpufreq_policy *policy,
		struct cpufreq_frequency_table *table,
		unsigned int transition_latency);

/*********************************************************************
 *                         CPUFREQ STATS                             *
 *********************************************************************/

void acct_update_power(struct task_struct *p, cputime_t cputime);

#endif /* _LINUX_CPUFREQ_H */
+32 −0
Original line number Diff line number Diff line
/*
 * include/linux/initramfs.h
 *
 * Copyright (C) 2015, Google
 * Rom Lemarchand <romlem@android.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#ifndef _LINUX_INITRAMFS_H
#define _LINUX_INITRAMFS_H

#include <linux/kconfig.h>

#if IS_BUILTIN(CONFIG_BLK_DEV_INITRD)

int __init default_rootfs(void);

#endif

#endif /* _LINUX_INITRAMFS_H */
Loading