diff --git a/include/linux/sched/walt.h b/include/linux/sched/walt.h new file mode 100644 index 000000000000..f3fdd4da27e8 --- /dev/null +++ b/include/linux/sched/walt.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2021, The Linux Foundation. All rights reserved. + */ + +#ifndef _LINUX_SCHED_WALT_H +#define _LINUX_SCHED_WALT_H + +#include + +#if IS_ENABLED(CONFIG_SCHED_WALT) +extern int sched_lpm_disallowed_time(int cpu, u64 *timeout); +#else +static inline int sched_lpm_disallowed_time(int cpu, u64 *timeout) +{ + return INT_MAX; +} +#endif + +#endif /* _LINUX_SCHED_WALT_H */ diff --git a/kernel/sched/walt/sched_avg.c b/kernel/sched/walt/sched_avg.c index cec81ea98fba..ededab2476e6 100644 --- a/kernel/sched/walt/sched_avg.c +++ b/kernel/sched/walt/sched_avg.c @@ -237,14 +237,21 @@ unsigned int sched_get_cpu_util(int cpu) return busy; } -u64 sched_lpm_disallowed_time(int cpu) +int sched_lpm_disallowed_time(int cpu, u64 *timeout) { u64 now = sched_clock(); u64 bias_end_time = atomic64_read(&per_cpu(busy_hyst_end_time, cpu)); - if (now < bias_end_time) - return bias_end_time - now; + if (unlikely(is_reserved(cpu))) { + *timeout = 10 * NSEC_PER_MSEC; + return 0; /* shallowest c-state */ + } - return 0; + if (now < bias_end_time) { + *timeout = bias_end_time - now; + return 0; /* shallowest c-state */ + } + + return INT_MAX; /* don't care */ } EXPORT_SYMBOL(sched_lpm_disallowed_time); diff --git a/kernel/sched/walt/walt.h b/kernel/sched/walt/walt.h index 50afd59cb54a..37c03d98182f 100644 --- a/kernel/sched/walt/walt.h +++ b/kernel/sched/walt/walt.h @@ -278,7 +278,6 @@ extern int sched_unpause_cpus(struct cpumask *unpause_cpus); extern unsigned int sched_get_cpu_util(int cpu); extern void sched_update_hyst_times(void); -extern u64 sched_lpm_disallowed_time(int cpu); extern int sched_updown_migrate_handler(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos);