History

posix-cpu-timers: Rename thread_group_cputimer() and make it static

thread_group_cputimer() is a complete misnomer. The function does two things: - For arming process wide timers it makes sure that the atomic time storage is up to date. If no cpu timer is armed yet, then the atomic time storage is not updated by the scheduler for performance reasons. In that case a full summing up of all threads needs to be done and the update needs to be enabled. - Samples the current time into the caller supplied storage. Rename it to thread_group_start_cputime(), make it static and fixup the callsite.

Thomas Gleixner committed 7 years ago

Commit c506bef1 parent a3249562 files · +15 −3Browse files

Unified · Split

2 files
  1. include/linux/sched/cputime.h +0 −1
  2. kernel/time/posix-cpu-timers.c +15 −2
include/linux/sched/cputime.h+0−1
@@ -61,7 +61,6 @@ extern void cputime_adjust(struct task_cputime *curr, struct prev_cputime *prev, · 60 unmodified lines
6161 * Thread group CPU time accounting.
6262 */
6363 void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
64−void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times);
6564 void thread_group_sample_cputime(struct task_struct *tsk, struct task_cputime *times);
6665
6766 /*
kernel/time/posix-cpu-timers.c+15−2
@@ -253,7 +253,20 @@ void thread_group_sample_cputime(struct task_struct *tsk, · 252 unmodified lines
253253 sample_cputime_atomic(times, &cputimer->cputime_atomic);
254254 }
255255
256−void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
256+/**
257+ * thread_group_start_cputime - Start cputime and return a sample
258+ * @tsk: Task for which cputime needs to be started
259+ * @iimes: Storage for time samples
260+ *
261+ * The thread group cputime accouting is avoided when there are no posix
262+ * CPU timers armed. Before starting a timer it's required to check whether
263+ * the time accounting is active. If not, a full update of the atomic
264+ * accounting store needs to be done and the accounting enabled.
265+ *
266+ * Updates @times with an uptodate sample of the thread group cputimes.
267+ */
268+static void
269+thread_group_start_cputime(struct task_struct *tsk, struct task_cputime *times)
257270 {
258271 struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
259272 struct task_cputime sum;
@@ -536,7 +549,7 @@ static int cpu_timer_sample_group(const clockid_t which_clock, · 276 unmodified lines
536549 {
537550 struct task_cputime cputime;
538551
539− thread_group_cputimer(p, &cputime);
552+ thread_group_start_cputime(p, &cputime);
540553 switch (CPUCLOCK_WHICH(which_clock)) {
541554 default:
542555 return -EINVAL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t