Skip to content

Commit e80d0a1

Browse files
committed
cputime: Rename thread_group_times to thread_group_cputime_adjusted
We have thread_group_cputime() and thread_group_times(). The naming doesn't provide enough information about the difference between these two APIs. To lower the confusion, rename thread_group_times() to thread_group_cputime_adjusted(). This name better suggests that it's a version of thread_group_cputime() that does some stabilization on the raw cputime values. ie here: scale on top of CFS runtime stats and bound lower value for monotonicity. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
1 parent a634f93 commit e80d0a1

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎fs/proc/array.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
438438

439439
min_flt += sig->min_flt;
440440
maj_flt += sig->maj_flt;
441-
thread_group_times(task, &utime, &stime);
441+
thread_group_cputime_adjusted(task, &utime, &stime);
442442
gtime += sig->gtime;
443443
}
444444

@@ -454,7 +454,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
454454
if (!whole) {
455455
min_flt = task->min_flt;
456456
maj_flt = task->maj_flt;
457-
task_times(task, &utime, &stime);
457+
task_cputime_adjusted(task, &utime, &stime);
458458
gtime = task->gtime;
459459
}
460460

‎include/linux/sched.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,8 +1751,8 @@ static inline void put_task_struct(struct task_struct *t)
17511751
__put_task_struct(t);
17521752
}
17531753

1754-
extern void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st);
1755-
extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st);
1754+
extern void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st);
1755+
extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st);
17561756

17571757
/*
17581758
* Per process flags

‎kernel/exit.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,11 +1186,11 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
11861186
* as other threads in the parent group can be right
11871187
* here reaping other children at the same time.
11881188
*
1189-
* We use thread_group_times() to get times for the thread
1189+
* We use thread_group_cputime_adjusted() to get times for the thread
11901190
* group, which consolidates times for all threads in the
11911191
* group including the group leader.
11921192
*/
1193-
thread_group_times(p, &tgutime, &tgstime);
1193+
thread_group_cputime_adjusted(p, &tgutime, &tgstime);
11941194
spin_lock_irq(&p->real_parent->sighand->siglock);
11951195
psig = p->real_parent->signal;
11961196
sig = p->signal;

‎kernel/sched/cputime.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,13 @@ void account_idle_ticks(unsigned long ticks)
445445
* Use precise platform statistics if available:
446446
*/
447447
#ifdef CONFIG_VIRT_CPU_ACCOUNTING
448-
void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
448+
void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st)
449449
{
450450
*ut = p->utime;
451451
*st = p->stime;
452452
}
453453

454-
void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
454+
void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st)
455455
{
456456
struct task_cputime cputime;
457457

@@ -516,7 +516,7 @@ static cputime_t scale_utime(cputime_t utime, cputime_t rtime, cputime_t total)
516516
return (__force cputime_t) temp;
517517
}
518518

519-
void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
519+
void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st)
520520
{
521521
cputime_t rtime, utime = p->utime, total = utime + p->stime;
522522

@@ -543,7 +543,7 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
543543
/*
544544
* Must be called with siglock held.
545545
*/
546-
void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
546+
void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st)
547547
{
548548
struct signal_struct *sig = p->signal;
549549
struct task_cputime cputime;

‎kernel/sys.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ void do_sys_times(struct tms *tms)
10461046
cputime_t tgutime, tgstime, cutime, cstime;
10471047

10481048
spin_lock_irq(&current->sighand->siglock);
1049-
thread_group_times(current, &tgutime, &tgstime);
1049+
thread_group_cputime_adjusted(current, &tgutime, &tgstime);
10501050
cutime = current->signal->cutime;
10511051
cstime = current->signal->cstime;
10521052
spin_unlock_irq(&current->sighand->siglock);
@@ -1704,7 +1704,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
17041704
utime = stime = 0;
17051705

17061706
if (who == RUSAGE_THREAD) {
1707-
task_times(current, &utime, &stime);
1707+
task_cputime_adjusted(current, &utime, &stime);
17081708
accumulate_thread_rusage(p, r);
17091709
maxrss = p->signal->maxrss;
17101710
goto out;
@@ -1730,7 +1730,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
17301730
break;
17311731

17321732
case RUSAGE_SELF:
1733-
thread_group_times(p, &tgutime, &tgstime);
1733+
thread_group_cputime_adjusted(p, &tgutime, &tgstime);
17341734
utime += tgutime;
17351735
stime += tgstime;
17361736
r->ru_nvcsw += p->signal->nvcsw;

0 commit comments

Comments
 (0)