#ifndef _KERNEL_SCHED_SCHED_H
#define _KERNEL_SCHED_SCHED_H
#include <linux/sched/affinity.h>
#include <linux/sched/autogroup.h>
#include <linux/sched/cpufreq.h>
#include <linux/sched/deadline.h>
#include <linux/sched.h>
#include <linux/sched/loadavg.h>
#include <linux/sched/mm.h>
#include <linux/sched/rseq_api.h>
#include <linux/sched/signal.h>
#include <linux/sched/smt.h>
#include <linux/sched/stat.h>
#include <linux/sched/sysctl.h>
#include <linux/sched/task_flags.h>
#include <linux/sched/task.h>
#include <linux/sched/topology.h>
#include <linux/atomic.h>
#include <linux/bitmap.h>
#include <linux/bug.h>
#include <linux/capability.h>
#include <linux/cgroup_api.h>
#include <linux/cgroup.h>
#include <linux/context_tracking.h>
#include <linux/cpufreq.h>
#include <linux/cpumask_api.h>
#include <linux/ctype.h>
#include <linux/file.h>
#include <linux/fs_api.h>
#include <linux/hrtimer_api.h>
#include <linux/interrupt.h>
#include <linux/irq_work.h>
#include <linux/jiffies.h>
#include <linux/kref_api.h>
#include <linux/kthread.h>
#include <linux/ktime_api.h>
#include <linux/lockdep_api.h>
#include <linux/lockdep.h>
#include <linux/minmax.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/mutex_api.h>
#include <linux/plist.h>
#include <linux/poll.h>
#include <linux/proc_fs.h>
#include <linux/profile.h>
#include <linux/psi.h>
#include <linux/rcupdate.h>
#include <linux/seq_file.h>
#include <linux/seqlock.h>
#include <linux/softirq.h>
#include <linux/spinlock_api.h>
#include <linux/static_key.h>
#include <linux/stop_machine.h>
#include <linux/syscalls_api.h>
#include <linux/syscalls.h>
#include <linux/tick.h>
#include <linux/topology.h>
#include <linux/types.h>
#include <linux/u64_stats_sync_api.h>
#include <linux/uaccess.h>
#include <linux/wait_api.h>
#include <linux/wait_bit.h>
#include <linux/workqueue_api.h>
#include <trace/events/power.h>
#include <trace/events/sched.h>
#include "../workqueue_internal.h"
struct rq;
struct cfs_rq;
struct rt_rq;
struct sched_group;
struct cpuidle_state;
#ifdef CONFIG_PARAVIRT
# include <asm/paravirt.h>
# include <asm/paravirt_api_clock.h>
#endif
#include <asm/barrier.h>
#include "cpupri.h"
#include "cpudeadline.h"
#ifdef CONFIG_SCHED_DEBUG
#define SCHED_WARN_ON(x) …
#else
#define SCHED_WARN_ON …
#endif
#define TASK_ON_RQ_QUEUED …
#define TASK_ON_RQ_MIGRATING …
extern __read_mostly int scheduler_running;
extern unsigned long calc_load_update;
extern atomic_long_t calc_load_tasks;
extern void calc_global_load_tick(struct rq *this_rq);
extern long calc_load_fold_active(struct rq *this_rq, long adjust);
extern void call_trace_sched_update_nr_running(struct rq *rq, int count);
extern int sysctl_sched_rt_period;
extern int sysctl_sched_rt_runtime;
extern int sched_rr_timeslice;
struct asym_cap_data { … };
extern struct list_head asym_cap_list;
#define cpu_capacity_span(asym_data) …
#define NS_TO_JIFFIES(time) …
#ifdef CONFIG_64BIT
#define NICE_0_LOAD_SHIFT …
#define scale_load(w) …
#define scale_load_down(w) …
#else
#define NICE_0_LOAD_SHIFT …
#define scale_load …
#define scale_load_down …
#endif
#define NICE_0_LOAD …
#define DL_SCALE …
#define RUNTIME_INF …
static inline int idle_policy(int policy)
{ … }
static inline int fair_policy(int policy)
{ … }
static inline int rt_policy(int policy)
{ … }
static inline int dl_policy(int policy)
{ … }
static inline bool valid_policy(int policy)
{ … }
static inline int task_has_idle_policy(struct task_struct *p)
{ … }
static inline int task_has_rt_policy(struct task_struct *p)
{ … }
static inline int task_has_dl_policy(struct task_struct *p)
{ … }
#define cap_scale(v, s) …
static inline void update_avg(u64 *avg, u64 sample)
{ … }
#define shr_bound(val, shift) …
#define SCHED_FLAG_SUGOV …
#define SCHED_DL_FLAGS …
static inline bool dl_entity_is_special(const struct sched_dl_entity *dl_se)
{ … }
static inline bool dl_entity_preempt(const struct sched_dl_entity *a,
const struct sched_dl_entity *b)
{ … }
struct rt_prio_array { … };
struct rt_bandwidth { … };
static inline int dl_bandwidth_enabled(void)
{ … }
struct dl_bw { … };
extern void init_dl_bw(struct dl_bw *dl_b);
extern int sched_dl_global_validate(void);
extern void sched_dl_do_global(void);
extern int sched_dl_overflow(struct task_struct *p, int policy, const struct sched_attr *attr);
extern void __setparam_dl(struct task_struct *p, const struct sched_attr *attr);
extern void __getparam_dl(struct task_struct *p, struct sched_attr *attr);
extern bool __checkparam_dl(const struct sched_attr *attr);
extern bool dl_param_changed(struct task_struct *p, const struct sched_attr *attr);
extern int dl_cpuset_cpumask_can_shrink(const struct cpumask *cur, const struct cpumask *trial);
extern int dl_bw_check_overflow(int cpu);
extern void dl_server_update(struct sched_dl_entity *dl_se, s64 delta_exec);
extern void dl_server_start(struct sched_dl_entity *dl_se);
extern void dl_server_stop(struct sched_dl_entity *dl_se);
extern void dl_server_init(struct sched_dl_entity *dl_se, struct rq *rq,
dl_server_has_tasks_f has_tasks,
dl_server_pick_f pick);
#ifdef CONFIG_CGROUP_SCHED
extern struct list_head task_groups;
struct cfs_bandwidth { … };
struct task_group { … };
#ifdef CONFIG_FAIR_GROUP_SCHED
#define ROOT_TASK_GROUP_LOAD …
#define MIN_SHARES …
#define MAX_SHARES …
#endif
tg_visitor;
extern int walk_tg_tree_from(struct task_group *from,
tg_visitor down, tg_visitor up, void *data);
static inline int walk_tg_tree(tg_visitor down, tg_visitor up, void *data)
{ … }
extern int tg_nop(struct task_group *tg, void *data);
#ifdef CONFIG_FAIR_GROUP_SCHED
extern void free_fair_sched_group(struct task_group *tg);
extern int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent);
extern void online_fair_sched_group(struct task_group *tg);
extern void unregister_fair_sched_group(struct task_group *tg);
#else
static inline void free_fair_sched_group(struct task_group *tg) { }
static inline int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
{
return 1;
}
static inline void online_fair_sched_group(struct task_group *tg) { }
static inline void unregister_fair_sched_group(struct task_group *tg) { }
#endif
extern void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
struct sched_entity *se, int cpu,
struct sched_entity *parent);
extern void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b, struct cfs_bandwidth *parent);
extern void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b);
extern void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b);
extern void unthrottle_cfs_rq(struct cfs_rq *cfs_rq);
extern bool cfs_task_bw_constrained(struct task_struct *p);
extern void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq,
struct sched_rt_entity *rt_se, int cpu,
struct sched_rt_entity *parent);
extern int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us);
extern int sched_group_set_rt_period(struct task_group *tg, u64 rt_period_us);
extern long sched_group_rt_runtime(struct task_group *tg);
extern long sched_group_rt_period(struct task_group *tg);
extern int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk);
extern struct task_group *sched_create_group(struct task_group *parent);
extern void sched_online_group(struct task_group *tg,
struct task_group *parent);
extern void sched_destroy_group(struct task_group *tg);
extern void sched_release_group(struct task_group *tg);
extern void sched_move_task(struct task_struct *tsk);
#ifdef CONFIG_FAIR_GROUP_SCHED
extern int sched_group_set_shares(struct task_group *tg, unsigned long shares);
extern int sched_group_set_idle(struct task_group *tg, long idle);
#ifdef CONFIG_SMP
extern void set_task_rq_fair(struct sched_entity *se,
struct cfs_rq *prev, struct cfs_rq *next);
#else
static inline void set_task_rq_fair(struct sched_entity *se,
struct cfs_rq *prev, struct cfs_rq *next) { }
#endif
#endif
#else
struct cfs_bandwidth { };
static inline bool cfs_task_bw_constrained(struct task_struct *p) { return false; }
#endif
extern void unregister_rt_sched_group(struct task_group *tg);
extern void free_rt_sched_group(struct task_group *tg);
extern int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent);
#ifdef CONFIG_64BIT
#define u64_u32_load_copy(var, copy) …
#define u64_u32_store_copy(var, copy, val) …
#else
#define u64_u32_load_copy …
#define u64_u32_store_copy …
#endif
#define u64_u32_load(var) …
#define u64_u32_store(var, val) …
struct cfs_rq { … };
static inline int rt_bandwidth_enabled(void)
{ … }
#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_SMP)
#define HAVE_RT_PUSH_IPI
#endif
struct rt_rq { … };
static inline bool rt_rq_is_runnable(struct rt_rq *rt_rq)
{ … }
struct dl_rq { … };
#ifdef CONFIG_FAIR_GROUP_SCHED
#define entity_is_task(se) …
static inline void se_update_runnable(struct sched_entity *se)
{ … }
static inline long se_runnable(struct sched_entity *se)
{ … }
#else
#define entity_is_task …
static inline void se_update_runnable(struct sched_entity *se) { }
static inline long se_runnable(struct sched_entity *se)
{
return !!se->on_rq;
}
#endif
#ifdef CONFIG_SMP
static inline long se_weight(struct sched_entity *se)
{ … }
static inline bool sched_asym_prefer(int a, int b)
{ … }
struct perf_domain { … };
struct root_domain { … };
extern void init_defrootdomain(void);
extern int sched_init_domains(const struct cpumask *cpu_map);
extern void rq_attach_root(struct rq *rq, struct root_domain *rd);
extern void sched_get_rd(struct root_domain *rd);
extern void sched_put_rd(struct root_domain *rd);
static inline int get_rd_overloaded(struct root_domain *rd)
{ … }
static inline void set_rd_overloaded(struct root_domain *rd, int status)
{ … }
#ifdef HAVE_RT_PUSH_IPI
extern void rto_push_irq_work_func(struct irq_work *work);
#endif
#endif
#ifdef CONFIG_UCLAMP_TASK
struct uclamp_bucket { … };
struct uclamp_rq { … };
DECLARE_STATIC_KEY_FALSE(sched_uclamp_used);
#endif
struct balance_callback { … };
struct rq { … };
#ifdef CONFIG_FAIR_GROUP_SCHED
static inline struct rq *rq_of(struct cfs_rq *cfs_rq)
{ … }
#else
static inline struct rq *rq_of(struct cfs_rq *cfs_rq)
{
return container_of(cfs_rq, struct rq, cfs);
}
#endif
static inline int cpu_of(struct rq *rq)
{ … }
#define MDF_PUSH …
static inline bool is_migration_disabled(struct task_struct *p)
{ … }
DECLARE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
#define cpu_rq(cpu) …
#define this_rq() …
#define task_rq(p) …
#define cpu_curr(cpu) …
#define raw_rq() …
#ifdef CONFIG_SCHED_CORE
static inline struct cpumask *sched_group_span(struct sched_group *sg);
DECLARE_STATIC_KEY_FALSE(__sched_core_enabled);
static inline bool sched_core_enabled(struct rq *rq)
{ … }
static inline bool sched_core_disabled(void)
{ … }
static inline raw_spinlock_t *rq_lockp(struct rq *rq)
{ … }
static inline raw_spinlock_t *__rq_lockp(struct rq *rq)
{ … }
extern bool
cfs_prio_less(const struct task_struct *a, const struct task_struct *b, bool fi);
extern void task_vruntime_update(struct rq *rq, struct task_struct *p, bool in_fi);
static inline bool sched_cpu_cookie_match(struct rq *rq, struct task_struct *p)
{ … }
static inline bool sched_core_cookie_match(struct rq *rq, struct task_struct *p)
{ … }
static inline bool sched_group_cookie_match(struct rq *rq,
struct task_struct *p,
struct sched_group *group)
{ … }
static inline bool sched_core_enqueued(struct task_struct *p)
{ … }
extern void sched_core_enqueue(struct rq *rq, struct task_struct *p);
extern void sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags);
extern void sched_core_get(void);
extern void sched_core_put(void);
#else
static inline bool sched_core_enabled(struct rq *rq)
{
return false;
}
static inline bool sched_core_disabled(void)
{
return true;
}
static inline raw_spinlock_t *rq_lockp(struct rq *rq)
{
return &rq->__lock;
}
static inline raw_spinlock_t *__rq_lockp(struct rq *rq)
{
return &rq->__lock;
}
static inline bool sched_cpu_cookie_match(struct rq *rq, struct task_struct *p)
{
return true;
}
static inline bool sched_core_cookie_match(struct rq *rq, struct task_struct *p)
{
return true;
}
static inline bool sched_group_cookie_match(struct rq *rq,
struct task_struct *p,
struct sched_group *group)
{
return true;
}
#endif
static inline void lockdep_assert_rq_held(struct rq *rq)
{ … }
extern void raw_spin_rq_lock_nested(struct rq *rq, int subclass);
extern bool raw_spin_rq_trylock(struct rq *rq);
extern void raw_spin_rq_unlock(struct rq *rq);
static inline void raw_spin_rq_lock(struct rq *rq)
{ … }
static inline void raw_spin_rq_lock_irq(struct rq *rq)
{ … }
static inline void raw_spin_rq_unlock_irq(struct rq *rq)
{ … }
static inline unsigned long _raw_spin_rq_lock_irqsave(struct rq *rq)
{ … }
static inline void raw_spin_rq_unlock_irqrestore(struct rq *rq, unsigned long flags)
{ … }
#define raw_spin_rq_lock_irqsave(rq, flags) …
#ifdef CONFIG_SCHED_SMT
extern void __update_idle_core(struct rq *rq);
static inline void update_idle_core(struct rq *rq)
{ … }
#else
static inline void update_idle_core(struct rq *rq) { }
#endif
#ifdef CONFIG_FAIR_GROUP_SCHED
static inline struct task_struct *task_of(struct sched_entity *se)
{ … }
static inline struct cfs_rq *task_cfs_rq(struct task_struct *p)
{ … }
static inline struct cfs_rq *cfs_rq_of(const struct sched_entity *se)
{ … }
static inline struct cfs_rq *group_cfs_rq(struct sched_entity *grp)
{ … }
#else
#define task_of …
static inline struct cfs_rq *task_cfs_rq(const struct task_struct *p)
{
return &task_rq(p)->cfs;
}
static inline struct cfs_rq *cfs_rq_of(const struct sched_entity *se)
{
const struct task_struct *p = task_of(se);
struct rq *rq = task_rq(p);
return &rq->cfs;
}
static inline struct cfs_rq *group_cfs_rq(struct sched_entity *grp)
{
return NULL;
}
#endif
extern void update_rq_clock(struct rq *rq);
#define RQCF_REQ_SKIP …
#define RQCF_ACT_SKIP …
#define RQCF_UPDATED …
static inline void assert_clock_updated(struct rq *rq)
{ … }
static inline u64 rq_clock(struct rq *rq)
{ … }
static inline u64 rq_clock_task(struct rq *rq)
{ … }
static inline void rq_clock_skip_update(struct rq *rq)
{ … }
static inline void rq_clock_cancel_skipupdate(struct rq *rq)
{ … }
static inline void rq_clock_start_loop_update(struct rq *rq)
{ … }
static inline void rq_clock_stop_loop_update(struct rq *rq)
{ … }
struct rq_flags { … };
extern struct balance_callback balance_push_callback;
static inline void rq_pin_lock(struct rq *rq, struct rq_flags *rf)
{ … }
static inline void rq_unpin_lock(struct rq *rq, struct rq_flags *rf)
{ … }
static inline void rq_repin_lock(struct rq *rq, struct rq_flags *rf)
{ … }
extern
struct rq *__task_rq_lock(struct task_struct *p, struct rq_flags *rf)
__acquires(…);
extern
struct rq *task_rq_lock(struct task_struct *p, struct rq_flags *rf)
__acquires(…)
__acquires(…);
static inline void __task_rq_unlock(struct rq *rq, struct rq_flags *rf)
__releases(rq->lock)
{ … }
static inline void
task_rq_unlock(struct rq *rq, struct task_struct *p, struct rq_flags *rf)
__releases(rq->lock)
__releases(p->pi_lock)
{ … }
DEFINE_LOCK_GUARD_1(task_rq_lock, struct task_struct,
_T->rq = …
static inline void rq_lock_irqsave(struct rq *rq, struct rq_flags *rf)
__acquires(rq->lock)
{ … }
static inline void rq_lock_irq(struct rq *rq, struct rq_flags *rf)
__acquires(rq->lock)
{ … }
static inline void rq_lock(struct rq *rq, struct rq_flags *rf)
__acquires(rq->lock)
{ … }
static inline void rq_unlock_irqrestore(struct rq *rq, struct rq_flags *rf)
__releases(rq->lock)
{ … }
static inline void rq_unlock_irq(struct rq *rq, struct rq_flags *rf)
__releases(rq->lock)
{ … }
static inline void rq_unlock(struct rq *rq, struct rq_flags *rf)
__releases(rq->lock)
{ … }
DEFINE_LOCK_GUARD_1(rq_lock, struct rq,
rq_lock(_T->lock, &_T->rf),
rq_unlock(_T->lock, &_T->rf),
… }
DEFINE_LOCK_GUARD_1(rq_lock_irq, struct rq,
rq_lock_irq(_T->lock, &_T->rf),
rq_unlock_irq(_T->lock, &_T->rf),
… }
DEFINE_LOCK_GUARD_1(rq_lock_irqsave, struct rq,
rq_lock_irqsave(_T->lock, &_T->rf),
rq_unlock_irqrestore(_T->lock, &_T->rf),
… }
static inline struct rq *this_rq_lock_irq(struct rq_flags *rf)
__acquires(rq->lock)
{ … }
#ifdef CONFIG_NUMA
enum numa_topology_type { … };
extern enum numa_topology_type sched_numa_topology_type;
extern int sched_max_numa_distance;
extern bool find_numa_distance(int distance);
extern void sched_init_numa(int offline_node);
extern void sched_update_numa(int cpu, bool online);
extern void sched_domains_numa_masks_set(unsigned int cpu);
extern void sched_domains_numa_masks_clear(unsigned int cpu);
extern int sched_numa_find_closest(const struct cpumask *cpus, int cpu);
#else
static inline void sched_init_numa(int offline_node) { }
static inline void sched_update_numa(int cpu, bool online) { }
static inline void sched_domains_numa_masks_set(unsigned int cpu) { }
static inline void sched_domains_numa_masks_clear(unsigned int cpu) { }
static inline int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
{
return nr_cpu_ids;
}
#endif
#ifdef CONFIG_NUMA_BALANCING
enum numa_faults_stats { … };
extern void sched_setnuma(struct task_struct *p, int node);
extern int migrate_task_to(struct task_struct *p, int cpu);
extern int migrate_swap(struct task_struct *p, struct task_struct *t,
int cpu, int scpu);
extern void init_numa_balancing(unsigned long clone_flags, struct task_struct *p);
#else
static inline void
init_numa_balancing(unsigned long clone_flags, struct task_struct *p)
{
}
#endif
#ifdef CONFIG_SMP
static inline void
queue_balance_callback(struct rq *rq,
struct balance_callback *head,
void (*func)(struct rq *rq))
{ … }
#define rcu_dereference_check_sched_domain(p) …
#define for_each_domain(cpu, __sd) …
#define SD_FLAG …
static const unsigned int SD_SHARED_CHILD_MASK = …;
#undef SD_FLAG
static inline struct sched_domain *highest_flag_domain(int cpu, int flag)
{ … }
static inline struct sched_domain *lowest_flag_domain(int cpu, int flag)
{ … }
DECLARE_PER_CPU(struct sched_domain __rcu *, sd_llc);
DECLARE_PER_CPU(int, sd_llc_size);
DECLARE_PER_CPU(int, sd_llc_id);
DECLARE_PER_CPU(int, sd_share_id);
DECLARE_PER_CPU(struct sched_domain_shared __rcu *, sd_llc_shared);
DECLARE_PER_CPU(struct sched_domain __rcu *, sd_numa);
DECLARE_PER_CPU(struct sched_domain __rcu *, sd_asym_packing);
DECLARE_PER_CPU(struct sched_domain __rcu *, sd_asym_cpucapacity);
extern struct static_key_false sched_asym_cpucapacity;
extern struct static_key_false sched_cluster_active;
static __always_inline bool sched_asym_cpucap_active(void)
{ … }
struct sched_group_capacity { … };
struct sched_group { … };
static inline struct cpumask *sched_group_span(struct sched_group *sg)
{ … }
static inline struct cpumask *group_balance_mask(struct sched_group *sg)
{ … }
extern int group_balance_cpu(struct sched_group *sg);
#ifdef CONFIG_SCHED_DEBUG
extern void update_sched_domain_debugfs(void);
extern void dirty_sched_domain_sysctl(int cpu);
#else
static inline void update_sched_domain_debugfs(void) { }
static inline void dirty_sched_domain_sysctl(int cpu) { }
#endif
extern int sched_update_scaling(void);
static inline const struct cpumask *task_user_cpus(struct task_struct *p)
{ … }
#endif
#include "stats.h"
#if defined(CONFIG_SCHED_CORE) && defined(CONFIG_SCHEDSTATS)
extern void __sched_core_account_forceidle(struct rq *rq);
static inline void sched_core_account_forceidle(struct rq *rq)
{ … }
extern void __sched_core_tick(struct rq *rq);
static inline void sched_core_tick(struct rq *rq)
{ … }
#else
static inline void sched_core_account_forceidle(struct rq *rq) { }
static inline void sched_core_tick(struct rq *rq) { }
#endif
#ifdef CONFIG_CGROUP_SCHED
static inline struct task_group *task_group(struct task_struct *p)
{ … }
static inline void set_task_rq(struct task_struct *p, unsigned int cpu)
{ … }
#else
static inline void set_task_rq(struct task_struct *p, unsigned int cpu) { }
static inline struct task_group *task_group(struct task_struct *p)
{
return NULL;
}
#endif
static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu)
{ … }
#ifdef CONFIG_SCHED_DEBUG
#define const_debug …
#else
#define const_debug …
#endif
#define SCHED_FEAT …
enum { … };
#undef SCHED_FEAT
#ifdef CONFIG_SCHED_DEBUG
extern const_debug unsigned int sysctl_sched_features;
#ifdef CONFIG_JUMP_LABEL
#define SCHED_FEAT …
#include "features.h"
#undef SCHED_FEAT
extern struct static_key sched_feat_keys[__SCHED_FEAT_NR];
#define sched_feat(x) …
#else
#define sched_feat …
#endif
#else
#define SCHED_FEAT …
static const_debug __maybe_unused unsigned int sysctl_sched_features =
#include "features.h"
0;
#undef SCHED_FEAT
#define sched_feat …
#endif
extern struct static_key_false sched_numa_balancing;
extern struct static_key_false sched_schedstats;
static inline u64 global_rt_period(void)
{ … }
static inline u64 global_rt_runtime(void)
{ … }
static inline int task_current(struct rq *rq, struct task_struct *p)
{ … }
static inline int task_on_cpu(struct rq *rq, struct task_struct *p)
{ … }
static inline int task_on_rq_queued(struct task_struct *p)
{ … }
static inline int task_on_rq_migrating(struct task_struct *p)
{ … }
#define WF_EXEC …
#define WF_FORK …
#define WF_TTWU …
#define WF_SYNC …
#define WF_MIGRATED …
#define WF_CURRENT_CPU …
#ifdef CONFIG_SMP
static_assert(…);
static_assert(…);
static_assert(…);
#endif
#define WEIGHT_IDLEPRIO …
#define WMULT_IDLEPRIO …
extern const int sched_prio_to_weight[40];
extern const u32 sched_prio_to_wmult[40];
#define DEQUEUE_SLEEP …
#define DEQUEUE_SAVE …
#define DEQUEUE_MOVE …
#define DEQUEUE_NOCLOCK …
#define DEQUEUE_MIGRATING …
#define ENQUEUE_WAKEUP …
#define ENQUEUE_RESTORE …
#define ENQUEUE_MOVE …
#define ENQUEUE_NOCLOCK …
#define ENQUEUE_HEAD …
#define ENQUEUE_REPLENISH …
#ifdef CONFIG_SMP
#define ENQUEUE_MIGRATED …
#else
#define ENQUEUE_MIGRATED …
#endif
#define ENQUEUE_INITIAL …
#define ENQUEUE_MIGRATING …
#define RETRY_TASK …
struct affinity_context { … };
extern s64 update_curr_common(struct rq *rq);
struct sched_class { … };
static inline void put_prev_task(struct rq *rq, struct task_struct *prev)
{ … }
static inline void set_next_task(struct rq *rq, struct task_struct *next)
{ … }
#define DEFINE_SCHED_CLASS(name) …
extern struct sched_class __sched_class_highest[];
extern struct sched_class __sched_class_lowest[];
#define for_class_range(class, _from, _to) …
#define for_each_class(class) …
#define sched_class_above(_a, _b) …
extern const struct sched_class stop_sched_class;
extern const struct sched_class dl_sched_class;
extern const struct sched_class rt_sched_class;
extern const struct sched_class fair_sched_class;
extern const struct sched_class idle_sched_class;
static inline bool sched_stop_runnable(struct rq *rq)
{ … }
static inline bool sched_dl_runnable(struct rq *rq)
{ … }
static inline bool sched_rt_runnable(struct rq *rq)
{ … }
static inline bool sched_fair_runnable(struct rq *rq)
{ … }
extern struct task_struct *pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf);
extern struct task_struct *pick_next_task_idle(struct rq *rq);
#define SCA_CHECK …
#define SCA_MIGRATE_DISABLE …
#define SCA_MIGRATE_ENABLE …
#define SCA_USER …
#ifdef CONFIG_SMP
extern void update_group_capacity(struct sched_domain *sd, int cpu);
extern void sched_balance_trigger(struct rq *rq);
extern int __set_cpus_allowed_ptr(struct task_struct *p, struct affinity_context *ctx);
extern void set_cpus_allowed_common(struct task_struct *p, struct affinity_context *ctx);
static inline cpumask_t *alloc_user_cpus_ptr(int node)
{ … }
static inline struct task_struct *get_push_task(struct rq *rq)
{ … }
extern int push_cpu_stop(void *arg);
#else
static inline int __set_cpus_allowed_ptr(struct task_struct *p,
struct affinity_context *ctx)
{
return set_cpus_allowed_ptr(p, ctx->new_mask);
}
static inline cpumask_t *alloc_user_cpus_ptr(int node)
{
return NULL;
}
#endif
#ifdef CONFIG_CPU_IDLE
static inline void idle_set_state(struct rq *rq,
struct cpuidle_state *idle_state)
{ … }
static inline struct cpuidle_state *idle_get_state(struct rq *rq)
{ … }
#else
static inline void idle_set_state(struct rq *rq,
struct cpuidle_state *idle_state)
{
}
static inline struct cpuidle_state *idle_get_state(struct rq *rq)
{
return NULL;
}
#endif
extern void schedule_idle(void);
asmlinkage void schedule_user(void);
extern void sysrq_sched_debug_show(void);
extern void sched_init_granularity(void);
extern void update_max_interval(void);
extern void init_sched_dl_class(void);
extern void init_sched_rt_class(void);
extern void init_sched_fair_class(void);
extern void reweight_task(struct task_struct *p, const struct load_weight *lw);
extern void resched_curr(struct rq *rq);
extern void resched_cpu(int cpu);
extern struct rt_bandwidth def_rt_bandwidth;
extern void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime);
extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq);
extern void init_dl_entity(struct sched_dl_entity *dl_se);
#define BW_SHIFT …
#define BW_UNIT …
#define RATIO_SHIFT …
#define MAX_BW_BITS …
#define MAX_BW …
extern unsigned long to_ratio(u64 period, u64 runtime);
extern void init_entity_runnable_average(struct sched_entity *se);
extern void post_init_entity_util_avg(struct task_struct *p);
#ifdef CONFIG_NO_HZ_FULL
extern bool sched_can_stop_tick(struct rq *rq);
extern int __init sched_tick_offload_init(void);
static inline void sched_update_tick_dependency(struct rq *rq)
{
int cpu = cpu_of(rq);
if (!tick_nohz_full_cpu(cpu))
return;
if (sched_can_stop_tick(rq))
tick_nohz_dep_clear_cpu(cpu, TICK_DEP_BIT_SCHED);
else
tick_nohz_dep_set_cpu(cpu, TICK_DEP_BIT_SCHED);
}
#else
static inline int sched_tick_offload_init(void) { … }
static inline void sched_update_tick_dependency(struct rq *rq) { … }
#endif
static inline void add_nr_running(struct rq *rq, unsigned count)
{ … }
static inline void sub_nr_running(struct rq *rq, unsigned count)
{ … }
extern void activate_task(struct rq *rq, struct task_struct *p, int flags);
extern void deactivate_task(struct rq *rq, struct task_struct *p, int flags);
extern void wakeup_preempt(struct rq *rq, struct task_struct *p, int flags);
#ifdef CONFIG_PREEMPT_RT
#define SCHED_NR_MIGRATE_BREAK …
#else
#define SCHED_NR_MIGRATE_BREAK …
#endif
extern const_debug unsigned int sysctl_sched_nr_migrate;
extern const_debug unsigned int sysctl_sched_migration_cost;
extern unsigned int sysctl_sched_base_slice;
#ifdef CONFIG_SCHED_DEBUG
extern int sysctl_resched_latency_warn_ms;
extern int sysctl_resched_latency_warn_once;
extern unsigned int sysctl_sched_tunable_scaling;
extern unsigned int sysctl_numa_balancing_scan_delay;
extern unsigned int sysctl_numa_balancing_scan_period_min;
extern unsigned int sysctl_numa_balancing_scan_period_max;
extern unsigned int sysctl_numa_balancing_scan_size;
extern unsigned int sysctl_numa_balancing_hot_threshold;
#endif
#ifdef CONFIG_SCHED_HRTICK
static inline int hrtick_enabled(struct rq *rq)
{ … }
static inline int hrtick_enabled_fair(struct rq *rq)
{ … }
static inline int hrtick_enabled_dl(struct rq *rq)
{ … }
extern void hrtick_start(struct rq *rq, u64 delay);
#else
static inline int hrtick_enabled_fair(struct rq *rq)
{
return 0;
}
static inline int hrtick_enabled_dl(struct rq *rq)
{
return 0;
}
static inline int hrtick_enabled(struct rq *rq)
{
return 0;
}
#endif
#ifndef arch_scale_freq_tick
static __always_inline void arch_scale_freq_tick(void) { }
#endif
#ifndef arch_scale_freq_capacity
static __always_inline
unsigned long arch_scale_freq_capacity(int cpu)
{
return SCHED_CAPACITY_SCALE;
}
#endif
#ifdef CONFIG_SCHED_DEBUG
static inline void double_rq_clock_clear_update(struct rq *rq1, struct rq *rq2)
{ … }
#else
static inline void double_rq_clock_clear_update(struct rq *rq1, struct rq *rq2) { }
#endif
#define DEFINE_LOCK_GUARD_2(name, type, _lock, _unlock, ...) …
#ifdef CONFIG_SMP
static inline bool rq_order_less(struct rq *rq1, struct rq *rq2)
{ … }
extern void double_rq_lock(struct rq *rq1, struct rq *rq2);
#ifdef CONFIG_PREEMPTION
static inline int _double_lock_balance(struct rq *this_rq, struct rq *busiest)
__releases(this_rq->lock)
__acquires(busiest->lock)
__acquires(this_rq->lock)
{ … }
#else
static inline int _double_lock_balance(struct rq *this_rq, struct rq *busiest)
__releases(this_rq->lock)
__acquires(busiest->lock)
__acquires(this_rq->lock)
{
if (__rq_lockp(this_rq) == __rq_lockp(busiest) ||
likely(raw_spin_rq_trylock(busiest))) {
double_rq_clock_clear_update(this_rq, busiest);
return 0;
}
if (rq_order_less(this_rq, busiest)) {
raw_spin_rq_lock_nested(busiest, SINGLE_DEPTH_NESTING);
double_rq_clock_clear_update(this_rq, busiest);
return 0;
}
raw_spin_rq_unlock(this_rq);
double_rq_lock(this_rq, busiest);
return 1;
}
#endif
static inline int double_lock_balance(struct rq *this_rq, struct rq *busiest)
{ … }
static inline void double_unlock_balance(struct rq *this_rq, struct rq *busiest)
__releases(busiest->lock)
{ … }
static inline void double_lock(spinlock_t *l1, spinlock_t *l2)
{ … }
static inline void double_lock_irq(spinlock_t *l1, spinlock_t *l2)
{ … }
static inline void double_raw_lock(raw_spinlock_t *l1, raw_spinlock_t *l2)
{ … }
static inline void double_raw_unlock(raw_spinlock_t *l1, raw_spinlock_t *l2)
{ … }
DEFINE_LOCK_GUARD_2(double_raw_spinlock, raw_spinlock_t,
double_raw_lock(_T->lock, _T->lock2),
double_raw_unlock(_T->lock, _T->lock2))
static inline void double_rq_unlock(struct rq *rq1, struct rq *rq2)
__releases(rq1->lock)
__releases(rq2->lock)
{ … }
extern void set_rq_online (struct rq *rq);
extern void set_rq_offline(struct rq *rq);
extern bool sched_smp_initialized;
#else
static inline void double_rq_lock(struct rq *rq1, struct rq *rq2)
__acquires(rq1->lock)
__acquires(rq2->lock)
{
WARN_ON_ONCE(!irqs_disabled());
WARN_ON_ONCE(rq1 != rq2);
raw_spin_rq_lock(rq1);
__acquire(rq2->lock);
double_rq_clock_clear_update(rq1, rq2);
}
static inline void double_rq_unlock(struct rq *rq1, struct rq *rq2)
__releases(rq1->lock)
__releases(rq2->lock)
{
WARN_ON_ONCE(rq1 != rq2);
raw_spin_rq_unlock(rq1);
__release(rq2->lock);
}
#endif
DEFINE_LOCK_GUARD_2(double_rq_lock, … }
extern struct sched_entity *__pick_root_entity(struct cfs_rq *cfs_rq);
extern struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq);
extern struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq);
#ifdef CONFIG_SCHED_DEBUG
extern bool sched_debug_verbose;
extern void print_cfs_stats(struct seq_file *m, int cpu);
extern void print_rt_stats(struct seq_file *m, int cpu);
extern void print_dl_stats(struct seq_file *m, int cpu);
extern void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
extern void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq);
extern void print_dl_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq);
extern void resched_latency_warn(int cpu, u64 latency);
# ifdef CONFIG_NUMA_BALANCING
extern void show_numa_stats(struct task_struct *p, struct seq_file *m);
extern void
print_numa_stats(struct seq_file *m, int node, unsigned long tsf,
unsigned long tpf, unsigned long gsf, unsigned long gpf);
# endif
#else
static inline void resched_latency_warn(int cpu, u64 latency) { }
#endif
extern void init_cfs_rq(struct cfs_rq *cfs_rq);
extern void init_rt_rq(struct rt_rq *rt_rq);
extern void init_dl_rq(struct dl_rq *dl_rq);
extern void cfs_bandwidth_usage_inc(void);
extern void cfs_bandwidth_usage_dec(void);
#ifdef CONFIG_NO_HZ_COMMON
#define NOHZ_BALANCE_KICK_BIT …
#define NOHZ_STATS_KICK_BIT …
#define NOHZ_NEWILB_KICK_BIT …
#define NOHZ_NEXT_KICK_BIT …
#define NOHZ_BALANCE_KICK …
#define NOHZ_STATS_KICK …
#define NOHZ_NEWILB_KICK …
#define NOHZ_NEXT_KICK …
#define NOHZ_KICK_MASK …
#define nohz_flags(cpu) …
extern void nohz_balance_exit_idle(struct rq *rq);
#else
static inline void nohz_balance_exit_idle(struct rq *rq) { }
#endif
#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
extern void nohz_run_idle_balance(int cpu);
#else
static inline void nohz_run_idle_balance(int cpu) { }
#endif
#ifdef CONFIG_IRQ_TIME_ACCOUNTING
struct irqtime { … };
DECLARE_PER_CPU(struct irqtime, cpu_irqtime);
static inline u64 irq_time_read(int cpu)
{ … }
#endif
#ifdef CONFIG_CPU_FREQ
DECLARE_PER_CPU(struct update_util_data __rcu *, cpufreq_update_util_data);
static inline void cpufreq_update_util(struct rq *rq, unsigned int flags)
{ … }
#else
static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) { }
#endif
#ifdef arch_scale_freq_capacity
# ifndef arch_scale_freq_invariant
#define arch_scale_freq_invariant …
# endif
#else
#define arch_scale_freq_invariant …
#endif
#ifdef CONFIG_SMP
unsigned long effective_cpu_util(int cpu, unsigned long util_cfs,
unsigned long *min,
unsigned long *max);
unsigned long sugov_effective_cpu_perf(int cpu, unsigned long actual,
unsigned long min,
unsigned long max);
static inline bool dl_task_fits_capacity(struct task_struct *p, int cpu)
{ … }
static inline unsigned long cpu_bw_dl(struct rq *rq)
{ … }
static inline unsigned long cpu_util_dl(struct rq *rq)
{ … }
extern unsigned long cpu_util_cfs(int cpu);
extern unsigned long cpu_util_cfs_boost(int cpu);
static inline unsigned long cpu_util_rt(struct rq *rq)
{ … }
#endif
#ifdef CONFIG_UCLAMP_TASK
unsigned long uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id);
static inline unsigned long uclamp_rq_get(struct rq *rq,
enum uclamp_id clamp_id)
{ … }
static inline void uclamp_rq_set(struct rq *rq, enum uclamp_id clamp_id,
unsigned int value)
{ … }
static inline bool uclamp_rq_is_idle(struct rq *rq)
{ … }
static inline bool uclamp_rq_is_capped(struct rq *rq)
{ … }
static inline bool uclamp_is_used(void)
{ … }
#define for_each_clamp_id(clamp_id) …
extern unsigned int sysctl_sched_uclamp_util_min_rt_default;
static inline unsigned int uclamp_none(enum uclamp_id clamp_id)
{ … }
#define UCLAMP_BUCKET_DELTA …
static inline unsigned int uclamp_bucket_id(unsigned int clamp_value)
{ … }
static inline void
uclamp_se_set(struct uclamp_se *uc_se, unsigned int value, bool user_defined)
{ … }
#else
static inline unsigned long
uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id)
{
if (clamp_id == UCLAMP_MIN)
return 0;
return SCHED_CAPACITY_SCALE;
}
static inline bool uclamp_rq_is_capped(struct rq *rq) { return false; }
static inline bool uclamp_is_used(void)
{
return false;
}
static inline unsigned long
uclamp_rq_get(struct rq *rq, enum uclamp_id clamp_id)
{
if (clamp_id == UCLAMP_MIN)
return 0;
return SCHED_CAPACITY_SCALE;
}
static inline void
uclamp_rq_set(struct rq *rq, enum uclamp_id clamp_id, unsigned int value)
{
}
static inline bool uclamp_rq_is_idle(struct rq *rq)
{
return false;
}
#endif
#ifdef CONFIG_HAVE_SCHED_AVG_IRQ
static inline unsigned long cpu_util_irq(struct rq *rq)
{ … }
static inline
unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max)
{ … }
#else
static inline unsigned long cpu_util_irq(struct rq *rq)
{
return 0;
}
static inline
unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned long max)
{
return util;
}
#endif
#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
#define perf_domain_span(pd) …
DECLARE_STATIC_KEY_FALSE(sched_energy_present);
static inline bool sched_energy_enabled(void)
{ … }
extern struct cpufreq_governor schedutil_gov;
#else
#define perf_domain_span …
static inline bool sched_energy_enabled(void) { return false; }
#endif
#ifdef CONFIG_MEMBARRIER
static inline void membarrier_switch_mm(struct rq *rq,
struct mm_struct *prev_mm,
struct mm_struct *next_mm)
{ … }
#else
static inline void membarrier_switch_mm(struct rq *rq,
struct mm_struct *prev_mm,
struct mm_struct *next_mm)
{
}
#endif
#ifdef CONFIG_SMP
static inline bool is_per_cpu_kthread(struct task_struct *p)
{ … }
#endif
extern void swake_up_all_locked(struct swait_queue_head *q);
extern void __prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait);
extern int try_to_wake_up(struct task_struct *tsk, unsigned int state, int wake_flags);
#ifdef CONFIG_PREEMPT_DYNAMIC
extern int preempt_dynamic_mode;
extern int sched_dynamic_mode(const char *str);
extern void sched_dynamic_update(int mode);
#endif
#ifdef CONFIG_SCHED_MM_CID
#define SCHED_MM_CID_PERIOD_NS …
#define MM_CID_SCAN_DELAY …
extern raw_spinlock_t cid_lock;
extern int use_cid_lock;
extern void sched_mm_cid_migrate_from(struct task_struct *t);
extern void sched_mm_cid_migrate_to(struct rq *dst_rq, struct task_struct *t);
extern void task_tick_mm_cid(struct rq *rq, struct task_struct *curr);
extern void init_sched_mm_cid(struct task_struct *t);
static inline void __mm_cid_put(struct mm_struct *mm, int cid)
{ … }
static inline void mm_cid_put_lazy(struct task_struct *t)
{ … }
static inline int mm_cid_pcpu_unset(struct mm_struct *mm)
{ … }
static inline void mm_cid_put(struct mm_struct *mm)
{ … }
static inline int __mm_cid_try_get(struct mm_struct *mm)
{ … }
static inline void mm_cid_snapshot_time(struct rq *rq, struct mm_struct *mm)
{ … }
static inline int __mm_cid_get(struct rq *rq, struct mm_struct *mm)
{ … }
static inline int mm_cid_get(struct rq *rq, struct mm_struct *mm)
{ … }
static inline void switch_mm_cid(struct rq *rq,
struct task_struct *prev,
struct task_struct *next)
{ … }
#else
static inline void switch_mm_cid(struct rq *rq, struct task_struct *prev, struct task_struct *next) { }
static inline void sched_mm_cid_migrate_from(struct task_struct *t) { }
static inline void sched_mm_cid_migrate_to(struct rq *dst_rq, struct task_struct *t) { }
static inline void task_tick_mm_cid(struct rq *rq, struct task_struct *curr) { }
static inline void init_sched_mm_cid(struct task_struct *t) { }
#endif
extern u64 avg_vruntime(struct cfs_rq *cfs_rq);
extern int entity_eligible(struct cfs_rq *cfs_rq, struct sched_entity *se);
#ifdef CONFIG_RT_MUTEXES
static inline int __rt_effective_prio(struct task_struct *pi_task, int prio)
{ … }
static inline int rt_effective_prio(struct task_struct *p, int prio)
{ … }
#else
static inline int rt_effective_prio(struct task_struct *p, int prio)
{
return prio;
}
#endif
extern int __sched_setscheduler(struct task_struct *p, const struct sched_attr *attr, bool user, bool pi);
extern int __sched_setaffinity(struct task_struct *p, struct affinity_context *ctx);
extern void __setscheduler_prio(struct task_struct *p, int prio);
extern void set_load_weight(struct task_struct *p, bool update_load);
extern void enqueue_task(struct rq *rq, struct task_struct *p, int flags);
extern void dequeue_task(struct rq *rq, struct task_struct *p, int flags);
extern void check_class_changed(struct rq *rq, struct task_struct *p,
const struct sched_class *prev_class,
int oldprio);
#ifdef CONFIG_SMP
extern struct balance_callback *splice_balance_callbacks(struct rq *rq);
extern void balance_callbacks(struct rq *rq, struct balance_callback *head);
#else
static inline struct balance_callback *splice_balance_callbacks(struct rq *rq)
{
return NULL;
}
static inline void balance_callbacks(struct rq *rq, struct balance_callback *head)
{
}
#endif
#endif