#include <linux/sched/signal.h>
#include <linux/sched/cputime.h>
#include <linux/posix-timers.h>
#include <linux/errno.h>
#include <linux/math64.h>
#include <linux/uaccess.h>
#include <linux/kernel_stat.h>
#include <trace/events/timer.h>
#include <linux/tick.h>
#include <linux/workqueue.h>
#include <linux/compat.h>
#include <linux/sched/deadline.h>
#include <linux/task_work.h>
#include "posix-timers.h"
static void posix_cpu_timer_rearm(struct k_itimer *timer);
void posix_cputimers_group_init(struct posix_cputimers *pct, u64 cpu_limit)
{ … }
int update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new)
{ … }
static struct pid *pid_for_clock(const clockid_t clock, bool gettime)
{ … }
static inline int validate_clock_permissions(const clockid_t clock)
{ … }
static inline enum pid_type clock_pid_type(const clockid_t clock)
{ … }
static inline struct task_struct *cpu_timer_task_rcu(struct k_itimer *timer)
{ … }
static u64 bump_cpu_timer(struct k_itimer *timer, u64 now)
{ … }
static inline bool expiry_cache_is_inactive(const struct posix_cputimers *pct)
{ … }
static int
posix_cpu_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
{ … }
static int
posix_cpu_clock_set(const clockid_t clock, const struct timespec64 *tp)
{ … }
static u64 cpu_clock_sample(const clockid_t clkid, struct task_struct *p)
{ … }
static inline void store_samples(u64 *samples, u64 stime, u64 utime, u64 rtime)
{ … }
static void task_sample_cputime(struct task_struct *p, u64 *samples)
{ … }
static void proc_sample_cputime_atomic(struct task_cputime_atomic *at,
u64 *samples)
{ … }
static inline void __update_gt_cputime(atomic64_t *cputime, u64 sum_cputime)
{ … }
static void update_gt_cputime(struct task_cputime_atomic *cputime_atomic,
struct task_cputime *sum)
{ … }
void thread_group_sample_cputime(struct task_struct *tsk, u64 *samples)
{ … }
static void thread_group_start_cputime(struct task_struct *tsk, u64 *samples)
{ … }
static void __thread_group_cputime(struct task_struct *tsk, u64 *samples)
{ … }
static u64 cpu_clock_sample_group(const clockid_t clkid, struct task_struct *p,
bool start)
{ … }
static int posix_cpu_clock_get(const clockid_t clock, struct timespec64 *tp)
{ … }
static int posix_cpu_timer_create(struct k_itimer *new_timer)
{ … }
static struct posix_cputimer_base *timer_base(struct k_itimer *timer,
struct task_struct *tsk)
{ … }
static void trigger_base_recalc_expires(struct k_itimer *timer,
struct task_struct *tsk)
{ … }
static void disarm_timer(struct k_itimer *timer, struct task_struct *p)
{ … }
static int posix_cpu_timer_del(struct k_itimer *timer)
{ … }
static void cleanup_timerqueue(struct timerqueue_head *head)
{ … }
static void cleanup_timers(struct posix_cputimers *pct)
{ … }
void posix_cpu_timers_exit(struct task_struct *tsk)
{ … }
void posix_cpu_timers_exit_group(struct task_struct *tsk)
{ … }
static void arm_timer(struct k_itimer *timer, struct task_struct *p)
{ … }
static void cpu_timer_fire(struct k_itimer *timer)
{ … }
static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
struct itimerspec64 *new, struct itimerspec64 *old)
{ … }
static void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *itp)
{ … }
#define MAX_COLLECTED …
static u64 collect_timerqueue(struct timerqueue_head *head,
struct list_head *firing, u64 now)
{ … }
static void collect_posix_cputimers(struct posix_cputimers *pct, u64 *samples,
struct list_head *firing)
{ … }
static inline void check_dl_overrun(struct task_struct *tsk)
{ … }
static bool check_rlimit(u64 time, u64 limit, int signo, bool rt, bool hard)
{ … }
static void check_thread_timers(struct task_struct *tsk,
struct list_head *firing)
{ … }
static inline void stop_process_timers(struct signal_struct *sig)
{ … }
static void check_cpu_itimer(struct task_struct *tsk, struct cpu_itimer *it,
u64 *expires, u64 cur_time, int signo)
{ … }
static void check_process_timers(struct task_struct *tsk,
struct list_head *firing)
{ … }
static void posix_cpu_timer_rearm(struct k_itimer *timer)
{ … }
static inline bool
task_cputimers_expired(const u64 *samples, struct posix_cputimers *pct)
{ … }
static inline bool fastpath_timer_check(struct task_struct *tsk)
{ … }
static void handle_posix_cpu_timers(struct task_struct *tsk);
#ifdef CONFIG_POSIX_CPU_TIMERS_TASK_WORK
static void posix_cpu_timers_work(struct callback_head *work)
{ … }
static void posix_cpu_timer_wait_running(struct k_itimer *timr)
{ … }
static void posix_cpu_timer_wait_running_nsleep(struct k_itimer *timr)
{ … }
void clear_posix_cputimers_work(struct task_struct *p)
{ … }
void __init posix_cputimers_init_work(void)
{ … }
static inline bool posix_cpu_timers_work_scheduled(struct task_struct *tsk)
{ … }
static inline void __run_posix_cpu_timers(struct task_struct *tsk)
{ … }
static inline bool posix_cpu_timers_enable_work(struct task_struct *tsk,
unsigned long start)
{ … }
#else
static inline void __run_posix_cpu_timers(struct task_struct *tsk)
{
lockdep_posixtimer_enter();
handle_posix_cpu_timers(tsk);
lockdep_posixtimer_exit();
}
static void posix_cpu_timer_wait_running(struct k_itimer *timr)
{
cpu_relax();
}
static void posix_cpu_timer_wait_running_nsleep(struct k_itimer *timr)
{
spin_unlock_irq(&timr->it_lock);
cpu_relax();
spin_lock_irq(&timr->it_lock);
}
static inline bool posix_cpu_timers_work_scheduled(struct task_struct *tsk)
{
return false;
}
static inline bool posix_cpu_timers_enable_work(struct task_struct *tsk,
unsigned long start)
{
return true;
}
#endif
static void handle_posix_cpu_timers(struct task_struct *tsk)
{ … }
void run_posix_cpu_timers(void)
{ … }
void set_process_cpu_timer(struct task_struct *tsk, unsigned int clkid,
u64 *newval, u64 *oldval)
{ … }
static int do_cpu_nanosleep(const clockid_t which_clock, int flags,
const struct timespec64 *rqtp)
{ … }
static long posix_cpu_nsleep_restart(struct restart_block *restart_block);
static int posix_cpu_nsleep(const clockid_t which_clock, int flags,
const struct timespec64 *rqtp)
{ … }
static long posix_cpu_nsleep_restart(struct restart_block *restart_block)
{ … }
#define PROCESS_CLOCK …
#define THREAD_CLOCK …
static int process_cpu_clock_getres(const clockid_t which_clock,
struct timespec64 *tp)
{ … }
static int process_cpu_clock_get(const clockid_t which_clock,
struct timespec64 *tp)
{ … }
static int process_cpu_timer_create(struct k_itimer *timer)
{ … }
static int process_cpu_nsleep(const clockid_t which_clock, int flags,
const struct timespec64 *rqtp)
{ … }
static int thread_cpu_clock_getres(const clockid_t which_clock,
struct timespec64 *tp)
{ … }
static int thread_cpu_clock_get(const clockid_t which_clock,
struct timespec64 *tp)
{ … }
static int thread_cpu_timer_create(struct k_itimer *timer)
{ … }
const struct k_clock clock_posix_cpu = …;
const struct k_clock clock_process = …;
const struct k_clock clock_thread = …;