summaryrefslogtreecommitdiffstats
path: root/kernel/tsacct.c
diff options
context:
space:
mode:
authorRik van Riel <riel@redhat.com>2016-02-10 20:08:26 -0500
committerIngo Molnar <mingo@kernel.org>2016-02-29 03:53:09 -0500
commit9344c92c2e72e495f695caef8364b3dd73af0eab (patch)
tree02123a47ac85b4bf35485972a72058b75121f269 /kernel/tsacct.c
parentb2add86edd3bc050af350515e6ba26f4622c38f3 (diff)
time, acct: Drop irq save & restore from __acct_update_integrals()
It looks like all the call paths that lead to __acct_update_integrals() already have irqs disabled, and __acct_update_integrals() does not need to disable irqs itself. This is very convenient since about half the CPU time left in this function was spent in local_irq_save alone. Performance of a microbenchmark that calls an invalid syscall ten million times in a row on a nohz_full CPU improves 21% vs. 4.5-rc1 with both the removal of divisions from __acct_update_integrals() and this patch, with runtime dropping from 3.7 to 2.9 seconds. With these patches applied, the highest remaining cpu user in the trace is native_sched_clock, which is addressed in the next patch. For testing purposes I stuck a WARN_ON(!irqs_disabled()) test in __acct_update_integrals(). It did not trigger. Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: clark@redhat.com Cc: eric.dumazet@gmail.com Cc: fweisbec@gmail.com Cc: luto@amacapital.net Link: http://lkml.kernel.org/r/1455152907-18495-4-git-send-email-riel@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/tsacct.c')
-rw-r--r--kernel/tsacct.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index d12e815b7bcd..f8e26ab963ed 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -126,20 +126,18 @@ static void __acct_update_integrals(struct task_struct *tsk,
126 cputime_t utime, cputime_t stime) 126 cputime_t utime, cputime_t stime)
127{ 127{
128 cputime_t time, dtime; 128 cputime_t time, dtime;
129 unsigned long flags;
130 u64 delta; 129 u64 delta;
131 130
132 if (!likely(tsk->mm)) 131 if (!likely(tsk->mm))
133 return; 132 return;
134 133
135 local_irq_save(flags);
136 time = stime + utime; 134 time = stime + utime;
137 dtime = time - tsk->acct_timexpd; 135 dtime = time - tsk->acct_timexpd;
138 /* Avoid division: cputime_t is often in nanoseconds already. */ 136 /* Avoid division: cputime_t is often in nanoseconds already. */
139 delta = cputime_to_nsecs(dtime); 137 delta = cputime_to_nsecs(dtime);
140 138
141 if (delta < TICK_NSEC) 139 if (delta < TICK_NSEC)
142 goto out; 140 return;
143 141
144 tsk->acct_timexpd = time; 142 tsk->acct_timexpd = time;
145 /* 143 /*
@@ -149,8 +147,6 @@ static void __acct_update_integrals(struct task_struct *tsk,
149 */ 147 */
150 tsk->acct_rss_mem1 += delta * get_mm_rss(tsk->mm) >> 10; 148 tsk->acct_rss_mem1 += delta * get_mm_rss(tsk->mm) >> 10;
151 tsk->acct_vm_mem1 += delta * tsk->mm->total_vm >> 10; 149 tsk->acct_vm_mem1 += delta * tsk->mm->total_vm >> 10;
152out:
153 local_irq_restore(flags);
154} 150}
155 151
156/** 152/**
@@ -160,9 +156,12 @@ out:
160void acct_update_integrals(struct task_struct *tsk) 156void acct_update_integrals(struct task_struct *tsk)
161{ 157{
162 cputime_t utime, stime; 158 cputime_t utime, stime;
159 unsigned long flags;
163 160
161 local_irq_save(flags);
164 task_cputime(tsk, &utime, &stime); 162 task_cputime(tsk, &utime, &stime);
165 __acct_update_integrals(tsk, utime, stime); 163 __acct_update_integrals(tsk, utime, stime);
164 local_irq_restore(flags);
166} 165}
167 166
168/** 167/**