sched/walt: Implement sched_lpm_disallowed_time() API

LPM governor can query the scheduler preference about the CPU's
c-state via sched_lpm_disallowed_time() API. It returns 0 when
shallowest c-state is preferred and associated timeout is set.

Change-Id: Ie8246aa9ec4638730d3442468aa9dc1969a90369
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
This commit is contained in:
Pavankumar Kondeti 2021-02-01 10:16:25 +05:30 committed by Rishabh Bhatnagar
parent 899a181942
commit 09445f02e8
3 changed files with 31 additions and 5 deletions

View File

@ -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 <linux/types.h>
#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 */

View File

@ -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);

View File

@ -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);