[tip:sched/urgent] sched: account system time properly



Commit-ID: f5f293a4e3d0a0c52cec31de6762c95050156516
Gitweb: http://git.kernel.org/tip/f5f293a4e3d0a0c52cec31de6762c95050156516
Author: Eric Dumazet <dada1@xxxxxxxxxxxxx>
AuthorDate: Wed, 29 Apr 2009 14:44:49 +0200
Committer: Ingo Molnar <mingo@xxxxxxx>
CommitDate: Wed, 29 Apr 2009 15:02:28 +0200

sched: account system time properly

Andrew Gallatin reported that IRQ and SOFTIRQ times were
sometime not reported correctly on recent kernels, and even
bisected to commit 457533a7d3402d1d91fbc125c8bd1bd16dcd3cd4
([PATCH] fix scaled & unscaled cputime accounting) as the first
bad commit.

Further analysis pointed that commit
79741dd35713ff4f6fd0eafd59fa94e8a4ba922d ([PATCH] idle cputime
accounting) was the real cause of the problem.

account_process_tick() was not taking into account timer IRQ
interrupting the idle task servicing a hard or soft irq.

On mostly idle cpu, irqs were thus not accounted and top or
mpstat could tell user/admin that cpu was 100 % idle, 0.00 %
irq, 0.00 % softirq, while it was not.

[ Impact: fix occasionally incorrect CPU statistics in top/mpstat ]

Reported-by: Andrew Gallatin <gallatin@xxxxxxxx>
Re-reported-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Eric Dumazet <dada1@xxxxxxxxxxxxx>
Acked-by: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
Cc: rick.jones2@xxxxxx
Cc: brice@xxxxxxxx
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>
LKML-Reference: <49F84BC1.7080602@xxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>


---
kernel/sched.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index b902e58..26efa47 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4732,7 +4732,7 @@ void account_process_tick(struct task_struct *p, int user_tick)

if (user_tick)
account_user_time(p, one_jiffy, one_jiffy_scaled);
- else if (p != rq->idle)
+ else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET))
account_system_time(p, HARDIRQ_OFFSET, one_jiffy,
one_jiffy_scaled);
else
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [PATCH] sched: account system time properly
    ... So, if IRQs are interrupting idle task, I guess if will be false. ... When idle task is interrupted by an IRQ, time accounting considers CPU is idle, ... even while it should account for hard or softirq. ... That patch makes a lot of sense to me. ...
    (Linux-Kernel)
  • Re: transaction demarction
    ... do they mark something? ... a banking transaction that moves money from one bank account ... that involves database access and ends when you either COMMIT or ROLLBACK. ...
    (comp.lang.java.programmer)
  • Re: Question about using ROWLOCK and XLOCK
    ... I like your original suggestion because it is more efficient (1-2 T-SQL ... account that UPDATE may return @@ROWCOUNT=0 because the other process has ... BEGIN TRAN t ... COMMIT t ...
    (microsoft.public.sqlserver.programming)
  • Re: [PATCH] sched: properly account IRQ and RT load in SCHED_OTHER load balancing
    ... it doesn't take IRQ time into account. ... * period over which we measure -rt task cpu usage in us. ...
    (Linux-Kernel)
  • Re: [PATCH 1/2] Xen: Fix bug `do_IRQ: cannot handle IRQ -1 vector 0x6 cpu 1
    ... Following commit 9c3f2468d8339866d9ef6a25aae31a8909c6be0d, do_IRQ() looks up the IRQ number in the per-cpu variable vector_irq. ... wonder you need to do sth for lguest too. ... Yes it crashes VMI too, i will get down to debug this maybe later in the ...
    (Linux-Kernel)