|
@@ -172,18 +172,19 @@ sched_info_switch(struct rq *rq,
|
|
*/
|
|
*/
|
|
|
|
|
|
/**
|
|
/**
|
|
- * cputimer_running - return true if cputimer is running
|
|
|
|
|
|
+ * get_running_cputimer - return &tsk->signal->cputimer if cputimer is running
|
|
*
|
|
*
|
|
* @tsk: Pointer to target task.
|
|
* @tsk: Pointer to target task.
|
|
*/
|
|
*/
|
|
-static inline bool cputimer_running(struct task_struct *tsk)
|
|
|
|
-
|
|
|
|
|
|
+#ifdef CONFIG_POSIX_TIMERS
|
|
|
|
+static inline
|
|
|
|
+struct thread_group_cputimer *get_running_cputimer(struct task_struct *tsk)
|
|
{
|
|
{
|
|
struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
|
|
struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
|
|
|
|
|
|
/* Check if cputimer isn't running. This is accessed without locking. */
|
|
/* Check if cputimer isn't running. This is accessed without locking. */
|
|
if (!READ_ONCE(cputimer->running))
|
|
if (!READ_ONCE(cputimer->running))
|
|
- return false;
|
|
|
|
|
|
+ return NULL;
|
|
|
|
|
|
/*
|
|
/*
|
|
* After we flush the task's sum_exec_runtime to sig->sum_sched_runtime
|
|
* After we flush the task's sum_exec_runtime to sig->sum_sched_runtime
|
|
@@ -200,10 +201,17 @@ static inline bool cputimer_running(struct task_struct *tsk)
|
|
* clock delta is behind the expiring timer value.
|
|
* clock delta is behind the expiring timer value.
|
|
*/
|
|
*/
|
|
if (unlikely(!tsk->sighand))
|
|
if (unlikely(!tsk->sighand))
|
|
- return false;
|
|
|
|
|
|
+ return NULL;
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
+ return cputimer;
|
|
|
|
+}
|
|
|
|
+#else
|
|
|
|
+static inline
|
|
|
|
+struct thread_group_cputimer *get_running_cputimer(struct task_struct *tsk)
|
|
|
|
+{
|
|
|
|
+ return NULL;
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
/**
|
|
/**
|
|
* account_group_user_time - Maintain utime for a thread group.
|
|
* account_group_user_time - Maintain utime for a thread group.
|
|
@@ -218,9 +226,9 @@ static inline bool cputimer_running(struct task_struct *tsk)
|
|
static inline void account_group_user_time(struct task_struct *tsk,
|
|
static inline void account_group_user_time(struct task_struct *tsk,
|
|
cputime_t cputime)
|
|
cputime_t cputime)
|
|
{
|
|
{
|
|
- struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
|
|
|
|
|
|
+ struct thread_group_cputimer *cputimer = get_running_cputimer(tsk);
|
|
|
|
|
|
- if (!cputimer_running(tsk))
|
|
|
|
|
|
+ if (!cputimer)
|
|
return;
|
|
return;
|
|
|
|
|
|
atomic64_add(cputime, &cputimer->cputime_atomic.utime);
|
|
atomic64_add(cputime, &cputimer->cputime_atomic.utime);
|
|
@@ -239,9 +247,9 @@ static inline void account_group_user_time(struct task_struct *tsk,
|
|
static inline void account_group_system_time(struct task_struct *tsk,
|
|
static inline void account_group_system_time(struct task_struct *tsk,
|
|
cputime_t cputime)
|
|
cputime_t cputime)
|
|
{
|
|
{
|
|
- struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
|
|
|
|
|
|
+ struct thread_group_cputimer *cputimer = get_running_cputimer(tsk);
|
|
|
|
|
|
- if (!cputimer_running(tsk))
|
|
|
|
|
|
+ if (!cputimer)
|
|
return;
|
|
return;
|
|
|
|
|
|
atomic64_add(cputime, &cputimer->cputime_atomic.stime);
|
|
atomic64_add(cputime, &cputimer->cputime_atomic.stime);
|
|
@@ -260,9 +268,9 @@ static inline void account_group_system_time(struct task_struct *tsk,
|
|
static inline void account_group_exec_runtime(struct task_struct *tsk,
|
|
static inline void account_group_exec_runtime(struct task_struct *tsk,
|
|
unsigned long long ns)
|
|
unsigned long long ns)
|
|
{
|
|
{
|
|
- struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
|
|
|
|
|
|
+ struct thread_group_cputimer *cputimer = get_running_cputimer(tsk);
|
|
|
|
|
|
- if (!cputimer_running(tsk))
|
|
|
|
|
|
+ if (!cputimer)
|
|
return;
|
|
return;
|
|
|
|
|
|
atomic64_add(ns, &cputimer->cputime_atomic.sum_exec_runtime);
|
|
atomic64_add(ns, &cputimer->cputime_atomic.sum_exec_runtime);
|