cpuidle: Add cpuidle_use_deepest_state_mask() helper function
The cpuidle_use_deepest_state() function introduced in commit 2847a3ac96d32 only affects the calling CPU. Add a helper function that affects all CPUs in a given cpumask to make it easier to toggle use_deepest_state for multiple CPUs at once and reduce boilerplate code wherever such behavior is desired. Signed-off-by: kdrag0n <dragon@khronodragon.com>
This commit is contained in:
parent
88ef894b09
commit
bef0d9ad57
2 changed files with 35 additions and 1 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include <linux/ktime.h>
|
#include <linux/ktime.h>
|
||||||
#include <linux/hrtimer.h>
|
#include <linux/hrtimer.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
#include <linux/suspend.h>
|
#include <linux/suspend.h>
|
||||||
#include <linux/tick.h>
|
#include <linux/tick.h>
|
||||||
#include <trace/events/power.h>
|
#include <trace/events/power.h>
|
||||||
|
@ -128,6 +129,32 @@ void cpuidle_use_deepest_state(bool enable)
|
||||||
preempt_enable();
|
preempt_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_uds_callback(void *info)
|
||||||
|
{
|
||||||
|
bool enable = *(bool *)info;
|
||||||
|
|
||||||
|
cpuidle_use_deepest_state(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cpuidle_use_deepest_state_mask - Set use_deepest_state on specific CPUs.
|
||||||
|
* @target: cpumask of CPUs to update use_deepest_state on.
|
||||||
|
* @enable: whether to enforce the deepest idle state on those CPUs.
|
||||||
|
*/
|
||||||
|
int cpuidle_use_deepest_state_mask(const struct cpumask *target, bool enable)
|
||||||
|
{
|
||||||
|
bool *info = kmalloc(sizeof(bool), GFP_KERNEL);
|
||||||
|
|
||||||
|
if (!info)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
*info = enable;
|
||||||
|
on_each_cpu_mask(target, set_uds_callback, info, 1);
|
||||||
|
kfree(info);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cpuidle_find_deepest_state - Find the deepest available idle state.
|
* cpuidle_find_deepest_state - Find the deepest available idle state.
|
||||||
* @drv: cpuidle driver for the given CPU.
|
* @drv: cpuidle driver for the given CPU.
|
||||||
|
|
|
@ -198,7 +198,9 @@ extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
|
||||||
struct cpuidle_device *dev);
|
struct cpuidle_device *dev);
|
||||||
extern int cpuidle_enter_freeze(struct cpuidle_driver *drv,
|
extern int cpuidle_enter_freeze(struct cpuidle_driver *drv,
|
||||||
struct cpuidle_device *dev);
|
struct cpuidle_device *dev);
|
||||||
extern void cpuidle_use_deepest_state(bool enable);
|
extern void cpuidle_use_deepest_state(bool enable);
|
||||||
|
extern int cpuidle_use_deepest_state_mask(const struct cpumask *target,
|
||||||
|
bool enable);
|
||||||
#else
|
#else
|
||||||
static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
|
static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
|
||||||
struct cpuidle_device *dev)
|
struct cpuidle_device *dev)
|
||||||
|
@ -209,6 +211,11 @@ static inline int cpuidle_enter_freeze(struct cpuidle_driver *drv,
|
||||||
static inline void cpuidle_use_deepest_state(bool enable)
|
static inline void cpuidle_use_deepest_state(bool enable)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
static inline int cpuidle_use_deepest_state_mask(const struct cpumask *target,
|
||||||
|
bool enable)
|
||||||
|
{
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* kernel/sched/idle.c */
|
/* kernel/sched/idle.c */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue