Skip to content

Commit 9344c92

Browse files
Rik van RielIngo Molnar
authored andcommitted
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>
1 parent b2add86 commit 9344c92

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

kernel/tsacct.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,18 @@ static void __acct_update_integrals(struct task_struct *tsk,
126126
cputime_t utime, cputime_t stime)
127127
{
128128
cputime_t time, dtime;
129-
unsigned long flags;
130129
u64 delta;
131130

132131
if (!likely(tsk->mm))
133132
return;
134133

135-
local_irq_save(flags);
136134
time = stime + utime;
137135
dtime = time - tsk->acct_timexpd;
138136
/* Avoid division: cputime_t is often in nanoseconds already. */
139137
delta = cputime_to_nsecs(dtime);
140138

141139
if (delta < TICK_NSEC)
142-
goto out;
140+
return;
143141

144142
tsk->acct_timexpd = time;
145143
/*
@@ -149,8 +147,6 @@ static void __acct_update_integrals(struct task_struct *tsk,
149147
*/
150148
tsk->acct_rss_mem1 += delta * get_mm_rss(tsk->mm) >> 10;
151149
tsk->acct_vm_mem1 += delta * tsk->mm->total_vm >> 10;
152-
out:
153-
local_irq_restore(flags);
154150
}
155151

156152
/**
@@ -160,9 +156,12 @@ static void __acct_update_integrals(struct task_struct *tsk,
160156
void acct_update_integrals(struct task_struct *tsk)
161157
{
162158
cputime_t utime, stime;
159+
unsigned long flags;
163160

161+
local_irq_save(flags);
164162
task_cputime(tsk, &utime, &stime);
165163
__acct_update_integrals(tsk, utime, stime);
164+
local_irq_restore(flags);
166165
}
167166

168167
/**

0 commit comments

Comments
 (0)